-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
142 lines (119 loc) · 3.82 KB
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// communicate with background page to clear badge
chrome.runtime.sendMessage({method:"changeBadge"},(Response)=>
{
console.log("message send");
})
// Defining constant value
let input = document.getElementById("example-input");
const options = {
width: 365,
height: 200,
bondThickness: 0.8,
bondLength: 15,
shortBondLength: 0.85,
bondSpacing: 0.18 * 15,
atomVisualization: 'default',
isomeric: true,
debug: false,
terminalCarbons: false,
explicitHydrogens: true,
overlapSensitivity: 0.42,
overlapResolutionIterations: 1,
compactDrawing: false,
fontSizeLarge: 5,
fontSizeSmall: 3,
padding: 15.0,
experimental: false,
themes: {
dark: {
C: '#fff',
O: '#e74c3c',
N: '#3498db',
F: '#27ae60',
CL: '#16a085',
BR: '#d35400',
I: '#8e44ad',
P: '#d35400',
S: '#f1c40f',
B: '#e67e22',
SI: '#e67e22',
H: '#fff',
BACKGROUND: '#141414'
},
light: {
C: '#222',
O: '#e74c3c',
N: '#3498db',
F: '#27ae60',
CL: '#16a085',
BR: '#d35400',
I: '#8e44ad',
P: '#d35400',
S: '#f1c40f',
B: '#e67e22',
SI: '#e67e22',
H: '#222',
BACKGROUND: '#fff'
}
}
};
// initializing RDKkit Module
onRuntimeInitialized: initRDKitModule().then(function (instance)
{
RDKitModule = instance;
// console.log('version: ' + RDKitModule.version());
// Initialize the drawer to draw to canvas
let smilesDrawer = new SmilesDrawer.Drawer(options);
// input.addEventListener("input", function()
chrome.storage.sync.get(["smi"],function(data)
{
if (data.smi === undefined){
input.value = "";
}else{
input.value = data.smi;
}
// Clean the input (remove unrecognized characters, such as spaces and tabs) and parse it
SmilesDrawer.parse(data.smi, function(tree) {
// Draw to the canvas
smilesDrawer.draw(tree, "example-canvas", "light", false);
// Alternatively, draw to SVG:
// svgDrawer.draw(tree, 'output-svg', 'dark', false);
});
var input_Value,rdkit_mol;
input_Value = String(data.smi); // convert input data in to string
rdkit_mol = RDKitModule.get_mol(input_Value) // creating rdkit molecule
var descriptor_obj = JSON.parse(rdkit_mol.get_descriptors());// storing desriptors
var dataToShow = ["exactmw","tpsa","CrippenClogP","NumAromaticRings","NumHBD","NumHBA"]; // descriptors name to be shown
for(var key in descriptor_obj){
for(var dataShow in dataToShow){
if(String(key) === String(dataToShow[dataShow]))
{
document.getElementById(String(key)).innerText = descriptor_obj[key]
}
}
}
});
input.addEventListener("input",function(e){
console.log(this.value)
// Clean the input (remove unrecognized characters, such as spaces and tabs) and parse it
SmilesDrawer.parse(this.value, function(tree) {
// Draw to the canvas
smilesDrawer.draw(tree, "example-canvas", "light", false);
// Alternatively, draw to SVG:
// svgDrawer.draw(tree, 'output-svg', 'dark', false);
});
var input_Value,rdkit_mol;
input_Value = String(this.value); // convert input data in to string
rdkit_mol = RDKitModule.get_mol(input_Value) // creating rdkit molecule
var descriptor_obj = JSON.parse(rdkit_mol.get_descriptors());// storing desriptors
var dataToShow = ["exactmw","tpsa","CrippenClogP","NumAromaticRings","NumHBD","NumHBA"]; // descriptors name to be shown
for(var key in descriptor_obj){
for(var dataShow in dataToShow){
if(String(key) === String(dataToShow[dataShow]))
{
document.getElementById(String(key)).innerText = descriptor_obj[key]
}
}
}
})
});