mirror of
https://github.com/hnasheralneam/hnasheralneam.github.io.git
synced 2024-11-06 15:45:54 -05:00
8d24b68504
Small text changes, added MAGIC CTF event, page theme color changes with page color.
28 lines
No EOL
990 B
JavaScript
28 lines
No EOL
990 B
JavaScript
console.log("JavaScript Connected!");
|
|
console.log("Nice to see you :)");
|
|
console.log("Have a great day! 💖 Editor Rust");
|
|
|
|
window.addEventListener("scroll", () => {
|
|
document.body.style.setProperty("--scroll", window.pageYOffset / (document.body.offsetHeight - window.innerHeight));
|
|
}, false);
|
|
|
|
function changeThme() {
|
|
let color = (Math.random() * 0xFFFFFF << 0).toString(16).padStart(6, "0");
|
|
setThemeColor(`#${color}`);
|
|
}
|
|
|
|
function changeThmeHex() {
|
|
let hex = prompt("Enter valid hexidecimal code :)");
|
|
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)) {
|
|
setThemeColor(hex);
|
|
} else alert("Invalid hex code!");
|
|
}
|
|
}
|
|
|
|
function setThemeColor(color) {
|
|
document.documentElement.style.setProperty("--theme-color", color);
|
|
let metaThemeColor = document.querySelector("meta[name=theme-color]");
|
|
metaThemeColor.setAttribute("content", color);
|
|
} |