Merge branch 'master' of https://git.xpub.nl/kamo/concrete-label
commit
d9067e3553
@ -0,0 +1,31 @@
|
|||||||
|
const exportText = document.getElementById("export-text");
|
||||||
|
|
||||||
|
exportText.addEventListener("click", (e) => {
|
||||||
|
let text = document.querySelector("ol").innerText;
|
||||||
|
let title = fileName.slice(0, fileName.indexOf(".")) || "export";
|
||||||
|
title += ".txt";
|
||||||
|
download(text, title, "text/plain;charset=utf-8");
|
||||||
|
});
|
||||||
|
|
||||||
|
// https://stackoverflow.com/questions/13405129/javascript-create-and-save-file
|
||||||
|
// Thank you Kanchu!
|
||||||
|
// Function to download data to a file
|
||||||
|
function download(data, filename, type) {
|
||||||
|
var file = new Blob([data], { type: type });
|
||||||
|
if (window.navigator.msSaveOrOpenBlob)
|
||||||
|
// IE10+
|
||||||
|
window.navigator.msSaveOrOpenBlob(file, filename);
|
||||||
|
else {
|
||||||
|
// Others
|
||||||
|
var a = document.createElement("a"),
|
||||||
|
url = URL.createObjectURL(file);
|
||||||
|
a.href = url;
|
||||||
|
a.download = filename;
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
setTimeout(function () {
|
||||||
|
document.body.removeChild(a);
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue