Remove Docker config and fix inline scripts

This commit is contained in:
Bad Manners 2024-03-20 15:01:42 -03:00
parent 324050ee38
commit aba96f95a2
12 changed files with 79 additions and 84 deletions

View file

@ -0,0 +1,35 @@
---
---
<script is:inline>
/* Color scheme toggle */
(() => {
var colorScheme = localStorage.getItem("colorScheme");
if (colorScheme == null || colorScheme === "auto") {
localStorage.setItem("colorScheme", "auto");
colorScheme = matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
}
const bodyClassList = document.querySelector("body").classList;
if (colorScheme === "dark") {
bodyClassList.add("dark");
}
function toggleColorScheme() {
if (colorScheme === "dark") {
colorScheme = "light";
bodyClassList.remove("dark");
} else {
colorScheme = "dark";
bodyClassList.add("dark");
}
localStorage.setItem("colorScheme", colorScheme);
}
const buttonDarkMode = document.querySelector("#button-dark-mode");
if (buttonDarkMode) {
buttonDarkMode.addEventListener("click", toggleColorScheme);
}
})();
</script>

View file

@ -13,7 +13,7 @@
<li>
<a
class="hover:text-green-800 hover:underline focus:text-green-800 focus:underline dark:hover:text-bm-300 dark:focus:text-bm-300"
href="/stories">Stories</a
href="/stories/1">Stories</a
>
</li>
<li>

View file

@ -1,56 +0,0 @@
---
---
<script is:inline>
/* Color scheme toggle */
(() => {
var colorScheme = localStorage.getItem("colorScheme");
if (colorScheme == null) {
localStorage.setItem("colorScheme", "auto");
} else if (colorScheme == "auto") {
colorScheme = matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
}
const bodyClassList = document.querySelector("body").classList;
if (colorScheme === "dark") {
bodyClassList.add("dark");
}
function toggleColorScheme() {
if (colorScheme === "dark") {
colorScheme = "light";
bodyClassList.remove("dark");
} else {
colorScheme = "dark";
bodyClassList.add("dark");
}
localStorage.setItem("colorScheme", colorScheme);
}
const buttonDarkMode = document.querySelector("#button-dark-mode");
if (buttonDarkMode) {
buttonDarkMode.addEventListener("click", toggleColorScheme);
}
})();
/* Age verification */
(() => {
if (window.location.pathname === "/age-verification") {
document.querySelector("#age-verification-reject").addEventListener("click", () => {
window.location.href = "about:blank";
});
document.querySelector("#age-verification-accept").addEventListener("click", () => {
localStorage.setItem("ageVerified", "true");
const params = new URLSearchParams(window.location.search);
window.location.href = decodeURIComponent(params.get("redirect") || "/");
});
} else {
const ageVerified = localStorage.getItem("ageVerified");
if (ageVerified !== "true") {
localStorage.setItem("ageVerified", "false");
window.location.href = `/age-verification?redirect=${encodeURIComponent(window.location.href)}`;
}
}
})();
</script>