10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-27 06:43:47 +01:00
QUESTDB_website/content/pages/index.html

80 lines
3.0 KiB
HTML

<!DOCTYPE html>
<html>
<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>
<script src="https://cdn.rawgit.com/larsgw/citation.js/archive/citation.js/citation-0.4.0-9.js" type="text/javascript"></script>
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" async>
</script>
<script>
async function update_file(filename) {
var file=filename+'.dat';
var lnk_file=document.getElementById('lnk_file');
lnk_file.setAttribute('href',getFullDataPath(file));
dat= await data.loadAsnyc(file);
await applyData(dat);
}
async function applyData(dat) {
const Cite = require('citation-js');
// Start a async task to get publi
let publitask = Cite.async(dat.doi.string)
const LatexInline=['\\(','\\)']
var par=document.getElementById("data_par")
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);
});
var node = document.createElement("h");
node.innerText= "Excitations";
par.appendChild(node);
dat.excitations.forEach(function(el) {
var node = document.createElement("div");
node.innerHTML= String.raw`${LatexInline[0]} ${el.start.toLaTeX()} \rightarrow ${el.end.toLaTeX()}${LatexInline[1]}, ${LatexInline[0]}${el.Eabs}\:\mathrm{eV}${LatexInline[1]}`;
MathJax.Hub.Queue(["Typeset",MathJax.Hub,node]);
par.appendChild(node);
});
var lnkdoi = document.createElement("a");
// Wait for the value of publi when required
let publi=await publitask;
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);
}
</script>
<script>
function onKeyDown(e) {
if (e.keyCode === 13) { //checks whether the pressed key is "Enter"
update_file(e.target.value);
}
}
</script>
<label>Write a data file name without extension<br/>
<input type="text" id='inp_filename' onkeydown="onKeyDown(e)"></input>
</label><br/>
<p id=data_par></p>
<a target="_blank" id='lnk_file' type='text/plain'>Go to file</a>
</body>
</html>