mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2024-11-04 05:03:53 +01:00
Cleaning code
This commit is contained in:
parent
c5274db711
commit
3762339745
55
index.html
55
index.html
@ -1,33 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="scripts/getdoiurl.js" type="text/javascript"></script>
|
||||
<head>
|
||||
<script src="scripts/data.js" type="text/javascript"></script>
|
||||
<script>
|
||||
function update_file() {
|
||||
inp=document.getElementById('filename_inp');
|
||||
doilink=document.getElementById('doilink');
|
||||
doilink.setAttribute('href',getdoiurlfromfile(inp.value+'.json'));
|
||||
filelink=document.getElementById('filelink');
|
||||
filelink.setAttribute('href','datas/'+inp.value+'.json');
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
window.onload=function() {
|
||||
var inp = document.getElementById("filename_inp");
|
||||
inp.addEventListener("keydown", function (e) {
|
||||
if (e.keyCode === 13) { //checks whether the pressed key is "Enter"
|
||||
update_file(inp.value);
|
||||
function update_file(filename) {
|
||||
lnk_doi=document.getElementById('lnk_doi');
|
||||
file=filename+'.json'
|
||||
data=getDataFromFile(file)
|
||||
lnk_doi.setAttribute('href',getDoiUrl(data));
|
||||
lnk_file=document.getElementById('lnk_file');
|
||||
lnk_file.setAttribute('href',getFullDataPath(file));
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<label>Write a data file name without extension
|
||||
<input type="text" id='filename_inp'></input>
|
||||
</label>
|
||||
<a target="_blank" id='doilink'>Go to paper</a>
|
||||
<a target="_blank" id='filelink'>Go to file</a>
|
||||
</body>
|
||||
<script>
|
||||
window.onload=function() {
|
||||
var inp = document.getElementById("inp_filename");
|
||||
inp.addEventListener("keydown", function (e) {
|
||||
if (e.keyCode === 13) { //checks whether the pressed key is "Enter"
|
||||
update_file(inp.value);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<label>Write a data file name without extension<br/>
|
||||
<input type="text" id='inp_filename'></input>
|
||||
</label><br/>
|
||||
<a target="_blank" id='lnk_doi'>Go to paper</a>
|
||||
<a target="_blank" id='lnk_file'>Go to file</a>
|
||||
</body>
|
||||
</html>
|
18
scripts/data.js
Normal file
18
scripts/data.js
Normal 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
|
||||
}
|
@ -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))
|
||||
}
|
Loading…
Reference in New Issue
Block a user