mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2024-12-25 13:53:48 +01:00
Use search query string instead of hash for file wiewer
This commit is contained in:
parent
0e324735c5
commit
61038a8750
@ -8,6 +8,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<script src="{static}/scripts/getFullDataPath.js" type="text/javascript"></script>
|
<script src="{static}/scripts/getFullDataPath.js" type="text/javascript"></script>
|
||||||
<script src="{static}/scripts/getTextFromFile.js" type="text/javascript"></script>
|
<script src="{static}/scripts/getTextFromFile.js" type="text/javascript"></script>
|
||||||
|
<script src="{static}/scripts/parseQueryStringToDictionary.js" type="text/javascript"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
window.onload=async function(){
|
window.onload=async function(){
|
||||||
@ -25,8 +26,10 @@
|
|||||||
}
|
}
|
||||||
console.warn(mystr);
|
console.warn(mystr);
|
||||||
}
|
}
|
||||||
if(location.hash.length>1){
|
queryDic=parseQueryStringToDictionary()
|
||||||
var filename=location.hash.substr(1);
|
key="dataFile"
|
||||||
|
if(queryDic[key]!=undefined){
|
||||||
|
var filename=queryDic[key];
|
||||||
var path=getFullDataPath(filename);
|
var path=getFullDataPath(filename);
|
||||||
var textPromise=getTextFromFileAsync(path)
|
var textPromise=getTextFromFileAsync(path)
|
||||||
btn_download=document.getElementById("btn_download");
|
btn_download=document.getElementById("btn_download");
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
async function update_file(filename) {
|
async function update_file(filename) {
|
||||||
var file=filename+'.dat';
|
var file=filename+'.dat';
|
||||||
var lnk_file=document.getElementById('lnk_file');
|
var lnk_file=document.getElementById('lnk_file');
|
||||||
lnk_file.setAttribute('href',String.raw`view#${file}`);
|
lnk_file.setAttribute('href',String.raw`view?dataFile=${file}`);
|
||||||
dat= await data.loadAsync(file);
|
dat= await data.loadAsync(file);
|
||||||
await applyData(dat);
|
await applyData(dat);
|
||||||
}
|
}
|
||||||
|
31
content/scripts/parseQueryStringToDictionary.js
Normal file
31
content/scripts/parseQueryStringToDictionary.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
function parseQueryStringToDictionary(queryString=window.location.search) {
|
||||||
|
var dictionary = {};
|
||||||
|
|
||||||
|
// remove the '?' from the beginning of the
|
||||||
|
// if it exists
|
||||||
|
if (queryString.indexOf('?') === 0) {
|
||||||
|
queryString = queryString.substr(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 1: separate out each key/value pair
|
||||||
|
var parts = queryString.split('&');
|
||||||
|
|
||||||
|
for (var i = 0; i < parts.length; i++) {
|
||||||
|
var p = parts[i];
|
||||||
|
// Step 2: Split Key/Value pair
|
||||||
|
var keyValuePair = p.split('=');
|
||||||
|
|
||||||
|
// Step 3: Add Key/Value pair to Dictionary object
|
||||||
|
var key = keyValuePair[0];
|
||||||
|
var value = keyValuePair[1];
|
||||||
|
|
||||||
|
// decode URI encoded string
|
||||||
|
value = decodeURIComponent(value);
|
||||||
|
value = value.replace(/\+/g, ' ');
|
||||||
|
|
||||||
|
dictionary[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 4: Return Dictionary Object
|
||||||
|
return dictionary;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user