How would I go about porting older javascript code to work with jupyter lab?
We are using some old javascript code that implements an editor for sketching molecular structures.
This editor can be embedded within web pages per the instructions on that website - but it's not modularized in the style of CommonJS.
I can embed this editor within a jupyter notebook output cell and sketch a molecule within it and make the output available to the jupyter notebook kernel.
I'd like to move to Jupyter lab - it looks fantastic! But I can't figure out how to get this molecular sketching javascript code to work with Jupyter lab. Does anyone have any pointers - or can you tell me that it simply can't be done and we need javascript that is more modern?
This is the code that I use to hack this editor into a Jupyter notebook:
<script type="text/javascript" src="jsme/jsme.nocache.js"></script>
<script type="text/javascript">
function jsmeOnLoad() {
//arguments: HTML id, width, height (must be string not number!)
jsmeApplet12345 = new JSApplet.JSME("appletContainer12345", "640px", "400px", {
//optional parameters
"options" : "number,query,hydrogens,paste,zoom,atommovebutton,border"
});
var jme = `~A`;
jsmeApplet12345.readMolFile(jme);
}
function onSubmit() {
var drawing = jsmeApplet12345.molFile();
// document.getElementById('jsme_smiles12345').value = drawing;
var command = '(defparameter jsme::*sketch* "' + drawing + '")';
console.log("Executing Command: " + command);
var kernel = IPython.notebook.kernel;
kernel.execute(command);
}
</script>
<table align="left" style="border: none;">
<tr style="border: none;">
<td id="appletContainer12345" style="border: none;"></td>
<td style="vertical-align: bottom; border: none;">
<button onclick="onSubmit()">done !</button>
</td>
</tr>
</table>
Best,
Christian Schafmeister,
Professor,
Chemistry,
Temple University