Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
63 lines (54 sloc) 1.54 KB
<html>
<head>
<title>WebMolKit - Sketcher</title>
<script src="../../bin/jquery.js" type="text/javascript"></script>
<script src="../../bin/webmolkit-build.js" type="text/javascript"></script>
</head>
<body>
<h1>WebMolKit - Sketcher</h1>
<span id="moldata" style="display: none;">SketchEl!(10,10)
C=-0.4500,2.5500;0,0,i0
C=-1.7490,1.8000;0,0,i1
C=0.8490,1.8000;0,0,i1
C=-1.7490,0.3000;0,0,i1
C=-0.4500,-0.4500;0,0,i0
C=0.8490,0.3000;0,0,i1
N=-0.4500,-1.9500;1,0,i3
C=-0.4500,4.0500;0,0,i0
O=0.8490,4.8000;-1,0,i0
O=-1.7490,4.8000;0,0,i0
1-2=1,0
1-3=2,0
2-4=2,0
4-5=1,0
5-6=2,0
6-3=1,0
5-7=1,0
1-8=1,0
8-9=1,0
8-10=2,0
!End</span>
<p id="sketcher"></p>
<p id="buttons">
<button onClick="sketcher.clearMolecule()">Clear</button>
<button onClick="demoMolecule()">Demo Molecule</button>
<button onClick="copySketchEl()">Copy SketchEl</button>
<button onClick="copyMDLMOL()">Copy MDLMOL</button>
</p>
<script>
var wmk = WebMolKit;
var url = window.location.href.substring(0, window.location.href.lastIndexOf('/'));
wmk.initWebMolKit(url + '../../../res');
var mol = wmk.Molecule.fromString($('#moldata').text());
var sketcher = new wmk.Sketcher();
sketcher.setSize(800, 700);
sketcher.defineMolecule(mol);
let proxy = new wmk.ClipboardProxyWeb();
sketcher.defineClipboard(proxy);
sketcher.setup(() => sketcher.render($('#sketcher')));
function demoMolecule() {sketcher.defineMolecule(mol);}
function copySketchEl() {sketcher.performCopy();}
function copyMDLMOL() {proxy.setString(new wmk.MDLMOLWriter(sketcher.getMolecule()).write());}
</script>
</body>
</html>