From 13579440d325063cda51d47ae3ff7c35b0a48bf3 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 9 Jul 2026 13:36:52 +0200 Subject: [PATCH] Unterricht 09.07. --- .idea/codeStyles/codeStyleConfig.xml | 5 ++ .idea/inspectionProfiles/Project_Default.xml | 13 +++ .idea/vcs.xml | 6 ++ Haushaltsplaner/index.html | 31 +++++++ Haushaltsplaner/script.js | 90 ++++++++++++++++++++ Haushaltsplaner/style.css | 21 +++++ Leuchtturm/style.css | 6 +- 7 files changed, 169 insertions(+), 3 deletions(-) create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/vcs.xml create mode 100644 Haushaltsplaner/index.html create mode 100644 Haushaltsplaner/script.js create mode 100644 Haushaltsplaner/style.css diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..e88f045 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..60a1b75 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,13 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Haushaltsplaner/index.html b/Haushaltsplaner/index.html new file mode 100644 index 0000000..0f00013 --- /dev/null +++ b/Haushaltsplaner/index.html @@ -0,0 +1,31 @@ + + + + + + Haushaltsplaner + + + + + +
+

Haushaltsbuch

+
+ + + + +
+ +

Einträge

+ + +

Bilanz

+

0.00 EUR

+
+ + + + + diff --git a/Haushaltsplaner/script.js b/Haushaltsplaner/script.js new file mode 100644 index 0000000..903e235 --- /dev/null +++ b/Haushaltsplaner/script.js @@ -0,0 +1,90 @@ +"use strict"; + +const eintragListe = document.querySelector("#eintragListe"); + +function ladeEintraege() { + const eintraege = JSON.parse(localStorage.getItem('eintraege')) || []; + eintragListe.innerHTML = ''; + + let gesamtEinnahmen = 0; + let gesamtAusgaben = 0; + + eintraege.forEach((eintrag, index) => { + const li = document.createElement('li'); + li.innerHTML = `${eintrag.beschreibung}: ${eintrag.betrag} EUR am ${eintrag.datum}`; + console.log(li); + li.appendChild(erstelleLoeschenButton(index)); + + eintragListe.appendChild(li); + + if (eintrag.betrag >= 0) { + gesamtEinnahmen += parseFloat(eintrag.betrag) + } else { + gesamtAusgaben += parseFloat(eintrag.betrag); + } + }); + + const bilanz = gesamtEinnahmen + gesamtAusgaben; + + document.getElementById('bilanz').textContent = `${bilanz.toFixed(2)}`; +} + +function erstelleLoeschenButton(index) { + const button = document.createElement('button'); + button.textContent = 'Loeschen'; + button.addEventListener('click', ((index) => { + Swal.fire({ + title: "Are you sure?", + text: "You won't be able to revert this!", + icon: "warning", + showCancelButton: true, + confirmButtonColor: "#3085d6", + cancelButtonColor: "#d33", + confirmButtonText: "Yes, delete it!" + }).then((result) => { + if (result.isConfirmed) { + const eintraege = JSON.parse(localStorage.getItem('eintraege')) || []; + console.log(eintraege); + eintraege.splice(index, 1); + console.log(eintraege); + localStorage.setItem('eintraege', JSON.stringify(eintraege)); + ladeEintraege(); + Swal.fire({ + title: "Deleted!", + text: "Your file has been deleted.", + icon: "success" + }); + } + }); + + })); + return button; +} + +function fuegeEintragHinzu() { + const beschreibung = document.getElementById('beschreibung').value; + const betrag = document.getElementById('betrag').value; + const datum = document.getElementById('datum').value; + + if (beschreibung && betrag && datum) { + const eintraege = JSON.parse(localStorage.getItem('eintraege')) || []; + + eintraege.push({'beschreibung': beschreibung, 'betrag': betrag, 'datum': datum}); + + console.log({beschreibung, betrag, datum}); + console.log({'beschreibung': beschreibung, 'betrag': betrag, 'datum': datum}); + + localStorage.setItem('eintraege', JSON.stringify(eintraege)); + + ladeEintraege(); + + document.getElementById('beschreibung').value = ''; + document.getElementById('betrag').value = ''; + document.getElementById('datum').value = ''; + + } else { + Swal.fire("Bitte alle Felder ausfüllen") + } +} + +ladeEintraege(); \ No newline at end of file diff --git a/Haushaltsplaner/style.css b/Haushaltsplaner/style.css new file mode 100644 index 0000000..0e5edcb --- /dev/null +++ b/Haushaltsplaner/style.css @@ -0,0 +1,21 @@ +body { + font-family: 'Verdana', 'Arial', sans-serif; + font-size: 1.2rem; +} + +main { + margin: auto; + width: 90vw; + background-color: ivory; + box-shadow: 2px 2px 10px 2px lightgray; + padding: 1em; +} + +.input-container { + display: flex; + gap: .7em; +} + +.input-container input { + height: 2em; +} \ No newline at end of file diff --git a/Leuchtturm/style.css b/Leuchtturm/style.css index 75fca4f..e624022 100644 --- a/Leuchtturm/style.css +++ b/Leuchtturm/style.css @@ -12,7 +12,7 @@ body { header { margin: 0; text-align: center; - padding: 1rem 0 3rem; + padding: 1rem 0 1.5rem; background: linear-gradient(to top, deepskyblue, ivory); } @@ -25,7 +25,7 @@ main { footer { margin: 0; text-align: center; - padding: 3rem 0 1rem; + padding: 1.5rem 0 1rem; background-color: ivory; } @@ -110,4 +110,4 @@ main section { .right img:hover { transform-origin: top right; } -} \ No newline at end of file +}