10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-11-09 07:33:52 +01:00
QUESTDB_website/content/view.html

77 lines
2.9 KiB
HTML
Raw Normal View History

---
title: "view"
date: 2019-08-29 09:00
draft: false
---
<script src="/scripts/getFullDataPath.js" type="text/javascript"></script>
<script src="/scripts/getTextFromFile.js" type="text/javascript"></script>
<script src="/scripts/parseQueryStringToDictionary.js" type="text/javascript"></script>
<script>
window.onload=async function(){
if(typeof(navigator.clipboard) == 'undefined' || typeof(navigator.clipboard.writeText) === 'undefined'){
btn_clip=document.getElementById("btn_clip");
btn_clip.disabled = true;
var browsers= {};
browsers["Chromium"]="https://www.mozilla.org/fr/firefox";
browsers["Firefox"]="https://chromium.woolyss.com/download";
var recomsting="We recomend to use Firefox or a Chromium based browser like Google Chrome";
btn_clip.title='This feature is not supported in this bowser\n'+recomsting;
var mystr='navigator.clipboard.writeText() not supported in this browser\n'+recomsting;
for(var key in browsers) {
mystr+="\n"+String.raw`Download ${key} : ${browsers[key]}`;
}
console.warn(mystr);
}
queryDic=parseQueryStringToDictionary()
2019-10-02 19:20:37 +02:00
key=["file","fileBase64"]
if(key[0] in queryDic){
var filename=queryDic[key[0]];
var textPromise=getTextFromFileUrlAsync(filename)
btn_download=document.getElementById("btn_download");
btn_download.onclick=function(){
2019-10-02 19:20:37 +02:00
window.open(filename,"_self");
}
2019-09-10 14:44:08 +02:00
document.getElementById('fileTitle').innerText=filename;
document.getElementById('fileContent').innerText=await textPromise;
document.getElementById('file').hidden=false;
document.getElementById("div_btn").hidden=false;
2019-10-02 19:20:37 +02:00
} else if(key[1] in queryDic){
var base64=queryDic[key[1]];
btn_download=document.getElementById("btn_download");
2019-10-04 09:58:38 +02:00
btn.btn_download.onclick=function(){
window.open(String.raw`data:text/plain;base64,${base64}`,"_self")
2019-10-02 19:20:37 +02:00
}
document.getElementById('fileTitle').hudden=true
document.getElementById('fileContent').innerText=atob(base64)
document.getElementById('file').hidden=false;
document.getElementById("div_btn").hidden=false;
}
2019-10-02 19:20:37 +02:00
else{
document.getElementById('error_P').hidden=false;
errNode;
}
}
</script>
<script>
function Copy()
{
navigator.clipboard.writeText(document.getElementById('fileContent').innerText);
};
</script>
</script>
</script>
<div>
<p id="error_P" style="color: red; font-weight: bold" hidden=true>
Error
</p>
2019-09-10 14:44:08 +02:00
<div id="file" hidden=true>
<h2 id="fileTitle"></h2>
<pre id="fileContent"></pre>
</div>
</div>
<div id="div_btn" hidden=true>
<button id="btn_clip" onclick="Copy()">Copy content</button>
<button id='btn_download'>Download</button>
</div>