From 6b121d459e418258b11bee58f3899e2ae6cbbce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20V=C3=A9ril?= Date: Wed, 9 Oct 2019 17:53:10 +0200 Subject: [PATCH] Using jquery to build the dynamic UI --- content/multipledataset.html | 125 +++++++++++++++++------------------ content/onedataset.html | 63 +++++++----------- content/papers.html | 77 +++++++++------------ static/css/paper.css | 8 +++ 4 files changed, 123 insertions(+), 150 deletions(-) diff --git a/content/multipledataset.html b/content/multipledataset.html index 3c064d71..c60ffd45 100644 --- a/content/multipledataset.html +++ b/content/multipledataset.html @@ -21,24 +21,25 @@ draft: false window.Cite = require('citation-js'); $('#form_dat input[type=radio]').on('change', async function(event) { processingIndicator.isActive=true - document.getElementById("Geom_th").hidden=true - document.getElementById("GSGeom_th").hidden=true - document.getElementById("ESGeom_th").hidden=true + $("#Geom_th,#GSGeom_th,#ESGeom_th").each(function(){ + $(this).attr("hidden",true) + }) var result = $(this).val(); var proms=[]; switch (result) { case "abs": proms=getAbsFilesName().map((f) => AbsDataFile.loadAsync(f)); - document.getElementById("Geom_th").hidden=false + $("#Geom_th").attr("hidden",false) break; case "fluo": proms=getFluoFilesName().map((f) => FluoDataFile.loadAsync(f)); - document.getElementById("Geom_th").hidden=false + $("#Geom_th").attr("hidden",false) break; case "zpe": proms=getZPEFilesName().map((f) => ZPEDataFile.loadAsync(f)); - document.getElementById("GSGeom_th").hidden=false - document.getElementById("ESGeom_th").hidden=false + $("#GSGeom_th,#ESGeom_th").each(function(){ + $(this).attr("hidden",false) + }) break; } window.dats=await Promise.all(proms) @@ -48,16 +49,14 @@ draft: false }) } function reloadFileSelector(){ - const fsel=document.getElementById("customFiles_input") - fsel.value="" - fsel.disabled=false + $("#customFiles_input").attr("value","").attr("disabled",false) } async function reloadSelect(){ processingIndicator.isActive=true radioval=$('#form_dat > input[name=datatype]:checked').val(); - for(file of Array.from(document.getElementById("customFiles_input").files)) - { + const files=$("#customFiles_input")[0].files + for(file of [...files]) { switch (radioval) { case "abs": var dat=await AbsDataFile.loadAsync(file) @@ -78,11 +77,10 @@ draft: false $(this).find('option[value!=""]').remove() const vals=uniq(window.dats.map((d)=>{return d[$(this).attr("name")]})) for (const val of vals){ - op=document.createElement("option") - op.value=JSON.stringify(val) - op.innerText=val.toString() - $(this).append(op) - } + $("