10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-27 06:43:47 +01:00
QUESTDB_website/content/view.html

78 lines
2.5 KiB
HTML
Raw Normal View History

---
title: "view"
date: 2019-08-29 09:00
draft: false
---
2020-01-29 10:56:50 +01:00
<script src="/js/getFullDataPath.js" type="text/javascript"></script>
<script src="/js/getTextFromFile.js" type="text/javascript"></script>
<script src="/js/Base64ToBlob.js" type="text/javascript"></script>
<script>
2020-01-29 10:56:50 +01:00
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://chromium.woolyss.com/download";
browsers["Firefox"] = "https://www.mozilla.org/fr/firefox";
2022-01-18 10:25:50 +01:00
var recomstring = "We recommend to use Firefox or a Chromium based browser like Google Chrome".;
btn_clip.title = 'This feature is not supported in this browser.\n' + recomsting;
2020-01-29 10:56:50 +01:00
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]}`;
}
2020-01-29 10:56:50 +01:00
console.warn(mystr);
}
var params = new URL(window.location.href).searchParams
var key = ["file", "fileBase64"]
if (params.has(key[0])) {
var filename = params.get(key[0]);
2022-01-18 10:25:50 +01:00
var text = await getTextFromFileUrlAsync(filename, {"Cache-Control":"max-age=0"})
2020-01-29 10:56:50 +01:00
$("#btn_download").click(function () {
2020-01-29 11:56:38 +01:00
var b = new Blob([text],{type:"text/plain;charset=utf-8"});
saveAs(b, filename.substring(filename.lastIndexOf('/')+1))
2020-01-29 10:56:50 +01:00
})
$('#fileTitle').text(filename);
2020-01-29 11:56:38 +01:00
$('#fileContent').text(text)
2020-01-29 10:56:50 +01:00
$('#file').show();
$("#div_btn").show();
2020-01-29 10:56:50 +01:00
} else if (params.has(key[1])) {
var base64 = params.get(key[1]);
$("#btn_download").click(function () {
const blob = base64ToBlob(base64, "text/plain")
2020-01-29 11:56:38 +01:00
saveAs(b, "file.dat")
2020-01-29 10:56:50 +01:00
})
$('#fileTitle').hide()
$('#fileContent').text(atob(base64))
$('file').show();
$("div_btn").show()
}
2020-01-29 10:56:50 +01:00
else {
$('#error_P').show()
errNode;
}
}
</script>
<script>
2020-01-29 10:56:50 +01:00
function Copy() {
navigator.clipboard.writeText($('#fileContent').text());
};
</script>
2020-01-29 10:56:50 +01:00
</script>
</script>
<div>
<p id="error_P" style="color: red; font-weight: bold" hidden=true>
Error
</p>
<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>
2020-09-11 14:15:15 +02:00
</div>