55 lines
1.6 KiB
JavaScript
55 lines
1.6 KiB
JavaScript
/**
|
|
* UGH.im — Bloodlust Edition
|
|
* Minimal interactions: date, theme, music
|
|
*/
|
|
|
|
const CONFIG = {
|
|
musicVolume: 0.4,
|
|
skins: [
|
|
{ bg: "#0a0808", green: "#00cc66", red: "#cc3333" },
|
|
{ bg: "#080a08", green: "#66ff66", red: "#ff4444" },
|
|
{ bg: "#08080a", green: "#6666ff", red: "#ff6666" },
|
|
{ bg: "#0a080a", green: "#cc66cc", red: "#ff66aa" }
|
|
]
|
|
};
|
|
|
|
/* Discordian Date */
|
|
const fetchDiscordianDate = async () => {
|
|
try {
|
|
const r = await fetch("./ddate-now");
|
|
const text = await r.text();
|
|
document.getElementById("ddate").textContent = text.trim();
|
|
} catch {
|
|
document.getElementById("ddate").textContent = "Welcome to UGH.im";
|
|
}
|
|
};
|
|
fetchDiscordianDate();
|
|
|
|
/* Theme / skin changer */
|
|
let skinIndex = 0;
|
|
window.changeTheme = () => {
|
|
skinIndex = (skinIndex + 1) % CONFIG.skins.length;
|
|
const s = CONFIG.skins[skinIndex];
|
|
document.documentElement.style.setProperty("--bl-bg", s.bg);
|
|
document.documentElement.style.setProperty("--bl-green", s.green);
|
|
document.documentElement.style.setProperty("--bl-red", s.red);
|
|
};
|
|
|
|
/* Music */
|
|
const bgMusic = document.getElementById("bg-music");
|
|
let musicOn = false;
|
|
window.toggleMusic = () => {
|
|
const btn = document.querySelector('button[onclick="toggleMusic()"]');
|
|
if (musicOn) {
|
|
bgMusic.pause();
|
|
musicOn = false;
|
|
if (btn) btn.textContent = "[MUSIC]";
|
|
} else {
|
|
bgMusic.volume = CONFIG.musicVolume;
|
|
bgMusic.play()
|
|
.then(() => { musicOn = true; if (btn) btn.textContent = "[STOP]"; })
|
|
.catch(() => { if (btn) btn.textContent = "[MUSIC]"; });
|
|
}
|
|
};
|
|
|