10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-25 22:03:49 +01:00

Cleaning code

This commit is contained in:
Mickaël Véril 2019-08-22 10:34:07 +02:00
parent c5274db711
commit 3762339745
5 changed files with 44 additions and 42 deletions

View File

@ -1,19 +1,20 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<script src="scripts/getdoiurl.js" type="text/javascript"></script> <script src="scripts/data.js" type="text/javascript"></script>
<script> <script>
function update_file() { function update_file(filename) {
inp=document.getElementById('filename_inp'); lnk_doi=document.getElementById('lnk_doi');
doilink=document.getElementById('doilink'); file=filename+'.json'
doilink.setAttribute('href',getdoiurlfromfile(inp.value+'.json')); data=getDataFromFile(file)
filelink=document.getElementById('filelink'); lnk_doi.setAttribute('href',getDoiUrl(data));
filelink.setAttribute('href','datas/'+inp.value+'.json'); lnk_file=document.getElementById('lnk_file');
lnk_file.setAttribute('href',getFullDataPath(file));
} }
</script> </script>
<script> <script>
window.onload=function() { window.onload=function() {
var inp = document.getElementById("filename_inp"); var inp = document.getElementById("inp_filename");
inp.addEventListener("keydown", function (e) { inp.addEventListener("keydown", function (e) {
if (e.keyCode === 13) { //checks whether the pressed key is "Enter" if (e.keyCode === 13) { //checks whether the pressed key is "Enter"
update_file(inp.value); update_file(inp.value);
@ -24,10 +25,10 @@
</script> </script>
</head> </head>
<body> <body>
<label>Write a data file name without extension <label>Write a data file name without extension<br/>
<input type="text" id='filename_inp'></input> <input type="text" id='inp_filename'></input>
</label> </label><br/>
<a target="_blank" id='doilink'>Go to paper</a> <a target="_blank" id='lnk_doi'>Go to paper</a>
<a target="_blank" id='filelink'>Go to file</a> <a target="_blank" id='lnk_file'>Go to file</a>
</body> </body>
</html> </html>

18
scripts/data.js Normal file
View File

@ -0,0 +1,18 @@
function getDataFromFile(file) {
var result = null;
var xmlhttp = new XMLHttpRequest();
xmlhttp
xmlhttp.open("GET",getFullDataPath(file), false);
xmlhttp.send();
if (xmlhttp.status==200) {
text = xmlhttp.responseText;
}
return JSON.parse(text);
}
function getDoiUrl(data) {
return 'https://doi.org/'+data.doi
}
function getFullDataPath(path) {
return 'data/'+path
}

View File

@ -1,17 +0,0 @@
function getjsonfromfile(path) {
var result = null;
var xmlhttp = new XMLHttpRequest();
xmlhttp
xmlhttp.open("GET", path, false);
xmlhttp.send();
if (xmlhttp.status==200) {
text = xmlhttp.responseText;
}
return JSON.parse(text);
}
function getdoiurl(datas) {
return 'https://doi.org/'+datas.doi
}
function getdoiurlfromfile(file) {
return getdoiurl(getjsonfromfile('datas/'+file))
}