mirror of
https://github.com/hnasheralneam/hnasheralneam.github.io.git
synced 2025-06-07 13:54:14 -04:00
Add projects page, move guestbook to new page, add navigation menu, made menu and footer partials
This commit is contained in:
parent
bea621a82d
commit
3f7805278d
27 changed files with 521 additions and 38 deletions
27
scripts/main.js
Normal file
27
scripts/main.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
console.log("hello");
|
||||
|
||||
window.addEventListener("scroll", () => {
|
||||
document.body.style.setProperty("--scroll", window.pageYOffset / (document.body.offsetHeight - window.innerHeight));
|
||||
}, false);
|
||||
|
||||
function changeTheme() {
|
||||
let color = (Math.random() * 0xFFFFFF << 0).toString(16).padStart(6, "0");
|
||||
setThemeColor(`#${color}`);
|
||||
}
|
||||
|
||||
function changeThemeHex() {
|
||||
let hex = prompt("Enter valid hexadecimal 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);
|
||||
document.querySelector(".hex-code-label").textContent = "Hex code: " + 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue