Skip to content

Commit

Permalink
jsme works!
Browse files Browse the repository at this point in the history
  • Loading branch information
syedzayyan committed Jun 5, 2024
1 parent acc1c56 commit 91a7548
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/misc_tools/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function JSMEPOPO() {
return (
<div className="container">
<div className="content-wrapper" style={{ marginTop: "60px" }}>
<JSME height="500px" width="500px" onChange={handleChange} id = 'test'/>
<JSME height="500px" width="500px" onChange={handleChange} />
</div>
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion app/tools/toc/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function TOC() {
<input ref={inputRef} className = "input" type="text" placeholder="Search By Substructure/SMILES" onChange={(e) => setSearchSmi(e.target.value)}/>
&nbsp;
<Dropdown buttonText="Draw the molecule">
<JSME width="300px" height="300px" onChange={(smiles) => setSearchSmi(smiles)} />
<JSME width="400px" height="300px" onChange={(smiles) => setSearchSmi(smiles)} />
</Dropdown>
&nbsp;
<button className="button" onClick={() => searchSubst()}>Substructure Search molecule</button>
Expand Down
28 changes: 17 additions & 11 deletions components/tools/toolViz/JSMEComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ const Jsme = ({ height, width, smiles, options, onChange, src }) => {
jsmeApplet.setCallBack("AfterStructureModified", handleChange);
jsmeApplet.readGenericMolecularInput(smiles);
} else {
const jsmeApplet = new globalThis.JSApplet.JSME(id, width, height);
const jsmeApplet = new globalThis.JSApplet.JSME(id, width, height, {
"options": "newlook",
"guicolor": "#FFFFFF",
"guiAtomColor": "#000000"
});
jsmeApplet.setCallBack("AfterStructureModified", handleChange);
jsmeApplet.readGenericMolecularInput(smiles);
}
Expand All @@ -47,18 +51,20 @@ const Jsme = ({ height, width, smiles, options, onChange, src }) => {
}, [onChange]);

useEffect(() => {
if (jsmeIsLoaded) {
handleJsmeLoad();
} else {
if (!globalThis.jsmeOnLoad) {
setup(src);
if (myRef.current && myRef.current.children.length < 1) {
if (jsmeIsLoaded) {
handleJsmeLoad();
} else {
if (!globalThis.jsmeOnLoad) {
setup(src);
}
jsmeCallbacks[id] = handleJsmeLoad;
}
jsmeCallbacks[id] = handleJsmeLoad;

return () => {
jsmeCallbacks[id] = undefined;
};
}

return () => {
jsmeCallbacks[id] = undefined;
};
}, []);

useEffect(() => {
Expand Down

0 comments on commit 91a7548

Please sign in to comment.