Removed the "confirm alert" in the delete costume document function. It made the textarea unklickable

This commit is contained in:
2026-01-20 16:46:32 +01:00
parent dacfa2094c
commit f706dcaf79
2 changed files with 76 additions and 84 deletions
+20 -31
View File
@@ -133,22 +133,7 @@ Listeners for Step 3
*/ */
window.api.getTxtFiles().then(files => {
var menu = document.getElementById('customDocumentTypes');
var l = document.getElementById('customDocumentTypes').options.length - 1;
for (i = l; i >= 0; i--) {
menu.remove(i);
}
files.forEach(file => {
const option = document.createElement('option');
option.value = file;
option.textContent = file
.replace('.txt', '') // Endung entfernen
.replace(/_/g, ' ') // Leerzeichen ersetzen
.replace(/\b\w/g, c => c.toUpperCase()) // ersten Buchstaben groß
menu.appendChild(option);
});
});
//Checkboxlistener so that only one can be selected at a time //Checkboxlistener so that only one can be selected at a time
docFormat.addEventListener("change", (e) => { docFormat.addEventListener("change", (e) => {
@@ -331,6 +316,7 @@ generateBtn.addEventListener("click", () => {
// dokumente löschen // dokumente löschen
deleteBtn.addEventListener("click", () => { deleteBtn.addEventListener("click", () => {
try {
const name = docName.value.trim(); const name = docName.value.trim();
if (!name) { if (!name) {
@@ -340,51 +326,54 @@ deleteBtn.addEventListener("click", () => {
}, 3000); }, 3000);
return; return;
} }
var success = true;
const confirmDelete = confirm(
`Möchtest du das Dokument "${name}" wirklich löschen?`
);
if (!confirmDelete) return;
window.api.deleteTxtFile(name).then((success) => { window.api.deleteTxtFile(name).then((success) => {
if (success) { if (success) {
result.textContent = "Dokument erfolgreich gelöscht!"; result.textContent = "Dokument erfolgreich gelöscht!";
reloadDocuments(); reloadDocuments();
existingDocs.value = "newDoc";
existingDocs.dispatchEvent(new Event("change")); existingDocs.dispatchEvent(new Event("change"));
} else { } else {
result.textContent = "Dokument konnte nicht gelöscht werden."; result.textContent = "Dokument konnte nicht gelöscht werden.";
} }
setTimeout(() => {
result.textContent = "";
}, 3000);
}); });
} catch (error) {
console.log(error)
}
}); });
//function to load existingDoc options to the drop down list //function to load existingDoc options to the drop down list
window.api.getTxtFiles().then(files => { window.api.getTxtFiles().then(files => {
try {
reloadDocuments(); reloadDocuments();
} catch (error) {
console.log(error)
}
}); });
//content anzeigen //content anzeigen
existingDocs.addEventListener("change", async () => { existingDocs.addEventListener("change", async () => {
try {
const existingDocsed = existingDocs.value; const existingDocsed = existingDocs.value;
const exampleText = ""; const exampleText = "";
if (existingDocsed === "newDoc") { if (existingDocsed === "newDoc") {
docNameWrapper.classList.remove("hidden"); docNameWrapper.classList.remove("hidden");
docName.value = ""; docName.value = "";
prompt.value = exampleText; document.getElementById("prompt").value = exampleText;
document.getElementById("prompt").textContent = exampleText;
return; return;
} }
docNameWrapper.classList.add("hidden"); docNameWrapper.classList.add("hidden");
document.getElementById("prompt").textContent = "";
document.getElementById("prompt").value = "";
const content = await window.api.readTxtFile(existingDocsed); const content = await window.api.readTxtFile(existingDocsed);
prompt.value = content; document.getElementById("prompt").value = content;
document.getElementById("prompt").textContent = content; document.getElementById("prompt").textContent = content;
docName.value = existingDocsed.replace(".txt", ""); docName.value = existingDocsed.replace(".txt", "");
} catch (error) {
console.log(error)
}
}); });
+13 -10
View File
@@ -482,10 +482,6 @@ function fileDownload() {
} }
} }
/* /*
Functions for the custom document section Functions for the custom document section
@@ -494,6 +490,7 @@ Functions for the custom document section
//reload drop down //reload drop down
function reloadDocuments() { function reloadDocuments() {
try{
[...existingDocs.querySelectorAll('option:not([value="newDoc"])')] [...existingDocs.querySelectorAll('option:not([value="newDoc"])')]
.forEach(o => o.remove()); .forEach(o => o.remove());
[...customDocumentTypes.querySelectorAll('option:not([value="newDoc"])')] [...customDocumentTypes.querySelectorAll('option:not([value="newDoc"])')]
@@ -501,22 +498,28 @@ function reloadDocuments() {
window.api.getTxtFiles().then(files => { window.api.getTxtFiles().then(files => {
files.forEach(file => { files.forEach(file => {
const option = document.createElement('option'); var option = document.createElement('option');
option.value = file; option.value = file;
option.textContent = file option.textContent = file
.replace('.txt', '') // Endung entfernen .replace('.txt', '') // Endung entfernen
.replace(/_/g, ' ') // Leerzeichen ersetzen .replace(/_/g, ' ') // Leerzeichen ersetzen
.replace(/\b\w/g, c => c.toUpperCase()) // ersten Buchstaben groß .replace(/\b\w/g, c => c.toUpperCase()); // ersten Buchstaben groß
existingDocs.appendChild(option); existingDocs.appendChild(option);
const option2 = document.createElement('option'); var option2 = document.createElement('option');
option.value = file; option2.value = file;
option.textContent = file option2.name = file;
option2.textContent = file
.replace('.txt', '') // Endung entfernen .replace('.txt', '') // Endung entfernen
.replace(/_/g, ' ') // Leerzeichen ersetzen .replace(/_/g, ' ') // Leerzeichen ersetzen
.replace(/\b\w/g, c => c.toUpperCase()) // ersten Buchstaben groß .replace(/\b\w/g, c => c.toUpperCase()); // ersten Buchstaben groß
customDocumentTypes.appendChild(option2); customDocumentTypes.appendChild(option2);
}); });
}); });
}
catch(error){
console.log(error)
}
} }
function sendSpeakerPackages() { function sendSpeakerPackages() {