diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2021-03-14 02:16:41 +0530 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2021-03-14 02:16:41 +0530 |
commit | f27b930331cc5dc70d070de4a10459d551dd597e (patch) | |
tree | 55c2184a001be460b0dab72a8109fda2c6b87d11 /assets/src/js/main.js |
v0.007
Diffstat (limited to 'assets/src/js/main.js')
-rw-r--r-- | assets/src/js/main.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/assets/src/js/main.js b/assets/src/js/main.js new file mode 100644 index 0000000..936215e --- /dev/null +++ b/assets/src/js/main.js @@ -0,0 +1,61 @@ +// import Popper +//= ../../../node_modules/popper.js/dist/umd/popper.js + +// import required js-files Bootstrap 5 +//= ../../../node_modules/bootstrap/js/dist/alert.js +//= ../../../node_modules/bootstrap/js/dist/button.js +//= ../../../node_modules/bootstrap/js/dist/carousel.js +//= ../../../node_modules/bootstrap/js/dist/collapse.js +//= ../../../node_modules/bootstrap/js/dist/dropdown.js +//= ../../../node_modules/bootstrap/js/dist/modal.js +//= ../../../node_modules/bootstrap/js/dist/popover.js +//= ../../../node_modules/bootstrap/js/dist/scrollspy.js +//= ../../../node_modules/bootstrap/js/dist/tab.js +//= ../../../node_modules/bootstrap/js/dist/toast.js +//= ../../../node_modules/bootstrap/js/dist/tooltip.js + +function bruh_moment(){ + alert('this is a bruh moment') +} + +function get_smiles_from_element_text(el_id){ + var inputVal = document.getElementById(el_id).value; + let url = `https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/${inputVal}/property/CanonicalSMILES/JSON`; + console.log(url) + fetch(url) + .then(res => res.json()) + .then((out) => { + console.log('Aye, got that dub from PubChem'); + //console.log(out["PropertyTable"]["Properties"][0]["CanonicalSMILES"]) + document.getElementById("inputSMILES").value = out["PropertyTable"]["Properties"][0]["CanonicalSMILES"] + }) + .catch(err => { + bruh_moment() + throw err }); +} + + +function draw_me_like_one_of_your_french_girls(mol){ + + mol.condense_abbreviations(); + var canvas = document.getElementById("draw-canvas-2"); + mol.draw_to_canvas(canvas, -1, -1); +} + + +function calculate_and_disperse(mol){ + var descrs = JSON.parse(mol.get_descriptors()); + document.getElementById('exactmw').textContent = descrs["exactmw"]; + document.getElementById('CrippenMR').textContent = descrs["CrippenMR"]; + document.getElementById('CrippenClogP').textContent = descrs["CrippenClogP"]; + + +} + +function analyse_me_senpai(smile_pwiz) { + var smiles = document.getElementById(smile_pwiz).value; + var mol = Module.get_mol(smiles); + draw_me_like_one_of_your_french_girls(mol); + calculate_and_disperse(mol); +} + |