From c8383c7b819b3c71c79a01e0feeb488254fecb5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20V=C3=A9ril?= Date: Fri, 3 Apr 2020 16:16:08 +0200 Subject: [PATCH 1/2] transform filterParams array to object to simplify code --- content/multipledataset.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/content/multipledataset.html b/content/multipledataset.html index 59cd70be..13a0a5a0 100644 --- a/content/multipledataset.html +++ b/content/multipledataset.html @@ -232,7 +232,7 @@ draft: false for (const exc of d.excitations) { const key2 = JSON.stringify([d.molecule, exc.initial, exc.final, exc.cVertExcitationKind]) const keydic = sdatdic.get(key) - if ((!exc.isUnsafe || window.filterParams[0]) && ((exc.type & window.filterParams[1]) !== 0) && ((exc.VertExcitationKind & window.filterParams[2]) !== 0)) { + if ((!exc.isUnsafe || window.filterParams.unsafe) && ((exc.type & window.filterParams.exType) !== 0) && ((exc.VertExcitationKind & window.filterParams.exVertKind) !== 0)) { if (!(keydic.has(key2))) { keydic.set(key2,exc.value) } @@ -319,7 +319,9 @@ draft: false processingIndicator.isActive = false } async function reloadContent() { - window.filterParams = [$("#cb_unsafe").prop("checked"), Array.from(Array.from($("#cb_exTypeList>li>input[type=checkbox]:checked")).map(el => parseInt(el.value))).reduce((pv, cv) => pv + cv, 0), Array.from(Array.from($("#cb_exVertKindList>li>input[type=checkbox]:checked")).map(el => parseInt(el.value))).reduce((pv, cv) => pv + cv, 0)] + window.filterParams = {unsafe:$("#cb_unsafe").prop("checked"), + exType:Array.from(Array.from($("#cb_exTypeList>li>input[type=checkbox]:checked")).map(el => parseInt(el.value))).reduce((pv, cv) => pv + cv, 0), + exVertKind:Array.from(Array.from($("#cb_exVertKindList>li>input[type=checkbox]:checked")).map(el => parseInt(el.value))).reduce((pv, cv) => pv + cv, 0)} doiCache.clear() processingIndicator.isActive = true const LatexInline = ['\\(', '\\)'] @@ -396,7 +398,7 @@ draft: false const key3 = JSON.stringify(dat.method) for (const ex of dat.excitations) { Reflect.setPrototypeOf(ex.type, excitationType.prototype) - if (((window.filterParams[1] & ex.type) !== 0) && ((window.filterParams[2] & ex.VertExcitationKind) !== 0)) { + if (((window.filterParams.exType & ex.type) !== 0) && ((window.filterParams.exVertKind & ex.VertExcitationKind) !== 0)) { const key2 = JSON.stringify([ex.initial, ex.final, ex.type, ex.VertExcitationKind]) if (!datadic.get(key1).has(key2)) { datadic.get(key1).set(key2, new Map()) @@ -437,7 +439,7 @@ draft: false if (unsafe) { td.append($("", { title: "unsafe value", role: "img", "aria-label": "Warning" }).addClass("emoji").text('⚠')) } - if (unsafe && !$("#cb_unsafe").is(':checked')) { + if (unsafe && !filterParams.unsafe) { td.append($("").append(val.toString())) } else { From e2485a833f62db5dfa3e3e26aee2444cab67ebc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20V=C3=A9ril?= Date: Wed, 8 Apr 2020 11:34:52 +0200 Subject: [PATCH 2/2] Add %T1 filterParams --- content/multipledataset.html | 76 +++++++++++++++++++++++++++++++--- static/js/numberRangeChange.js | 12 ++++++ 2 files changed, 83 insertions(+), 5 deletions(-) create mode 100644 static/js/numberRangeChange.js diff --git a/content/multipledataset.html b/content/multipledataset.html index 13a0a5a0..cbeaef11 100644 --- a/content/multipledataset.html +++ b/content/multipledataset.html @@ -22,6 +22,7 @@ draft: false + @@ -34,7 +35,7 @@ draft: false window.onload = async () => { window.browser = bowser.getParser(window.navigator.userAgent); $("input[type='checkbox']:checked").trigger("change") - + $("input[type='number'].range").trigger("change") adjustSticky(); $(window).resize(adjustSticky) const LatexInline = ['\\(', '\\)'] @@ -229,10 +230,22 @@ draft: false if (!(sdatdic.has(key))) { sdatdic.set(key, new Map()) } + const myT1s=T1ref.get(d.DOI.string).get(d.molecule) for (const exc of d.excitations) { + var allowT1=false + const T1Key=JSON.stringify((exc.initial,exc.final)) + const T1range=filterParams.T1 + if (T1range.min===0 && T1range.max===100) { + allowT1=true + } else if (myT1s.has(T1Key)) { + const T1Val=myT1s.get(T1Key) + if (T1range.min<=T1Val && T1Val<=T1range.max) { + allowT1=true + } + } const key2 = JSON.stringify([d.molecule, exc.initial, exc.final, exc.cVertExcitationKind]) const keydic = sdatdic.get(key) - if ((!exc.isUnsafe || window.filterParams.unsafe) && ((exc.type & window.filterParams.exType) !== 0) && ((exc.VertExcitationKind & window.filterParams.exVertKind) !== 0)) { + if ((!exc.isUnsafe || window.filterParams.unsafe) && ((exc.type & window.filterParams.exType) !== 0) && ((exc.VertExcitationKind & window.filterParams.exVertKind) !== 0) && allowT1) { if (!(keydic.has(key2))) { keydic.set(key2,exc.value) } @@ -321,7 +334,12 @@ draft: false async function reloadContent() { window.filterParams = {unsafe:$("#cb_unsafe").prop("checked"), exType:Array.from(Array.from($("#cb_exTypeList>li>input[type=checkbox]:checked")).map(el => parseInt(el.value))).reduce((pv, cv) => pv + cv, 0), - exVertKind:Array.from(Array.from($("#cb_exVertKindList>li>input[type=checkbox]:checked")).map(el => parseInt(el.value))).reduce((pv, cv) => pv + cv, 0)} + exVertKind:Array.from(Array.from($("#cb_exVertKindList>li>input[type=checkbox]:checked")).map(el => parseInt(el.value))).reduce((pv, cv) => pv + cv, 0), + T1:{ + min:parseFloat($("#T1min").val()), + max:parseFloat($("#T1max").val()) + } + } doiCache.clear() processingIndicator.isActive = true const LatexInline = ['\\(', '\\)'] @@ -337,7 +355,37 @@ draft: false delete (val) }) }) - await window.doiCache.addRange(window.filtData.map((d) => d.DOI.string)) + window.T1ref=new Map() + var dois = new Set(window.filtData.map((d) => d.DOI.string)) + var mols = new Set(window.filtData.map((d) => d.molecule)) + await window.doiCache.addRange(dois) + for (const doi of dois) { + window.T1ref.set(doi,new Map()) + for (const mol of mols) { + window.T1ref.get(doi).set(mol,new Map()) + var TBESortdat=window.dats.filter(d=>d.DOI.string===doi && d.molecule===mol).sort((d1,d2)=>{ + if (d1.method.isTBE && !d2.method.isTBE) { + return -1 + } else if(!d1.method.isTBE && d2.method.isTBE) { + return 1 + } else if (d1.method.isTBE && d2.method.isTBE) { + if (d1.method.name==="TBE(FC)" && d2.method.name==="TBE") { + return -1 + } else if(d1.method.name==="TBE" && d2.method.name==="TBE(FC)") { + return 1 + } + else { + return 0 + } + } + }) + if (TBESortdat.length>0 && TBESortdat[0].method.isTBE) { + for (const exc of TBESortdat[0].excitations) { + window.T1ref.get(doi).get(mol).set(JSON.stringify((exc.initial,exc.final)),exc.T1) + } + } + } + } $(sel_ref).empty() for (const el of uniq(window.filtData.map(d => [d.method, d.DOI.string]))) { op = $("