eacortes commited on
Commit
cbc0739
·
1 Parent(s): 8d486c1

push new db or demo version

Browse files
Files changed (4) hide show
  1. dump.rdb +1 -1
  2. src/constants.py +1 -1
  3. src/static/main.js +12 -27
  4. src/static/main.min.js +1 -1
dump.rdb CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4ca3d33b2de6c4119d3f100efdb3c0f43431320df29923e22a4112a01a89cccb
3
  size 2454945
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:edb6dac953afd60f97f39ca1a77dfb3cc323e573cbfd6b6ed768d6d637613898
3
  size 2454945
src/constants.py CHANGED
@@ -14,7 +14,7 @@ HNSW_PARAMETERS = {
14
  # Defines the initial capacity of the vector index. It helps in pre-allocating space for the index.
15
  "INITIAL_CAP": 440,
16
  # Max number of outgoing edges (connections) for each node in a graph layer.
17
- "M": 128,
18
  # Max number of connected neighbors to consider during graph building.
19
  # Higher values increase accuracy, but also increase index build time.
20
  "EF_CONSTRUCTION": 4096,
 
14
  # Defines the initial capacity of the vector index. It helps in pre-allocating space for the index.
15
  "INITIAL_CAP": 440,
16
  # Max number of outgoing edges (connections) for each node in a graph layer.
17
+ "M": 256,
18
  # Max number of connected neighbors to consider during graph building.
19
  # Higher values increase accuracy, but also increase index build time.
20
  "EF_CONSTRUCTION": 4096,
src/static/main.js CHANGED
@@ -101,6 +101,9 @@ function handleJSMEStructureChange(event) {
101
  */
102
  function getJsmeGuiScale() {
103
  const width = getJsmeContainerWidthNumber();
 
 
 
104
  let menuScale;
105
  if (width > 460) {
106
  menuScale = 1.3;
@@ -136,10 +139,7 @@ function getJsmeContainerWidthPx() {
136
  */
137
  function getJsmeContainerWidthNumber() {
138
  const container = document.getElementById("jsme_container");
139
- if (!container) {
140
- return null;
141
- }
142
- return container.parentNode.offsetWidth;
143
  }
144
 
145
  // ============================================================================
@@ -154,8 +154,7 @@ function getJsmeContainerWidthNumber() {
154
  function updateGradioTextbox(smiles) {
155
  try {
156
  const textbox = document.querySelector(SMILES_INPUT_SELECTOR);
157
-
158
- if (!textbox || textbox.value === smiles) {
159
  return;
160
  }
161
 
@@ -184,15 +183,11 @@ function updateGradioTextbox(smiles) {
184
  * @param {string} smiles - The SMILES string to display in JSME
185
  */
186
  function updateJSMEFromTextbox(smiles) {
187
- if (!jsmeApplet) {
188
- return;
189
- }
190
-
191
  try {
192
- if (smiles && smiles.trim() !== "") {
193
- jsmeApplet.readGenericMolecularInput(smiles.trim());
194
  } else {
195
- jsmeApplet.reset();
196
  }
197
  lastTextboxValue = smiles;
198
  } catch (error) {
@@ -243,13 +238,9 @@ function handleTextboxPaste(event) {
243
  * Handles window resize events and updates JSME applet width
244
  */
245
  function handleResize() {
246
- if (!jsmeApplet) {
247
- return;
248
- }
249
-
250
  try {
251
- jsmeApplet.setMenuScale(getJsmeGuiScale());
252
- jsmeApplet.setWidth(getJsmeContainerWidthPx());
253
  } catch (error) {
254
  console.error("Error resizing JSME applet:", error);
255
  }
@@ -266,10 +257,7 @@ function handleResize() {
266
  * @public
267
  */
268
  window.setJSMESmiles = function (smiles) {
269
- if (jsmeApplet) {
270
- updateJSMEFromTextbox(smiles);
271
- }
272
-
273
  updateGradioTextbox(smiles);
274
  return smiles;
275
  };
@@ -280,10 +268,7 @@ window.setJSMESmiles = function (smiles) {
280
  * @public
281
  */
282
  window.clearJSME = function () {
283
- if (jsmeApplet) {
284
- jsmeApplet.reset();
285
- }
286
-
287
  updateGradioTextbox("");
288
  return ["", [], [], "Cleared - Draw a new molecule or enter SMILES"];
289
  };
 
101
  */
102
  function getJsmeGuiScale() {
103
  const width = getJsmeContainerWidthNumber();
104
+ if (width == null || width <= 0) {
105
+ return 1;
106
+ }
107
  let menuScale;
108
  if (width > 460) {
109
  menuScale = 1.3;
 
139
  */
140
  function getJsmeContainerWidthNumber() {
141
  const container = document.getElementById("jsme_container");
142
+ return container?.parentNode?.offsetWidth;
 
 
 
143
  }
144
 
145
  // ============================================================================
 
154
  function updateGradioTextbox(smiles) {
155
  try {
156
  const textbox = document.querySelector(SMILES_INPUT_SELECTOR);
157
+ if (textbox?.value === smiles) {
 
158
  return;
159
  }
160
 
 
183
  * @param {string} smiles - The SMILES string to display in JSME
184
  */
185
  function updateJSMEFromTextbox(smiles) {
 
 
 
 
186
  try {
187
+ if (smiles?.trim() !== "") {
188
+ jsmeApplet?.readGenericMolecularInput(smiles.trim());
189
  } else {
190
+ jsmeApplet?.reset();
191
  }
192
  lastTextboxValue = smiles;
193
  } catch (error) {
 
238
  * Handles window resize events and updates JSME applet width
239
  */
240
  function handleResize() {
 
 
 
 
241
  try {
242
+ jsmeApplet?.setMenuScale(getJsmeGuiScale());
243
+ jsmeApplet?.setWidth(getJsmeContainerWidthPx());
244
  } catch (error) {
245
  console.error("Error resizing JSME applet:", error);
246
  }
 
257
  * @public
258
  */
259
  window.setJSMESmiles = function (smiles) {
260
+ updateJSMEFromTextbox(smiles);
 
 
 
261
  updateGradioTextbox(smiles);
262
  return smiles;
263
  };
 
268
  * @public
269
  */
270
  window.clearJSME = function () {
271
+ jsmeApplet?.reset();
 
 
 
272
  updateGradioTextbox("");
273
  return ["", [], [], "Cleared - Draw a new molecule or enter SMILES"];
274
  };
src/static/main.min.js CHANGED
@@ -1 +1 @@
1
- function initializeJSME(){try{(jsmeApplet=new JSApplet.JSME("jsme_container",getJsmeContainerWidthPx(),CONTAINER_HEIGHT,{options:"NOcanonize,rButton,zoom,zoomgui,newLook,star,multipart,polarnitro,NOexportInChI,NOexportInChIkey,NOsearchInChIkey,NOexportSVG,NOpaste"})).setCallBack("AfterStructureModified",handleJSMEStructureChange),jsmeApplet.setMenuScale(getJsmeGuiScale()),jsmeApplet.setUserInterfaceBackgroundColor("#adadad"),jsmeApplet.readGenericMolecularInput(DEFAULT_SMILES),lastTextboxValue=DEFAULT_SMILES,setupTextboxEventListeners(),window.addEventListener("resize",handleResize)}catch(e){throw e}}function handleJSMEStructureChange(){try{updateGradioTextbox(jsmeApplet.smiles())}catch(e){}}function getJsmeGuiScale(){const e=getJsmeContainerWidthNumber();return e>460?1.3:e>420?1.1:e>370?1.05:e>300?.88:2}function getJsmeContainerWidthPx(){const e=getJsmeContainerWidthNumber();return null==e||e<=0?"100%":`${e}px`}function getJsmeContainerWidthNumber(){const e=document.getElementById("jsme_container");return e?e.parentNode.offsetWidth:null}function updateGradioTextbox(e){try{const t=document.querySelector(SMILES_INPUT_SELECTOR);if(!t||t.value===e)return;t.value=e,lastTextboxValue=e,GRADIO_CHANGE_EVENTS.forEach(e=>{const n=new Event(e,{bubbles:!0,cancelable:!0});t.dispatchEvent(n)})}catch(e){}}function updateJSMEFromTextbox(e){if(jsmeApplet)try{e&&""!==e.trim()?jsmeApplet.readGenericMolecularInput(e.trim()):jsmeApplet.reset(),lastTextboxValue=e}catch(e){}}function setupTextboxEventListeners(){const e=document.querySelector(SMILES_INPUT_SELECTOR);e&&(e.addEventListener("input",handleTextboxChange),e.addEventListener("change",handleTextboxChange),e.addEventListener("paste",handleTextboxPaste),e.addEventListener("keyup",handleTextboxChange))}function handleTextboxChange(e){e.target.value!==lastTextboxValue&&updateJSMEFromTextbox(e.target.value)}function handleTextboxPaste(e){setTimeout(()=>{updateJSMEFromTextbox(e.target.value)},PASTE_DELAY)}function handleResize(){if(jsmeApplet)try{jsmeApplet.setMenuScale(getJsmeGuiScale()),jsmeApplet.setWidth(getJsmeContainerWidthPx())}catch(e){}}function initializeWhenReady(){"undefined"!=typeof JSApplet&&JSApplet.JSME?initializeJSME():setTimeout(initializeWhenReady,INIT_RETRY_DELAY)}function startInitialization(){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{setTimeout(initializeWhenReady,INIT_RETRY_DELAY)}):setTimeout(initializeWhenReady,INIT_RETRY_DELAY)}let jsmeApplet=null,lastTextboxValue="";const DEFAULT_SMILES="CCO",CONTAINER_HEIGHT="450px",SMILES_INPUT_SELECTOR="#smiles_input textarea, #smiles_input input",PASTE_DELAY=50,INIT_RETRY_DELAY=2e3,GRADIO_CHANGE_EVENTS=["input","change","keyup"];window.setJSMESmiles=function(e){return jsmeApplet&&updateJSMEFromTextbox(e),updateGradioTextbox(e),e},window.clearJSME=function(){return jsmeApplet&&jsmeApplet.reset(),updateGradioTextbox(""),["",[],[],"Cleared - Draw a new molecule or enter SMILES"]},startInitialization();
 
1
+ function initializeJSME(){try{jsmeApplet=new JSApplet.JSME("jsme_container",getJsmeContainerWidthPx(),"450px",{options:"NOcanonize,rButton,zoom,zoomgui,newLook,star,multipart,polarnitro,NOexportInChI,NOexportInChIkey,NOsearchInChIkey,NOexportSVG,NOpaste"}),jsmeApplet.setCallBack("AfterStructureModified",handleJSMEStructureChange),jsmeApplet.setMenuScale(getJsmeGuiScale()),jsmeApplet.setUserInterfaceBackgroundColor("#adadad"),jsmeApplet.readGenericMolecularInput("CCO"),lastTextboxValue="CCO",setupTextboxEventListeners(),window.addEventListener("resize",handleResize)}catch(e){throw e}}function handleJSMEStructureChange(){try{updateGradioTextbox(jsmeApplet.smiles())}catch(e){}}function getJsmeGuiScale(){const e=getJsmeContainerWidthNumber();if(null==e||e<=0)return 1;let t;return t=e>460?1.3:e>420?1.1:e>370?1.05:e>300?.88:2,t}function getJsmeContainerWidthPx(){const e=getJsmeContainerWidthNumber();return null==e||e<=0?"100%":`${e}px`}function getJsmeContainerWidthNumber(){const e=document.getElementById("jsme_container");return e?.parentNode?.offsetWidth}function updateGradioTextbox(e){try{const t=document.querySelector(SMILES_INPUT_SELECTOR);if(t?.value===e)return;t.value=e,lastTextboxValue=e,GRADIO_CHANGE_EVENTS.forEach((e=>{const n=new Event(e,{bubbles:!0,cancelable:!0});t.dispatchEvent(n)}))}catch(e){}}function updateJSMEFromTextbox(e){try{""!==e?.trim()?jsmeApplet?.readGenericMolecularInput(e.trim()):jsmeApplet?.reset(),lastTextboxValue=e}catch(e){}}function setupTextboxEventListeners(){const e=document.querySelector(SMILES_INPUT_SELECTOR);e&&(e.addEventListener("input",handleTextboxChange),e.addEventListener("change",handleTextboxChange),e.addEventListener("paste",handleTextboxPaste),e.addEventListener("keyup",handleTextboxChange))}function handleTextboxChange(e){e.target.value!==lastTextboxValue&&updateJSMEFromTextbox(e.target.value)}function handleTextboxPaste(e){setTimeout((()=>{updateJSMEFromTextbox(e.target.value)}),50)}function handleResize(){try{jsmeApplet?.setMenuScale(getJsmeGuiScale()),jsmeApplet?.setWidth(getJsmeContainerWidthPx())}catch(e){}}function initializeWhenReady(){"undefined"!=typeof JSApplet&&JSApplet.JSME?initializeJSME():setTimeout(initializeWhenReady,2e3)}function startInitialization(){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>{setTimeout(initializeWhenReady,2e3)})):setTimeout(initializeWhenReady,2e3)}let jsmeApplet=null,lastTextboxValue="";const DEFAULT_SMILES="CCO",CONTAINER_HEIGHT="450px",SMILES_INPUT_SELECTOR="#smiles_input textarea, #smiles_input input",PASTE_DELAY=50,INIT_RETRY_DELAY=2e3,GRADIO_CHANGE_EVENTS=["input","change","keyup"];window.setJSMESmiles=function(e){return updateJSMEFromTextbox(e),updateGradioTextbox(e),e},window.clearJSME=function(){return jsmeApplet?.reset(),updateGradioTextbox(""),["",[],[],"Cleared - Draw a new molecule or enter SMILES"]},startInitialization();