10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-25 13:53:48 +01:00

Try to implement excitation type filters

This commit is contained in:
Mickaël Véril 2020-01-04 18:07:31 +01:00
parent c72176d808
commit b34b104a06

View File

@ -19,12 +19,13 @@ draft: false
<script src="https://cdn.rawgit.com/larsgw/citation.js/archive/citation.js/citation-0.4.0-9.js" <script src="https://cdn.rawgit.com/larsgw/citation.js/archive/citation.js/citation-0.4.0-9.js"
type="text/javascript"></script> type="text/javascript"></script>
<script src="/js/DOICache.js"></script> <script src="/js/DOICache.js"></script>
<script src="/js/nestedCheckbox.js"></script>
<script src="https://unpkg.com/simple-statistics@7.0.2/dist/simple-statistics.min.js"></script> <script src="https://unpkg.com/simple-statistics@7.0.2/dist/simple-statistics.min.js"></script>
<script> <script>
window.onload = async () => { window.onload = async () => {
const LatexInline = ['\\(', '\\)'] const LatexInline = ['\\(', '\\)']
var al = $("#AllowList") var cbextl = $("#cb_exTypeList")
var ef = $("#excitationFilter") var allc = $("#AllowList:last-child")
for (const [name, value] of excitationTypes.All) { for (const [name, value] of excitationTypes.All) {
var description = null var description = null
switch (Number(value)) { switch (Number(value)) {
@ -45,16 +46,15 @@ draft: false
description = null; description = null;
break; break;
} }
$("<li/>").text(LatexInline[0] + value.LaTeX + LatexInline[1] + (description == null ? '' : ": " + description)).appendTo(al) $("<li/>").text(LatexInline[0] + value.LaTeX + LatexInline[1] + (description == null ? '' : ": " + description)).insertBefore(allc)
$('<label />', { 'for': 'cb_' + name, text: LatexInline[0] + value.LaTeX + LatexInline[1] }).appendTo(ef); var cbli = $("<li/>")
$("<input/>", { type: "checkbox", id: "cb_" + name, name: name, value: Number(value) }).appendTo(ef) $("<input/>", { type: "checkbox", id: "cb_" + name, name: name, value: Number(value) }).change(nestedCheckbox_change).appendTo(cbli);
$('<label />', { 'for': 'cb_' + name, text: LatexInline[0] + value.LaTeX + LatexInline[1] }).appendTo(cbli);
cbextl.append(cbli);
} }
await MathJax.typesetPromise(); await MathJax.typesetPromise();
$("<li/>").text("Unsafe").appendTo(al) delete (cbextl)
$('<label/>', { 'for': 'cb_unsafe', text: "Unsafe" }).appendTo(ef); delete (allc)
$("<input/>", { type: "checkbox", id: "cb_unsafe", name: "unsafe" }).appendTo(ef)
delete (al)
delete (ef)
window.doiCache = new DOICache() window.doiCache = new DOICache()
$('#form_dat > fieldset > input[type=radio]').on('change', async function (event) { $('#form_dat > fieldset > input[type=radio]').on('change', async function (event) {
processingIndicator.isActive = true processingIndicator.isActive = true
@ -139,7 +139,7 @@ draft: false
$(stb).empty() $(stb).empty()
var refstr = $("#sel_ref option:selected").val() var refstr = $("#sel_ref option:selected").val()
var sdatdic = new Map() var sdatdic = new Map()
for (const d of window.filt) { for (const d of window.filtData) {
const key = JSON.stringify([d.code, d.method, d.DOI]) const key = JSON.stringify([d.code, d.method, d.DOI])
if (!(sdatdic.has(key))) { if (!(sdatdic.has(key))) {
sdatdic.set(key, new Map()) sdatdic.set(key, new Map())
@ -236,22 +236,23 @@ draft: false
processingIndicator.isActive = false processingIndicator.isActive = false
} }
async function reloadContent() { async function reloadContent() {
window.filterParams = ($("#cb_unsafe").prop("checked"), Array.from($("#cb_exTypeList>li>input[type=checkbox:checked]").map(el => el.value).reduce((pv, cv) => pv + cv, 0)))
doiCache.clear() doiCache.clear()
processingIndicator.isActive = true processingIndicator.isActive = true
const LatexInline = ['\\(', '\\)'] const LatexInline = ['\\(', '\\)']
window.filt = window.dats window.filtData = window.dats
$('#form_dat > fieldset > div > select').each(function () { $('#form_dat > fieldset > div > select').each(function () {
const prop = $(this).attr("name") const prop = $(this).attr("name")
const values = $(this).val() const values = $(this).val()
window.filt = window.filt.filter((d) => { window.filtData = window.filtData.filter((d) => {
if (typeof values == "undefined" || values == null) { if (typeof values == "undefined" || values == null) {
return false return false
} }
return values.includes(JSON.stringify(d[prop])) return values.includes(JSON.stringify(d[prop]))
}) })
}) })
await window.doiCache.addRange(window.filt.map((d) => d.DOI.string)) await window.doiCache.addRange(window.filtData.map((d) => d.DOI.string))
for (const el of uniq(window.filt.map(d => [d.code, d.method, d.DOI]))) { for (const el of uniq(window.filtData.map(d => [d.code, d.method, d.DOI]))) {
op = $("<option/>", { op = $("<option/>", {
value: JSON.stringify(el) value: JSON.stringify(el)
}).text(el[1]) }).text(el[1])
@ -265,10 +266,10 @@ draft: false
$(sel_ref).prop("selectedIndex", 0); $(sel_ref).prop("selectedIndex", 0);
var data = $("#data") var data = $("#data")
$(data).empty(); $(data).empty();
if (window.filt.length > 0) { if (window.filtData.length > 0) {
var sets = await getSets() var sets = await getSets()
for (const doi of doiCache.keys()) { for (const doi of doiCache.keys()) {
paperdata = window.filt.filter((d) => { paperdata = window.filtData.filter((d) => {
return d.DOI.string == doi return d.DOI.string == doi
}) })
var methods = uniq(paperdata.map(d => d.method)) var methods = uniq(paperdata.map(d => d.method))
@ -307,6 +308,7 @@ draft: false
} }
const key3 = JSON.stringify(dat.method) const key3 = JSON.stringify(dat.method)
for (const ex of dat.excitations) { for (const ex of dat.excitations) {
if (window.filterParams[1] & ex.type != 0) {
const key2 = JSON.stringify([ex.initial, ex.final, ex.type]) const key2 = JSON.stringify([ex.initial, ex.final, ex.type])
if (!datadic.get(key1).has(key2)) { if (!datadic.get(key1).has(key2)) {
datadic.get(key1).set(key2, new Map()) datadic.get(key1).set(key2, new Map())
@ -314,6 +316,7 @@ draft: false
datadic.get(key1).get(key2).set(key3, [ex.value, ex.isUnsafe]) datadic.get(key1).get(key2).set(key3, [ex.value, ex.isUnsafe])
} }
} }
}
for (const [molecule, moldat] of datadic.entries()) { for (const [molecule, moldat] of datadic.entries()) {
var printmol = true; var printmol = true;
for (const [jsonex, exdat] of moldat.entries()) { for (const [jsonex, exdat] of moldat.entries()) {
@ -376,6 +379,7 @@ draft: false
<li>Publication</li> <li>Publication</li>
<li>Allow:</li> <li>Allow:</li>
<ul id="AllowList"> <ul id="AllowList">
<li>Unsafe</li>
</ul> </ul>
</ul> </ul>
<li>Select a reference from <strong>already selected data</strong> (by default first is selected -it's the <abbr <li>Select a reference from <strong>already selected data</strong> (by default first is selected -it's the <abbr
@ -414,6 +418,18 @@ draft: false
</div> </div>
</fieldset> </fieldset>
<fieldset id="excitationFilter"> <fieldset id="excitationFilter">
<ul>
<li>
<h1>excitations types</h1>
<input type="checkbox" onchange="nestedCheckbox_change(event)" id="cb_exType_All"></input>
<label for="cb_exType_All"> All</label>
</li>
<ul id="cb_exTypeList">
</ul>
<li id="li_cb_unsafe">
<input type="checkbox" id="cb_unsafe" name="unsafe">
<label for="cb_unsafe">Unsafe</label>
</li>
</fieldset> </fieldset>
<input type="submit" disabled=true value="Load"></input> <input type="submit" disabled=true value="Load"></input>
</form> </form>