2024-02-12 22:02:10 -05:00
|
|
|
console.log("hello");
|
2021-01-14 14:40:08 -05:00
|
|
|
|
2022-11-05 18:43:49 -04:00
|
|
|
window.addEventListener("scroll", () => {
|
|
|
|
document.body.style.setProperty("--scroll", window.pageYOffset / (document.body.offsetHeight - window.innerHeight));
|
|
|
|
}, false);
|
2022-11-06 14:57:38 -05:00
|
|
|
|
2024-02-12 22:02:10 -05:00
|
|
|
function changeTheme() {
|
2022-11-06 14:57:38 -05:00
|
|
|
let color = (Math.random() * 0xFFFFFF << 0).toString(16).padStart(6, "0");
|
2023-07-24 16:27:00 -04:00
|
|
|
setThemeColor(`#${color}`);
|
2022-11-06 14:57:38 -05:00
|
|
|
}
|
|
|
|
|
2024-02-12 22:02:10 -05:00
|
|
|
function changeThemeHex() {
|
|
|
|
let hex = prompt("Enter valid hexadecimal code :)");
|
2022-11-06 14:57:38 -05:00
|
|
|
if (hex) {
|
|
|
|
if (hex.charAt(0) != "#") hex = `#${hex}`;
|
|
|
|
if (/^#[0-9A-F]{3}$/i.test(hex) || /^#[0-9A-F]{6}$/i.test(hex) || /^#[0-9A-F]{8}$/i.test(hex)) {
|
2023-07-24 16:27:00 -04:00
|
|
|
setThemeColor(hex);
|
2024-09-16 12:41:52 -04:00
|
|
|
document.querySelector(".hex-code-label").textContent = "Hex code: " + hex;
|
2022-11-06 14:57:38 -05:00
|
|
|
} else alert("Invalid hex code!");
|
|
|
|
}
|
2023-07-24 16:27:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function setThemeColor(color) {
|
|
|
|
document.documentElement.style.setProperty("--theme-color", color);
|
|
|
|
let metaThemeColor = document.querySelector("meta[name=theme-color]");
|
|
|
|
metaThemeColor.setAttribute("content", color);
|
2022-11-06 14:57:38 -05:00
|
|
|
}
|