mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2024-12-24 13:23:40 +01:00
Try to implement excitation type filters
This commit is contained in:
parent
c72176d808
commit
b34b104a06
@ -19,12 +19,13 @@ draft: false
|
||||
<script src="https://cdn.rawgit.com/larsgw/citation.js/archive/citation.js/citation-0.4.0-9.js"
|
||||
type="text/javascript"></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>
|
||||
window.onload = async () => {
|
||||
const LatexInline = ['\\(', '\\)']
|
||||
var al = $("#AllowList")
|
||||
var ef = $("#excitationFilter")
|
||||
var cbextl = $("#cb_exTypeList")
|
||||
var allc = $("#AllowList:last-child")
|
||||
for (const [name, value] of excitationTypes.All) {
|
||||
var description = null
|
||||
switch (Number(value)) {
|
||||
@ -45,16 +46,15 @@ draft: false
|
||||
description = null;
|
||||
break;
|
||||
}
|
||||
$("<li/>").text(LatexInline[0] + value.LaTeX + LatexInline[1] + (description == null ? '' : ": " + description)).appendTo(al)
|
||||
$('<label />', { 'for': 'cb_' + name, text: LatexInline[0] + value.LaTeX + LatexInline[1] }).appendTo(ef);
|
||||
$("<input/>", { type: "checkbox", id: "cb_" + name, name: name, value: Number(value) }).appendTo(ef)
|
||||
$("<li/>").text(LatexInline[0] + value.LaTeX + LatexInline[1] + (description == null ? '' : ": " + description)).insertBefore(allc)
|
||||
var cbli = $("<li/>")
|
||||
$("<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();
|
||||
$("<li/>").text("Unsafe").appendTo(al)
|
||||
$('<label/>', { 'for': 'cb_unsafe', text: "Unsafe" }).appendTo(ef);
|
||||
$("<input/>", { type: "checkbox", id: "cb_unsafe", name: "unsafe" }).appendTo(ef)
|
||||
delete (al)
|
||||
delete (ef)
|
||||
delete (cbextl)
|
||||
delete (allc)
|
||||
window.doiCache = new DOICache()
|
||||
$('#form_dat > fieldset > input[type=radio]').on('change', async function (event) {
|
||||
processingIndicator.isActive = true
|
||||
@ -139,7 +139,7 @@ draft: false
|
||||
$(stb).empty()
|
||||
var refstr = $("#sel_ref option:selected").val()
|
||||
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])
|
||||
if (!(sdatdic.has(key))) {
|
||||
sdatdic.set(key, new Map())
|
||||
@ -236,22 +236,23 @@ draft: false
|
||||
processingIndicator.isActive = false
|
||||
}
|
||||
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()
|
||||
processingIndicator.isActive = true
|
||||
const LatexInline = ['\\(', '\\)']
|
||||
window.filt = window.dats
|
||||
window.filtData = window.dats
|
||||
$('#form_dat > fieldset > div > select').each(function () {
|
||||
const prop = $(this).attr("name")
|
||||
const values = $(this).val()
|
||||
window.filt = window.filt.filter((d) => {
|
||||
window.filtData = window.filtData.filter((d) => {
|
||||
if (typeof values == "undefined" || values == null) {
|
||||
return false
|
||||
}
|
||||
return values.includes(JSON.stringify(d[prop]))
|
||||
})
|
||||
})
|
||||
await window.doiCache.addRange(window.filt.map((d) => d.DOI.string))
|
||||
for (const el of uniq(window.filt.map(d => [d.code, d.method, d.DOI]))) {
|
||||
await window.doiCache.addRange(window.filtData.map((d) => d.DOI.string))
|
||||
for (const el of uniq(window.filtData.map(d => [d.code, d.method, d.DOI]))) {
|
||||
op = $("<option/>", {
|
||||
value: JSON.stringify(el)
|
||||
}).text(el[1])
|
||||
@ -265,10 +266,10 @@ draft: false
|
||||
$(sel_ref).prop("selectedIndex", 0);
|
||||
var data = $("#data")
|
||||
$(data).empty();
|
||||
if (window.filt.length > 0) {
|
||||
if (window.filtData.length > 0) {
|
||||
var sets = await getSets()
|
||||
for (const doi of doiCache.keys()) {
|
||||
paperdata = window.filt.filter((d) => {
|
||||
paperdata = window.filtData.filter((d) => {
|
||||
return d.DOI.string == doi
|
||||
})
|
||||
var methods = uniq(paperdata.map(d => d.method))
|
||||
@ -307,11 +308,13 @@ draft: false
|
||||
}
|
||||
const key3 = JSON.stringify(dat.method)
|
||||
for (const ex of dat.excitations) {
|
||||
const key2 = JSON.stringify([ex.initial, ex.final, ex.type])
|
||||
if (!datadic.get(key1).has(key2)) {
|
||||
datadic.get(key1).set(key2, new Map())
|
||||
if (window.filterParams[1] & ex.type != 0) {
|
||||
const key2 = JSON.stringify([ex.initial, ex.final, ex.type])
|
||||
if (!datadic.get(key1).has(key2)) {
|
||||
datadic.get(key1).set(key2, new Map())
|
||||
}
|
||||
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()) {
|
||||
@ -336,14 +339,14 @@ draft: false
|
||||
return JSON.stringify(method) == x[0]
|
||||
})
|
||||
if (kv !== undefined) {
|
||||
const [val,unsafe]=kv[1]
|
||||
const [val, unsafe] = kv[1]
|
||||
if (unsafe) {
|
||||
td.append($("<div/>",{title:"unsafe value",style:"float: left"}).text('⚠'))
|
||||
td.append($("<div/>", { title: "unsafe value", style: "float: left" }).text('⚠'))
|
||||
}
|
||||
if (unsafe && !$("#cb_unsafe").is(':checked')){
|
||||
if (unsafe && !$("#cb_unsafe").is(':checked')) {
|
||||
td.append($("<s/>").append(val))
|
||||
}
|
||||
else{
|
||||
else {
|
||||
td.append(val)
|
||||
}
|
||||
}
|
||||
@ -376,6 +379,7 @@ draft: false
|
||||
<li>Publication</li>
|
||||
<li>Allow:</li>
|
||||
<ul id="AllowList">
|
||||
<li>Unsafe</li>
|
||||
</ul>
|
||||
</ul>
|
||||
<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>
|
||||
</fieldset>
|
||||
<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>
|
||||
<input type="submit" disabled=true value="Load"></input>
|
||||
</form>
|
||||
|
Loading…
Reference in New Issue
Block a user