Collections:
Refresh Molecule in JSME Editor
How to refresh (read and reset) molecule created in JSME editor with the Web server?
✍: FYIcenter.com
If you want refresh molecule properties displayed in the JSME editor,
you can use a PHP script on the Web server to read and reset the molecule
structure in the JSME editor.
1. Create an HTML form with an input field for submitting the molecule structure to the server.
<form id="jmeForm" action="update-molecule.php" method="post"> <input id="jmeVar" type="hidden" name="JME"/> <button type="button" onclick="jsmeOnClick();">Update"</button> </form>
2. Create a JavaScript function jsmeOnClick(), which will be called when the "Update" button is clicked. It reads the molecule structure in JME format from the JSME editor and submit the structure to the server using the HTML form.
<script>
function jsmeOnClick() {
var jme = jsmeObj.jmeFile();
document.getElementById("jmeVar").value = jme;
document.getElementById("jmeForm").submit();
}
</script>
3. Retrieve the molecule structure on the server side in the PHP script, update-molecule.php.
$jme = _REQUEST["JME"]; # save the structure to database or to a file.
4. Generate HTML document with JavaScript code to load the molecule structure into the JSME editor.
$jme = _REQUEST["JME"];
$htm = <<< EndOfHtml
<script>
function jsmeOnLoad() {
jsmeObj = new JSApplet.JSME("jsme_container", "380px", "340px");
jsmeObj.readMolecule($jme);
}
</script>
EndOfHtml;
Note that you also use the jsmeObj.readGenericMolecularInput($jme) to load the molecule structure in JME format. But it will display the "ERROR: Invalid JME string" message on the JSME editor, for an empty structure.
So JSME has a bug in the readGenericMolecularInput() code for a given empty structure in JME format: "0 0".
⇒ JSME Molecule Editor Options
2023-04-13, 1160🔥, 0💬
Popular Posts:
Molecule Summary: ID: FYI-1002941 Names: InChIKey: QNOYEQFIQLMSPD-UHFFFAOYS A-NSMILES: CS(=O)(=Nc1c(...
How to create and edit a chemical Reaction with Ketcher editor? To help you to create and edit a che...
Molecule Summary: ID: FYI-1002537 Names: InChIKey: WSLBJQQQZZTFBA-QQSPYBPKS A-NSMILES: CCCCC/C=C/C/C...
What is JSME JavaScript API? I want to see an example on how to use it. JSME JavaScript API is progr...
Molecule Summary: ID: FYI-1004215 Names: InChIKey: KUPLEGDPSCCPJI-UHFFFAOYS A-NSMILES: CCCCCCCCCCCCC...