|
|
|
@ -1,11 +1,30 @@
|
|
|
|
|
const exportText = document.getElementById("export-text");
|
|
|
|
|
const exportButton = document.getElementById("export-text");
|
|
|
|
|
const imageElement = document.getElementById("background-image");
|
|
|
|
|
|
|
|
|
|
exportText.addEventListener("click", (e) => {
|
|
|
|
|
const checkJSON = document.getElementById("checkJSON");
|
|
|
|
|
const checkTEXT = document.getElementById("checkText");
|
|
|
|
|
|
|
|
|
|
let fileUrl = imageElement.src;
|
|
|
|
|
let fileName = fileUrl.slice(fileUrl.lastIndexOf("/") + 1, fileUrl.length);
|
|
|
|
|
let fileTitle = fileName.slice(0, fileName.indexOf(".")) || "export";
|
|
|
|
|
|
|
|
|
|
console.log(document.getElementById("transcription-panel"));
|
|
|
|
|
|
|
|
|
|
exportButton.addEventListener("click", (e) => {
|
|
|
|
|
if (checkJSON.value) exportJSON();
|
|
|
|
|
if (checkTEXT.value) exportText();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function exportText() {
|
|
|
|
|
let text = document.querySelector("ol").innerText;
|
|
|
|
|
let title = fileName.slice(0, fileName.indexOf(".")) || "export";
|
|
|
|
|
title += ".txt";
|
|
|
|
|
let title = fileTitle + ".txt";
|
|
|
|
|
download(text, title, "text/plain;charset=utf-8");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function exportJSON() {
|
|
|
|
|
let title = fileTitle + ".json";
|
|
|
|
|
download(JSON.stringify(labelsObj), title, "application/json");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// https://stackoverflow.com/questions/13405129/javascript-create-and-save-file
|
|
|
|
|
// Thank you Kanchu!
|
|
|
|
|