131 lines
No EOL
3 KiB
JavaScript
131 lines
No EOL
3 KiB
JavaScript
// Chipsregen
|
|
|
|
console.log("Meine Seite läuft");
|
|
|
|
// Chips erstellen
|
|
function createChip() {
|
|
const chip = document.createElement("img");
|
|
|
|
chip.src = "img/Chips.png"; // ggf. Pfad prüfen
|
|
chip.classList.add("chip");
|
|
|
|
const size = Math.random() * 50 + 50;
|
|
chip.style.width = size + "px";
|
|
|
|
chip.style.left = Math.random() * window.innerWidth + "px";
|
|
|
|
const duration = Math.random() * 3 + 3;
|
|
chip.style.animationDuration = duration + "s";
|
|
|
|
document.body.appendChild(chip);
|
|
|
|
// Entfernen nach Animation (besser als fixe Zeit)
|
|
chip.addEventListener("animationend", () => {
|
|
chip.remove();
|
|
});
|
|
}
|
|
|
|
// Start / Stop Logik (optional aber empfehlenswert)
|
|
const chipInterval = setInterval(createChip, 300);
|
|
|
|
// optional: nach 30 Sekunden stoppen
|
|
setTimeout(() => {
|
|
clearInterval(chipInterval);
|
|
}, 30000);
|
|
|
|
|
|
|
|
|
|
// Notenrechner
|
|
|
|
function berechneNote(prozent) {
|
|
if (prozent >= 90) {
|
|
return "sehr gut";
|
|
} else if (prozent >= 75) {
|
|
return "gut";
|
|
} else if (prozent >= 60) {
|
|
return "befriedigend";
|
|
} else if (prozent >= 50) {
|
|
return "ausreichend";
|
|
} else {
|
|
return "nicht bestanden";
|
|
}
|
|
}
|
|
|
|
function startNotenrechner() {
|
|
|
|
const punkte = Number(
|
|
document.getElementById("punkte").value
|
|
);
|
|
|
|
const max = Number(
|
|
document.getElementById("max").value
|
|
);
|
|
|
|
const ausgabe =
|
|
document.getElementById("ergebnis");
|
|
|
|
if (isNaN(punkte) || isNaN(max) || max <= 0) {
|
|
ausgabe.textContent =
|
|
"Bitte gültige Zahlen eingeben!";
|
|
return;
|
|
}
|
|
|
|
const prozent =
|
|
Math.round((punkte / max) * 100);
|
|
|
|
ausgabe.textContent =
|
|
`${punkte} von ${max} Punkten (${prozent} %) = ${berechneNote(prozent)}`;
|
|
}
|
|
// Light-/Dark-Mode
|
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
const themeButton = document.getElementById("theme-toggle");
|
|
|
|
if (!themeButton) return;
|
|
|
|
const root = document.documentElement;
|
|
|
|
if (localStorage.getItem("theme") === "light") {
|
|
root.classList.add("light-mode");
|
|
themeButton.textContent = "🌙 Dark Mode";
|
|
}
|
|
|
|
themeButton.addEventListener("click", () => {
|
|
root.classList.toggle("light-mode");
|
|
|
|
if (root.classList.contains("light-mode")) {
|
|
localStorage.setItem("theme", "light");
|
|
themeButton.textContent = "🌙 Dark Mode";
|
|
} else {
|
|
localStorage.setItem("theme", "dark");
|
|
themeButton.textContent = "☀️ Light Mode";
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
// Begruessung nach Tageszeit
|
|
const stunde = new Date().getHours();
|
|
let text;
|
|
|
|
if (stunde < 10) {
|
|
text = "Guten Morgen!";
|
|
} else if (stunde < 18) {
|
|
text = "Hallo, schön dass du da bist!";
|
|
} else {
|
|
text = "Guten Abend!";
|
|
}
|
|
|
|
document.getElementById("begruessung").textContent = text;
|
|
|
|
const el = document.getElementById("begruessung");
|
|
el.textContent = text;
|
|
|
|
if (stunde < 10) {
|
|
el.classList.add("morgen");
|
|
} else if (stunde < 18) {
|
|
el.classList.add("tag");
|
|
} else {
|
|
el.classList.add("abend");
|
|
} |