limepot-xyz/public/scripts/limepot.js
2024-07-27 00:01:47 -06:00

76 lines
2.1 KiB
JavaScript

const value = localStorage.getItem("value");
function onload() {
if (JSON.parse(value) !== true) localStorage.setItem("value", true);
redirect();
sdocument.getElementById("body").style.fontFamily = "system-ui, sans-serif";
}
function redirect() {
let chromium = /Chrome|Chromium|OPR|Opera|Edge|UC|QQ|Brave/.test(
navigator.userAgent,
);
//let disclaimer = `<div class="web-disclaimer">`;
if (chromium && screen.width >= 699 && getAccepted() == 0)
window.location.replace("/bsod");
if (chromium && screen.width <= 699 && getAccepted() == 0)
window.location.replace("/mobile-warn");
}
function toggleTheme() {
// Obtains an array of all <link>
// elements.
// Select your element using indexing.
if (document.getElementById("body").style.fontFamily !== "standardGalactic") {
document.getElementById("body").style.fontFamily = "standardGalactic";
} else {
document.getElementById("body").style.fontFamily = "system-ui, sans-serif";
}
}
// Resizable textarea
const tx = document.getElementsByTagName("textarea");
for (let i = 0; i < tx.length; i++) {
tx[i].setAttribute(
"style",
"height:" + tx[i].scrollHeight + "px;overflow-y:hidden;",
);
tx[i].addEventListener("input", OnInput, false);
}
function OnInput() {
this.style.height = "auto";
this.style.height = this.scrollHeight + "px";
}
// Sound effects
function PlaySound(soundobj) {
var thissound = document.getElementById(soundobj);
thissound.play();
}
function StopSound(soundobj) {
var thissound = document.getElementById(soundobj);
thissound.pause();
thissound.currentTime = 0;
}
const audio = new Audio(
"/assets/sounds/ui/zapsplat_multimedia_button_click_004_68776.mp3",
);
const buttons = document.querySelectorAll("button");
const links = document.querySelectorAll("a");
// biome-ignore lint/complexity/noForEach: <explanation>
links.forEach((a) => {
a.addEventListener("click", () => {
audio.play();
});
});
// biome-ignore lint/complexity/noForEach: <explanation>
buttons.forEach((button) => {
button.addEventListener("click", () => {
audio.play();
});
});