10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-11-04 21:24:00 +01:00
QUESTDB_website/content/pages/index.html

90 lines
3.3 KiB
HTML
Raw Normal View History

2019-08-21 20:04:29 +02:00
<!DOCTYPE html>
<html>
2019-08-22 10:34:07 +02:00
<head>
<title>Welcome</title>
<meta name="save_as" content="index.html"></meta>
<meta name="date" content="2019-08-29 09:00"></meta>
</head>
<body>
<script src="{static}/scripts/data.js" type="text/javascript"></script>
<script src="{static}/scripts/getFullDataPath.js" type="text/javascript"></script>
2019-08-22 15:23:52 +02:00
<script src="https://cdn.rawgit.com/larsgw/citation.js/archive/citation.js/citation-0.4.0-9.js" type="text/javascript"></script>
2019-09-05 12:59:54 +02:00
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script type="text/javascript" id="MathJax-script" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js">
2019-09-03 15:38:17 +02:00
</script>
2019-08-21 20:04:29 +02:00
<script>
2019-09-05 10:32:46 +02:00
async function update_file(filename) {
2019-09-05 09:34:48 +02:00
var file=filename+'.dat';
var lnk_file=document.getElementById('lnk_file');
2019-08-22 10:34:07 +02:00
lnk_file.setAttribute('href',getFullDataPath(file));
dat= await data.loadAsync(file);
2019-09-05 10:32:46 +02:00
await applyData(dat);
}
2019-09-05 10:32:46 +02:00
async function applyData(dat) {
2019-08-22 15:23:52 +02:00
const Cite = require('citation-js');
2019-09-05 15:26:50 +02:00
// Start an async task to get publi data
let publiPromise = Cite.async(dat.doi.string)
2019-09-05 10:32:46 +02:00
const LatexInline=['\\(','\\)']
var par=document.getElementById("data_par")
2019-09-03 15:38:17 +02:00
par.innerHTML='';
var md=[];
var els=[];
md.push(["Title",dat.title]);
md.push(["Code",dat.code]);
md.push(["Basis",dat.basis]);
md.push(["DOI",dat.doi]);
md.forEach(function(element){
var node = document.createElement("div");
node.innerText= element[0]+': '+element[1];
par.appendChild(node);
});
2019-09-05 15:26:50 +02:00
var exDiv= document.createElement("div");
par.appendChild(exDiv);
var exTitle = document.createElement("h2");
exTitle.innerText= "Excitations";
exDiv.appendChild(exTitle);
var exPar= document.createElement("p");
exDiv.appendChild(exPar);
2019-09-05 12:59:54 +02:00
await dat.excitations.reduce(async (promise,el)=> {
await promise;
2019-09-03 15:38:17 +02:00
var node = document.createElement("div");
2019-09-09 10:32:51 +02:00
node.innerHTML= String.raw`${LatexInline[0]} ${el.start.toLaTeX()} \rightarrow ${el.end.toLaTeX()}${LatexInline[1]}, ${LatexInline[0]}${el.Eabs.toPrecision(3)}\:\mathrm{eV}${LatexInline[1]}`;
node.hidden=true
2019-09-05 15:26:50 +02:00
exPar.appendChild(node);
2019-09-05 12:59:54 +02:00
await MathJax.typesetPromise();
node.hidden=false;
2019-09-03 15:38:17 +02:00
});
2019-09-05 12:59:54 +02:00
2019-09-03 15:38:17 +02:00
var lnkdoi = document.createElement("a");
2019-09-05 10:32:46 +02:00
// Wait for the value of publi when required
let publi=await publiPromise;
2019-09-03 15:38:17 +02:00
let output = publi.format('bibliography', {
format: 'html',
template: 'apa',
lang: 'en-US'
})
lnkdoi.innerHTML=output
lnkdoi.setAttribute('target','_blank');
lnkdoi.setAttribute('href',dat.doi.url);
par.appendChild(lnkdoi);
}
2019-08-21 20:04:29 +02:00
</script>
<script>
2019-09-05 09:34:48 +02:00
function onKeyDown(e) {
if (e.keyCode === 13) { //checks whether the pressed key is "Enter"
update_file(e.target.value);
2019-08-22 10:34:07 +02:00
}
}
2019-08-21 20:04:29 +02:00
</script>
2019-08-22 10:34:07 +02:00
<label>Write a data file name without extension<br/>
<input type="text" id='inp_filename' onkeydown="onKeyDown(event)"></input>
2019-08-22 10:34:07 +02:00
</label><br/>
2019-09-05 15:26:50 +02:00
<h1>Data</h1>
2019-09-03 15:38:17 +02:00
<p id=data_par></p>
<a target="_blank" id='lnk_file' type='text/plain'>Go to file</a>
2019-08-22 10:34:07 +02:00
</body>
</html>