diff --git a/electron/main/custom_document.html b/electron/main/custom_document.html
index a12b429..e21971c 100644
--- a/electron/main/custom_document.html
+++ b/electron/main/custom_document.html
@@ -1,5 +1,6 @@
+
Manage document types
@@ -105,8 +110,8 @@
-
-
+
+
@@ -132,29 +137,23 @@
const resultDiv = document.getElementById("result");
const exampleText = "";
-
- // Zurück zur Haupt-GUI
- goBackBtn.addEventListener("click", () => {
- window.electronAPI.goBackToMain();
- });
-
// dokumente speichern
generateBtn.addEventListener("click", () => {
const name = docNameInput.value.trim();
const content = promptInput.value.trim();
- if (!name || !content) {
- resultDiv.textContent = "Bitte Dokumentname und Prompt ausfüllen.";
- setTimeout(() => {
- resultDiv.textContent = "";
- }, 3000);
- return;
- }
- window.api.saveTxtFile(name, content).then();
- resultDiv.textContent = "Dokument erfolgreich gespeichert!";
- setTimeout(() => {
- resultDiv.textContent = "";
- }, 3000);
- reloadDocuments();
+ if (!name || !content) {
+ resultDiv.textContent = "Bitte Dokumentname und Prompt ausfüllen.";
+ setTimeout(() => {
+ resultDiv.textContent = "";
+ }, 3000);
+ return;
+ }
+ window.api.saveTxtFile(name, content).then();
+ resultDiv.textContent = "Dokument erfolgreich gespeichert!";
+ setTimeout(() => {
+ resultDiv.textContent = "";
+ }, 3000);
+ reloadDocuments();
});
@@ -162,49 +161,47 @@
const select = document.getElementById('existingDocs');
window.api.getTxtFiles().then(files => {
- reloadDocuments();
+ reloadDocuments();
});
//content anzeigen
const docNameWrapper = document.getElementById("docNameWrapper");
existingDocs.addEventListener("change", async () => {
- const selected = existingDocs.value;
+ const selected = existingDocs.value;
- if (selected === "newDoc") {
- docNameWrapper.classList.remove("hidden");
- docNameInput.value = "";
- promptInput.value = exampleText;
- return;
- }
- docNameWrapper.classList.add("hidden");
+ if (selected === "newDoc") {
+ docNameWrapper.classList.remove("hidden");
+ docNameInput.value = "";
+ promptInput.value = exampleText;
+ return;
+ }
+ docNameWrapper.classList.add("hidden");
- const content = await window.api.readTxtFile(selected);
- promptInput.value = content;
- docNameInput.value = selected.replace(".txt", "");
+ const content = await window.api.readTxtFile(selected);
+ promptInput.value = content;
+ docNameInput.value = selected.replace(".txt", "");
});
- //reload drop down
- function reloadDocuments() {
- [...existingDocs.querySelectorAll('option:not([value="newDoc"])')]
- .forEach(o => o.remove());
+ //reload drop down
+ function reloadDocuments() {
+ [...existingDocs.querySelectorAll('option:not([value="newDoc"])')]
+ .forEach(o => o.remove());
- window.api.getTxtFiles().then(files => {
- 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ß
- existingDocs.appendChild(option);
+ window.api.getTxtFiles().then(files => {
+ 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ß
+ existingDocs.appendChild(option);
+ });
});
- });
-
-}
-
+ }
-
-
+
+