improved delete all files

fixed some modal timing issues
changed modal position
testing: disabled copy and text to output field
This commit is contained in:
maru21 2023-10-14 20:42:15 +02:00
parent b7868bc4e5
commit 387d043afd
5 changed files with 34 additions and 10 deletions

View File

@ -301,8 +301,8 @@
</div> </div>
</div> </div>
<div id="modalNotifier" style="display: none" class="w3-modal"> <div id="modalNotifier" style="display: none; padding-top: 200px !important;" class="w3-modal">
<div class="w3-card-4 w3-modal-content w3-margin-top w3-animate-opacity" style="max-width:600px"> <div class="w3-card-4 w3-modal-content w3-margin-top" style="max-width:600px;">
<span <span
onclick="this.parentElement.parentElement.style.display='none'" onclick="this.parentElement.parentElement.style.display='none'"
class="w3-button w3-display-topright w3-flat-clouds" class="w3-button w3-display-topright w3-flat-clouds"

View File

@ -155,7 +155,7 @@ function createTemplate(template = false) {
} }
let data = document.getElementById("templateInput").value; let data = document.getElementById("templateInput").value;
setNewTemplate(fileName, data); setNewTemplate(fileName, data);
modalNotifier(fileName+" saved!", 1); modalNotifier(fileName+" saved!", 2);
e.target.className = e.target.className.replace(" w3-grey", " w3-flat-nephritis"); e.target.className = e.target.className.replace(" w3-grey", " w3-flat-nephritis");
e.target.style.pointerEvents = "none"; e.target.style.pointerEvents = "none";
const timeoutSave = setTimeout(() => { const timeoutSave = setTimeout(() => {

View File

@ -145,7 +145,7 @@ function clickLoadFileDiv(fileName, template) {
if (fileName == "_overflow") return; if (fileName == "_overflow") return;
if (fileName == "_clearAll") { if (fileName == "_clearAll") {
clearAllFiles(); clickClearAllFiles();
return; return;
} }
@ -346,10 +346,33 @@ function getPreviousFile(storageName) {
return (previousFile != undefined) ? previousFile : false; return (previousFile != undefined) ? previousFile : false;
} }
function clickClearAllFiles() {
let modal = document.getElementById("modalMsg");
modal.replaceWith(modal.cloneNode(true));
document.getElementById("modalMsg").addEventListener("click", (e) => {
if (e.target && e.target.tagName === "BUTTON") {
let modal = document.getElementById("modalNotifier");
switch (e.target.innerHTML) {
case "Delete":
clearAllFiles();
modal.replaceWith(modal.cloneNode(true));
modalNotifier("All files deleted!", 2);
break;
default:
e.preventDefault;
}
}
})
modalNotifier(
"<div class='w3-container'> \
<p>Would you really like to delete all stored files?</p> \
<button class='w3-button w3-border w3-flat-pomegranate' >Delete</button>",
0);
}
function clearAllFiles() { function clearAllFiles() {
let tF = JSON.parse(retrieveData("templateFiles")); let tF = JSON.parse(retrieveData("templateFiles"));
if (tF == null || tF.length == 0) { if (tF == null || tF.length == 0) {
modalNotifier("there are no saved texts yet"); modalNotifier("there are no saved texts yet",2);
return; return;
} }
for (let storageName of tF) { for (let storageName of tF) {

View File

@ -225,6 +225,7 @@ function formEvts() {
parseFormOnSubmit(); parseFormOnSubmit();
e.target.className = e.target.className.replace(" w3-grey", " w3-flat-carrot"); e.target.className = e.target.className.replace(" w3-grey", " w3-flat-carrot");
e.target.style.pointerEvents = "none"; e.target.style.pointerEvents = "none";
modalNotifier(activeState.fileName + " copied to clipboard", 2);
const timeoutCopy = setTimeout(() => { const timeoutCopy = setTimeout(() => {
e.target.className = e.target.className.replace(" w3-flat-carrot"," w3-grey"); e.target.className = e.target.className.replace(" w3-flat-carrot"," w3-grey");
e.target.style.pointerEvents = "auto"; e.target.style.pointerEvents = "auto";

View File

@ -144,11 +144,11 @@ function parseFormOnSubmit(returnJSON = false, parseOnly = false) {
return div; return div;
} }
let p = document.createElement("p"); // let p = document.createElement("p");
p.innerHTML = "Copied to Clipboard:"; // p.innerHTML = "Copied to Clipboard:";
document.getElementById("output").innerHTML = ""; // document.getElementById("output").innerHTML = "";
document.getElementById("output").appendChild(p); // document.getElementById("output").appendChild(p);
document.getElementById("output").appendChild(div); // document.getElementById("output").appendChild(div);
storeData("userInput", JSON.stringify(dataArray)); storeData("userInput", JSON.stringify(dataArray));
clearData("userInput"); clearData("userInput");