diff --git a/devnotes/index.html b/devnotes/index.html index a915b57..0705066 100644 --- a/devnotes/index.html +++ b/devnotes/index.html @@ -3,20 +3,21 @@ Dev Notes | Atom596.com - - - + +

Dev Notes

+ + diff --git a/index.html b/index.html index 3034c67..fd9024d 100644 --- a/index.html +++ b/index.html @@ -3,15 +3,14 @@ Home | Atom596.com - - +

Atom596.com

-
+

New Website Under Construction

@@ -24,5 +23,7 @@

Live GitHub Tracker

Live Modrinth Tracker

+ + diff --git a/script/common.js b/script/common.js new file mode 100644 index 0000000..9b89ccb --- /dev/null +++ b/script/common.js @@ -0,0 +1,46 @@ +window.addEventListener("load", function() { + fetch("/topbar.html") + .then(response => response.text()) + .then((data) => { + document.getElementById("topbar").innerHTML = data + + const toggleButton = document.getElementById("mode-toggle"); + if (toggleButton) { + toggleButton.addEventListener("click", toggleMode); + } + }) +}) + +function getCookie(name) { + const value = `; ${document.cookie}`; + const parts = value.split(`; ${name}=`); + if (parts.length === 2) return parts.pop().split(';').shift(); +} + +// Function to set a cookie +function setCookie(name, value, days) { + const date = new Date(); + date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); + const expires = `expires=${date.toUTCString()}`; + document.cookie = `${name}=${value}; ${expires}; path=/`; +} + +// Function to toggle between light and dark mode +function toggleMode() { + const currentMode = getCookie("theme") || "light"; + const newMode = currentMode === "light" ? "dark" : "light"; + setCookie("theme", newMode, 365); // Save new mode for one year + location.reload(); // Reload page to apply new theme +} + +// Apply the correct CSS based on the theme cookie +function applyTheme() { + const theme = getCookie("theme") || "light"; + const themeCss = document.getElementById('theme-css'); + + console.log(`Applying theme: ${theme}`); + + themeCss.href = "/style/" + theme + ".css"; +} + +applyTheme() diff --git a/script/cookies.js b/script/cookies.js deleted file mode 100644 index 670d8c7..0000000 --- a/script/cookies.js +++ /dev/null @@ -1,18 +0,0 @@ -export function setCookie(cname, cvalue) { - document.cookie = cname + "=" + cvalue + ";path=/" -} - -export function getCookie(cname) { - let name = cname + "="; - let ca = document.cookie.split(';'); - for(let i = 0; i < ca.length; i++) { - let c = ca[i]; - while (c.charAt(0) == ' ') { - c = c.substring(1); - } - if (c.indexOf(name) == 0) { - return c.substring(name.length, c.length); - } - } - return ""; -} diff --git a/script/lightdark.js b/script/lightdark.js deleted file mode 100644 index 262608c..0000000 --- a/script/lightdark.js +++ /dev/null @@ -1,13 +0,0 @@ -import { getCookie, setCookie } from "cookies.js" - -window.addEventListener("load", function() { - if (getCookie("darkmode") == "false") { - document.getElementsByTagName("head")[0].appendChild("/style/light.css") - } - else if (getCookie("darkmore") == "true") { - document.getElementsByTagName("head")[0].appendChild("/style/dark.css") - } - else { - setCookie("darkmode", "true") - } -}) diff --git a/script/topbar.js b/script/topbar.js deleted file mode 100644 index 8f3ce39..0000000 --- a/script/topbar.js +++ /dev/null @@ -1,7 +0,0 @@ -window.addEventListener('load', function() { - fetch("/topbar.html") - .then(response => response.text()) - .then((data) => { - document.getElementById("topbar").innerHTML = data - }) -}) diff --git a/style/dark.css b/style/dark.css index 66abf5a..9891ac7 100644 --- a/style/dark.css +++ b/style/dark.css @@ -1,9 +1,10 @@ h1 { text-align: center; + color:palegoldenrod; } body { - background-image: url("https://www.toptal.com/designers/subtlepatterns/uploads/fancy-cushion.pngflower.png"); + background-image: url("https://www.toptal.com/designers/subtlepatterns/uploads/fancy-cushion.png"); background-repeat: repeat; font-family: Cambria, serif; } \ No newline at end of file diff --git a/style/topbar.css b/style/topbar.css index 4f8be7f..146c91d 100644 --- a/style/topbar.css +++ b/style/topbar.css @@ -9,3 +9,20 @@ margin-top: 10px; margin-bottom: 10px; } + +.dropdown { + position: relative; + display: inline-block; +} +.dropdown-content { + display: none; + position: absolute; + background-color: #f9f9f9; + min-width: 90px; + box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); + padding: 12px 16px; + z-index: 1; +} +.dropdown:hover .dropdown-content { + display: block; +} diff --git a/topbar.html b/topbar.html index adec612..fd41e8d 100644 --- a/topbar.html +++ b/topbar.html @@ -1,7 +1,12 @@