10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-25 05:43:46 +01:00

New publis handling with sets which support multiple publications

This commit is contained in:
Mickaël Véril 2020-08-20 15:28:06 +02:00
parent 5904358ecf
commit 62acffa870
6 changed files with 230 additions and 146 deletions

View File

@ -23,6 +23,7 @@ draft: false
<script src="/js/numberRangeChange.js"></script>
<script src="/js/DebugMode.js"></script>
<script src="/js/numberUtils.js"></script>
<script src="/js/PubliDB.js"></script>
<script>
function adjustSticky() {
const height = $("nav").height()
@ -194,31 +195,52 @@ draft: false
selectSelectAll(afters.first())
}
}
function getAllVals(select) {
var baseval = $(select).val()
switch (select.name) {
case "DOI":
vals=baseval.reduce((accumulator,currentValue)=>accumulator.concat(JSON.parse(currentValue)),[])
return vals
break;
default:
return baseval
}
}
async function reloadSelect(name) {
clearSelect(name)
var selects = getAllSelectBefore(name, true)
var currentselect = selects.last()
selects = selects.slice(0, selects.length - 1)
const vals = uniq(window.dats.filter(d => {
var vals = uniq(window.dats.filter(d => {
return Array.from(selects).every((el) => {
return $(el).val().includes(getSelectValue(d, el.name))
return getAllVals(el).includes(getSelectValue(d, el.name))
})
}).map((d) => getSelectValue(d, name)))
const sets = await (async () => {
const publis = await (async () => {
if (name === "DOI") {
const publis = await getPublis()
var sets = publis.sets
sets.set("","Unknow set")
return sets
const publis = await publiDB.loadAsync()
return publis
}
else {
return undefined
}
})()
if (name === "DOI") {
let newvals = []
for (const val of vals) {
for (const set of publis.sets.values()) {
if (set.includes(val)) {
newvals.push(set)
}
}
}
vals = newvals
}
textSelctor = function (value) {
switch (name) {
case "DOI":
return sets.has(value) ? sets.get(value) : value.toString()
setname = publis.findNameFromSet(value, true)
return setname === null ? value.toString() : setname
break;
case "molecule":
const mhchemCE = /^\\ce\{(.*)\}$/
@ -233,17 +255,25 @@ draft: false
return value.toString()
}
}
valueSelector = function (value) {
if (typeof value === 'object') {
return JSON.stringify(value)
}
else {
return value
}
}
for (const val of vals) {
if (val !== null) {
$("<option/>", {
value: val
value: valueSelector(val)
}).text(textSelctor(val)).appendTo(currentselect)
}
}
if (name === "molecule") {
await MathJax.typesetPromise()
}
}
}
function getSelectValue(data, name) {
switch (name) {
case "method":
@ -371,7 +401,7 @@ draft: false
window.filtData = window.dats
getAllSelect().each(function () {
const prop = $(this).attr("name")
const values = $(this).val()
const values = getAllVals(this)
window.filtData = window.filtData.filter((d) => {
if (typeof values == "undefined" || values == null) {
return false
@ -427,8 +457,9 @@ draft: false
var data = $("#data")
$(data).empty();
if (window.filtData.length > 0) {
var sets = (await getPublis()).sets
sets.set("","Unknow set")
var publis = await publiDB.loadAsync()
var PreviousSetName = undefined
var CurrentsetName = undefined
for (const doi of doiCache.keys()) {
paperdata = window.filtData.filter((d) => {
return (d.DOI === null ? "" : d.DOI.string) == doi
@ -454,7 +485,11 @@ draft: false
}
})
var div = $('<div/>').appendTo(data)
$("<h1/>").text(sets.get(doi)).appendTo(div)
CurrentsetName = publis.findSetNameFromDOI(doi, true)
if (PreviousSetName !== CurrentsetName) {
$("<h1/>").text(CurrentsetName).appendTo(div)
}
$("<h2/>").text(doiCache.get(doi).format('data', { format: 'object' })[0].title).appendTo(div)
var table = $("<table/>").addClass("datatable").appendTo(div)
var head = $("<tr/>")
$("<thead/>").addClass("sticky").append(head).appendTo(table)
@ -539,6 +574,7 @@ draft: false
tbody.append(tr)
}
}
PreviousSetName === CurrentsetName
}
await MathJax.typesetPromise()
}
@ -563,6 +599,8 @@ draft: false
async function submitdat() {
if (!DebugMode.Enabled) {
window.onbeforeunload = () => { return ''; }
window.onbeforeunload = () => { return ''; }
window.onbeforeunload = () => { return ''; }
}
await reloadContent();
}
@ -577,7 +615,8 @@ draft: false
</p>
</noscript>
<p>
On this page you can compare multiple dataset and have some statistics to evaluate method accuracy (All fields marked with a red asterisk (<span style="color: red;">*</span>) are mandatory).
On this page you can compare multiple dataset and have some statistics to evaluate method accuracy (All fields marked
with a red asterisk (<span style="color: red;">*</span>) are mandatory).
</p>
<form id="form_dat" action="javascript:submitdat()" method="post">
<fieldset class="main">
@ -626,12 +665,12 @@ draft: false
</div>
</fieldset>
<fieldset>
<legend class="required"
>Vertical excitation kind</legend>
<legend class="required">Vertical excitation kind</legend>
<p>Choose what kind of vertical excitations you want</p>
<ul class="nestedCbList" style="padding-left: 0em;">
<li>
<input type="checkbox" data-onerequired="true" checked onchange="nestedCheckbox_change(event)" id="cb_fileType_All"></input>
<input type="checkbox" data-onerequired="true" checked onchange="nestedCheckbox_change(event)"
id="cb_fileType_All"></input>
<label for="cb_fileType_All"> All</label>
</li>
<ul class="nestedCbList" id="cb_exVertKindList">
@ -651,7 +690,8 @@ draft: false
<p>Choose other excitation parameters you want</p>
<ul class="nestedCbList" style="padding-left: 0em;">
<li>
<input type="checkbox" data-onerequired="true" onchange="nestedCheckbox_change(event)" id="cb_exType_All"></input>
<input type="checkbox" data-onerequired="true" onchange="nestedCheckbox_change(event)"
id="cb_exType_All"></input>
<label for="cb_exType_All"> All</label>
</li>
<ul id="cb_exTypeList" class="nestedCbList">
@ -665,11 +705,11 @@ draft: false
<fieldset>
<legend>\(\mathrm{\%T_1}\)</legend>
<p>Chose the range of \(\mathrm{\%T_1}\) range using the two number box</p>
<input class="range min" airia-label="Minimum value" type="number" id="T1min"
onchange="numberRangeChange(event)" min="0" value="0">
<input class="range min" airia-label="Minimum value" type="number" id="T1min" onchange="numberRangeChange(event)"
min="0" value="0">
<span>\(\leq \mathrm{\%T_1} \leq\)</span>
<input class="range max" airia-label="Maximum value" type="number" id="T1max"
onchange="numberRangeChange(event)" max="100" value="100">
<input class="range max" airia-label="Maximum value" type="number" id="T1max" onchange="numberRangeChange(event)"
max="100" value="100">
</fieldset>
</fieldset>
<input type="submit" value="Load"></input>

View File

@ -15,6 +15,7 @@ draft: false
<script src="/js/numberUtils.js"></script>
<script src="/js/DebugMode.js"></script>
<script src="/js/createPubliUI.js"></script>
<script src="/js/PubliDB.js"></script>
{{< getDataFilesName >}}
<script>
window.onload = async function () {
@ -22,30 +23,37 @@ draft: false
const Cite = require("citation-js")
const sdois = uniq(Object.values(await loadAllData()).flat().filter(d => d.DOI !== null).map(d => d.DOI.string))
const spubliscite = await Cite.async(sdois)
const pubs = await getPublis()
const uospublis = spubliscite.format('data', { format: 'object' })
const spublis = uospublis.sort((puba, pubb) => pubUtils.getIssuedDate(puba) - pubUtils.getIssuedDate(pubb))
var myDB = await publiDB.loadAsync()
for (const publi of spublis) {
art= await createPubliUI(publi,pubs.sets,true,true)
$(art).appendTo("#publis_sets")
var art = await createPubliUI(publi, true, true)
var setName = myDB.findSetNameFromDOI(publi.DOI, true)
setsSec = $('#publis_sets')
var mySetSec = setsSec.find(`section.publiSet[data-setName="${setName}"]`)
if (mySetSec.length === 0) {
mySetSec = $('<section>').addClass('publiSet').attr("data-setName", setName).appendTo(setsSec)
$("<h1>").text(setName).appendTo(mySetSec)
}
const odois=Array.from(pubs.others.keys())
$(art).appendTo(mySetSec)
}
const odois = myDB.others
const opubliscite = await Cite.async(odois)
const uoopublis = opubliscite.format('data', { format: 'object' })
const opublis = uoopublis.sort((puba, pubb) => pubUtils.getIssuedDate(puba) - pubUtils.getIssuedDate(pubb))
for (const publi of opublis) {
art= await createPubliUI(publi,pubs.others,true,true)
art = await createPubliUI(publi, true, true)
$(art).appendTo("#publis_others")
}
}
</script>
<section class="publis-list" id="publis_sets">
<header>
<h2>Sets</h2>
<h1>Sets</h2>
</header>
</section>
<section class="publis" id="publis_others">
<header>
<h2>Others</h2>
<h1>Others</h2>
</header>
</section>

View File

@ -1,7 +1,8 @@
.publi h1 {
font-size: 22pt
.publiSet h1 {
font-size: 22PT;
}
.publi h2 {
.publi h1 {
font-size: 20pt
}

View File

@ -1,7 +1,11 @@
sets:
10.1021/acs.jctc.8b00406 : QUEST#1
10.1021/acs.jctc.8b01205 : QUEST#2
10.1021/acs.jctc.9b01216 : QUEST#3
10.1021/acs.jctc.0c00227 : QUEST#4
QUEST#1:
- 10.1021/acs.jctc.8b00406
QUEST#2:
- 10.1021/acs.jctc.8b01205
QUEST#3:
- 10.1021/acs.jctc.9b01216
QUEST#4:
- 10.1021/acs.jctc.0c00227
others:
10.1021/acs.jpclett.0c00014 :
- 10.1021/acs.jpclett.0c00014

34
static/js/PubliDB.js Normal file
View File

@ -0,0 +1,34 @@
class publiDB {
static async loadAsync() {
var db = new publiDB
const text = await getTextFromFileUrlAsync("/data/publis/index.yaml")
const myYaml = jsyaml.load(text);
db.sets = ((myYaml.sets === null) ? new Map() : new Map(Object.entries(myYaml.sets)));
db.others = ((myYaml.others === null) ? new Map() : new Map(Object.entries(myYaml.others)));
return db
}
static get UnknowSetName() {
return "Unknow set"
}
findNameFromSet(set, supportUnknow = false) {
if (supportUnknow && JSON.stringify(set) === JSON.stringify([""])) {
return publiDB.UnknowSetName
}
for (let [setname, dois] of this.sets.entries()) {
if (JSON.stringify(set.sort()) === JSON.stringify(dois.sort())) {
return setname
}
}
return null
}
findSetNameFromDOI(doi, supportUnknow = false) {
for (let [setname, dois] of this.sets.entries()) {
if (dois.includes(doi))
return setname
}
if (supportUnknow && doi === "") {
return UnknowSetName
}
return null
}
}

View File

@ -2,16 +2,13 @@ function getPubliSubDir(DOI) {
return DOI.split(".").join("/")
}
async function createPubliUI(publi,sets=new Map(),toolTips=false,abstract=false) {
async function createPubliUI(publi,toolTips=false,abstract=false) {
const art = $("<article/>").addClass("publi")
art.className = "publi"
if (sets.has(publi.DOI) && sets.get(publi.DOI)!==null) {
$("<header/>").append($("<h1/>").text(sets.get(publi.DOI))).appendTo(art)
}
$("<a/>", {
href: publi.URL,
target: "_blank"
}).html($("<h2/>").text(publi.title)).appendTo(art)
}).html($("<h1/>").text(publi.title)).appendTo(art)
const authors = publi.author
const ulauthors = $("<ul/>").addClass("authors-list").appendTo(art)
for (const author of authors) {