2019-09-14 15:05:55 +02:00
|
|
|
---
|
|
|
|
title: "view"
|
|
|
|
date: 2019-08-29 09:00
|
|
|
|
draft: false
|
|
|
|
---
|
2019-10-07 10:23:21 +02:00
|
|
|
<script src="/js/getFullDataPath.js" type="text/javascript"></script>
|
|
|
|
<script src="/js/getTextFromFile.js" type="text/javascript"></script>
|
2019-11-09 17:40:37 +01:00
|
|
|
<script src="/js/downloadData.js" type="text/javascript"></script>
|
|
|
|
<script src="/js/Base64ToBlob.js" type="text/javascript"></script>
|
2019-09-09 15:20:30 +02:00
|
|
|
<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;
|
2019-09-10 14:10:57 +02:00
|
|
|
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);
|
2019-09-09 15:20:30 +02:00
|
|
|
}
|
2019-10-30 13:28:32 +01:00
|
|
|
var params=new URL(window.location.href).searchParams
|
2019-10-30 13:08:45 +01:00
|
|
|
var key=["file","fileBase64"]
|
2019-10-30 13:28:32 +01:00
|
|
|
if(params.has(key[0])){
|
|
|
|
var filename=params.get(key[0]);
|
2019-10-02 19:20:37 +02:00
|
|
|
var textPromise=getTextFromFileUrlAsync(filename)
|
2019-10-30 13:11:35 +01:00
|
|
|
$("#btn_download").click(function(){
|
2019-10-02 19:20:37 +02:00
|
|
|
window.open(filename,"_self");
|
2019-10-30 13:11:35 +01:00
|
|
|
})
|
2019-10-30 13:32:41 +01:00
|
|
|
$('#fileTitle').text(filename);
|
|
|
|
$('#fileContent').text(await textPromise)
|
|
|
|
$('#file').show();
|
|
|
|
$("#div_btn").show();
|
2019-10-30 13:28:32 +01:00
|
|
|
|
|
|
|
} else if(params.has(key[1])){
|
|
|
|
var base64=params.get(key[1]);
|
2019-10-30 13:11:35 +01:00
|
|
|
$("#btn_download").click(function(){
|
2019-11-09 17:40:37 +01:00
|
|
|
const blob=base64ToBlob(base64,"text/plain")
|
|
|
|
downloadData(blob,"file.dat")
|
2019-10-30 13:11:35 +01:00
|
|
|
})
|
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-09-09 15:20:30 +02:00
|
|
|
}
|
2019-10-02 19:20:37 +02:00
|
|
|
else{
|
2019-09-09 15:20:30 +02:00
|
|
|
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>
|
2019-09-09 15:20:30 +02:00
|
|
|
</div>
|
|
|
|
<div id="div_btn" hidden=true>
|
|
|
|
<button id="btn_clip" onclick="Copy()">Copy content</button>
|
|
|
|
<button id='btn_download'>Download</button>
|
2019-09-14 15:05:55 +02:00
|
|
|
</div>
|