From 78fc5dd6737eff96895af8ba4b8ab0469f85d79e Mon Sep 17 00:00:00 2001 From: mveril Date: Fri, 11 Dec 2020 10:44:35 +0100 Subject: [PATCH] Fixes in the loading process (#14) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix broken link * Fix bug in indexDB * Fix sourceFile for each geometry * Use valueOf in ex.type * Fix VertExcitationKind for custom files * Fix excitationType bug when value is set to Single by default * Remove the unnecessary valuOf() * Copy type of excitation from the reference for custom files * Remove sets dependency for %T1 to allow cross set %T1 reference data Co-authored-by: Mickaël Véril --- content/dataset.html | 29 ++++++++++++++++++++--------- static/js/data.js | 2 +- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/content/dataset.html b/content/dataset.html index adbb2a6c..d047c2cc 100644 --- a/content/dataset.html +++ b/content/dataset.html @@ -192,16 +192,28 @@ draft: false } async function reloadCustomFiles() { processingIndicator.isActive = true - window.dats = window.defaultDats; + window.customDats = [] + window.dats = window.defaultDats const kinds = new Map([["file_abs", VertExcitationKinds.Absorbtion], ["file_fluo", VertExcitationKinds.Fluorescence]]) for (const el of $('#form_dat > fieldset > fieldset > div > input[type="file"')) { if (kinds.has(el.name)) { + const kind=kinds.get(el.name) for (const f of el.files) { - const dat = await VertDataFile.loadAsync(f, kinds.get(this.name)) - window.dats.push(dat) + const dat = await VertDataFile.loadAsync(f, kind) + window.customDats.push(dat) } } } + for (const defdat of window.defaultDats) { + if (defdat.method.isTBE) { + for (const custdat of window.customDats) { + if (custdat.molecule===defdat.molecule) { + custdat.CopyExcitationsTypeFrom(defdat) + } + } + } + } + window.dats=window.defaultDats.concat(window.customDats) processingIndicator.isActive = false reloadSizeSelector() reloadSelect("sets") @@ -363,7 +375,7 @@ draft: false if (!(sdatdic.has(key))) { sdatdic.set(key, new Map()) } - const myT1s = T1ref.get(SetName).get(d.molecule) + const myT1s = T1ref.get(d.molecule) for (const exc of d.excitations) { var allowT1 = false const T1Key = JSON.stringify((exc.initial, exc.final)) @@ -504,10 +516,9 @@ draft: false publiCache.set(DOI,await PubliData.loadAsync(DOI)) } const setName = exSet.name - window.T1ref.set(setName, new Map()) for (const mol of mols) { - window.T1ref.get(setName).set(mol, new Map()) - var TBESortdat = window.dats.filter((d)=>exSet.name === d.set.name && d.molecule === mol).sort((d1, d2) => { + window.T1ref.set(mol, new Map()) + var TBESortdat = window.dats.filter((d)=> d.molecule === mol).sort((d1, d2) => { if (d1.method.isTBE && !d2.method.isTBE) { return -1 } else if (!d1.method.isTBE && d2.method.isTBE) { @@ -525,7 +536,7 @@ draft: false }) if (TBESortdat.length > 0 && TBESortdat[0].method.isTBE) { for (const exc of TBESortdat[0].excitations) { - window.T1ref.get(setName).get(mol).set(JSON.stringify((exc.initial, exc.final)), exc.T1) + window.T1ref.get(mol).set(JSON.stringify((exc.initial, exc.final)), exc.T1) } } } @@ -598,7 +609,7 @@ draft: false for (const dat of paperdata) { const setName = dat.set.name const key1 = dat.molecule; - const myT1s = T1ref.get(setName).get(dat.molecule) + const myT1s = T1ref.get(dat.molecule) if (!datadic.has(key1)) { datadic.set(key1, new Map()) } diff --git a/static/js/data.js b/static/js/data.js index 3146c28c..25d82287 100644 --- a/static/js/data.js +++ b/static/js/data.js @@ -203,7 +203,7 @@ class excitationBase { this.type.Value = excitationTypes.Others.Value; } else if (!(this.type & (excitationTypes.Single.Value | excitationTypes.Double.Value))){ - this.type.Value = excitationTypes.Single + this.type.Value += excitationTypes.Single.Value } this.T1 = T1 }