mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2024-12-25 13:53:48 +01:00
Use select instead of input and add a shortcode to get file list
This commit is contained in:
parent
26b3e27aec
commit
d566394650
@ -11,9 +11,19 @@ draft: false
|
|||||||
<script type="text/javascript" id="MathJax-script" async
|
<script type="text/javascript" id="MathJax-script" async
|
||||||
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js">
|
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js">
|
||||||
</script>
|
</script>
|
||||||
|
{{< getDataFilesName >}}
|
||||||
<script>
|
<script>
|
||||||
async function update_file(filename) {
|
window.onload=function()
|
||||||
var file=filename+'.dat';
|
{
|
||||||
|
fsel=document.getElementById("fileSelect")
|
||||||
|
getDataFilesName().forEach(function(element) {
|
||||||
|
op=document.createElement("option");
|
||||||
|
op.value=element;
|
||||||
|
op.innerText=element.split('.')[0];
|
||||||
|
fsel.appendChild(op);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
async function update_file(file) {
|
||||||
var lnk_file=document.getElementById('lnk_file');
|
var lnk_file=document.getElementById('lnk_file');
|
||||||
lnk_file.setAttribute('href',String.raw`view?dataFile=${file}`);
|
lnk_file.setAttribute('href',String.raw`view?dataFile=${file}`);
|
||||||
dat= await data.loadAsync(file);
|
dat= await data.loadAsync(file);
|
||||||
@ -70,15 +80,15 @@ draft: false
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
function onKeyDown(e) {
|
function onValueChange(e) {
|
||||||
if (e.keyCode === 13) { //checks whether the pressed key is "Enter"
|
|
||||||
update_file(e.target.value);
|
update_file(e.target.value);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<label>Write a data file name without extension<br/>
|
<label>Write a data file name without extension<br/>
|
||||||
<input type="text" id='inp_filename' onkeydown="onKeyDown(event)"></input>
|
<select id="fileSelect" onchange="onValueChange(event)">
|
||||||
|
<option value="" disabled=true selected=true>Select a file</option>
|
||||||
|
</select>
|
||||||
</label><br/>
|
</label><br/>
|
||||||
<h1>Data</h1>
|
<h1>Data</h1>
|
||||||
<p id=data_par></p>
|
<p id=data_par></p>
|
||||||
|
10
layouts/shortcodes/getDataFilesName.html
Normal file
10
layouts/shortcodes/getDataFilesName.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<script>
|
||||||
|
{{- $files := readDir "/static/data" -}}
|
||||||
|
function getDataFilesName(){
|
||||||
|
var files=[]
|
||||||
|
{{- range $files }}
|
||||||
|
files.push({{ .Name }})
|
||||||
|
{{- end }}
|
||||||
|
return files
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
Reference in New Issue
Block a user