AkademieProjekt3/script.js

145 lines
4.4 KiB
JavaScript
Raw Normal View History

2024-03-22 21:19:38 +00:00
//Nastavení Header menu
const menuIcon = document.querySelector(".menu-icon");
const menuList = document.querySelector("nav");
const hamburgerIcon = document.querySelector(".fa-solid");
menuIcon.addEventListener("click", () => {
if (hamburgerIcon.classList[1] === "fa-bars") {
hamburgerIcon.classList.add("fa-xmark");
hamburgerIcon.classList.remove("fa-bars");
menuList.style.display = "block";
} else {
hamburgerIcon.classList.add("fa-bars");
hamburgerIcon.classList.remove("fa-xmark");
menuList.style.display = "none";
}
});
2024-03-23 18:38:39 +00:00
// Dark Light Mode
const body = document.querySelector("body");
2024-03-28 17:53:22 +00:00
const head = document.querySelector("header");
const links = document.querySelectorAll("a");
2024-03-23 18:38:39 +00:00
const nav = document.querySelector(".navigation");
const h1 = document.querySelector("h1");
2024-03-28 17:53:22 +00:00
const nadpish2 = document.querySelectorAll("h2");
2024-03-23 18:38:39 +00:00
const p = document.querySelector("p");
2024-03-28 17:53:22 +00:00
const solid = document.querySelector(".fa-solid");
const solid1 = document.querySelector(".menu-icon");
const footer = document.querySelector("footer");
2024-03-28 21:29:49 +00:00
const gotop = document.querySelector("#scrollToTopBtn");
const theme = document.querySelector("#toggleButton");
const box = document.querySelectorAll(".code-box");
2024-03-28 17:53:22 +00:00
let isDraculaMode = false;
// Funkce pro nastavení stylů pro Dracula mód
function setDraculaStyles() {
body.style.backgroundColor = "#2a232b"; // Barva pozadí pro Dracula mód
body.style.color = "#f8f8f2"; // Barva textu pro Dracula mód
head.style.backgroundColor = "#2a232b";
links.forEach((a) => {
a.style.color = "#f76b00";
});
nav.style.backgroundColor = "#2a232b";
h1.style.color = "#e54472";
nadpish2.forEach((h2) => {
h2.style.color = "#18f700";
});
solid.style.backgroundColor = "#2a232b";
solid.style.color = "#f76b00";
solid1.style.backgroundColor = "#2a232b";
footer.style.backgroundColor = "#2a232b";
2024-03-28 21:29:49 +00:00
gotop.style.backgroundColor = "#18f700";
theme.style.backgroundColor = "#18f700";
2024-03-28 17:53:22 +00:00
}
2024-03-28 21:29:49 +00:00
// Funkce pro nastavení stylů pro Light mód;
2024-03-28 17:53:22 +00:00
function setLightStyles() {
2024-03-28 21:29:49 +00:00
body.style.backgroundColor = "#e7efa7"; // Barva pozadí pro Light mód
2024-03-28 17:53:22 +00:00
body.style.color = "#282a36"; // Barva textu pro Light mód
2024-03-28 21:29:49 +00:00
head.style.backgroundColor = "#e7efa7";
nav.style.backgroundColor = "#e7efa7";
solid.style.backgroundColor = "#e7efa7";
solid1.style.backgroundColor = "#e7efa7";
footer.style.backgroundColor = "#e7efa7";
nadpish2.forEach((h2) => {
h2.style.color = "#c627d8";
});
gotop.style.backgroundColor = "#a7e6ef";
theme.style.backgroundColor = "#a7e6ef";
box.forEach((p) =>{
p.style.color = "white"
})
2024-03-28 17:53:22 +00:00
}
2024-03-23 23:58:20 +00:00
// Funkce pro přepnutí módu
function toggleMode() {
2024-03-28 17:53:22 +00:00
if (isDraculaMode) {
// Pokud je momentálně v Dracula modu, přepnout na Light mód
setLightStyles();
isDraculaMode = false;
2024-03-23 23:58:20 +00:00
} else {
2024-03-28 17:53:22 +00:00
// Pokud je momentálně v Light modu, přepnout na Dracula mód
setDraculaStyles();
isDraculaMode = true;
2024-03-23 23:58:20 +00:00
}
2024-03-23 18:38:39 +00:00
}
2024-03-23 23:58:20 +00:00
2024-03-28 17:53:22 +00:00
// Při kliknutí na tlačítko spusť funkci pro přepnutí módu
2024-03-23 23:58:20 +00:00
document.getElementById("toggleButton").addEventListener("click", toggleMode);
2024-03-28 17:53:22 +00:00
// Nastavit výchozí styl na Dracula mód po načtení stránky
setDraculaStyles();
isDraculaMode = true;
2024-03-28 19:08:37 +00:00
// Photo Gallery -> section
2024-03-28 21:29:49 +00:00
const image1 = document.querySelector(".picture");
2024-03-28 19:08:37 +00:00
image1.addEventListener("mouseenter", () => {
2024-03-28 21:29:49 +00:00
image1.style.transform = "scale(2.2)";
});
2024-03-28 19:08:37 +00:00
image1.addEventListener("mouseleave", () => {
2024-03-28 21:29:49 +00:00
image1.style.transform = "scale(1)";
});
2024-03-28 19:08:37 +00:00
2024-03-28 21:29:49 +00:00
const image2 = document.querySelector(".picture1");
2024-03-28 19:08:37 +00:00
image2.addEventListener("mouseenter", () => {
2024-03-28 21:29:49 +00:00
image2.style.transform = "scale(2.2)";
});
2024-03-28 19:08:37 +00:00
image2.addEventListener("mouseleave", () => {
2024-03-28 21:29:49 +00:00
image2.style.transform = "scale(1)";
});
2024-03-28 19:08:37 +00:00
2024-03-28 21:29:49 +00:00
const image3 = document.querySelector(".picture2");
2024-03-28 19:08:37 +00:00
image3.addEventListener("mouseenter", () => {
2024-03-28 21:29:49 +00:00
image3.style.transform = "scale(2.2)";
});
2024-03-28 19:08:37 +00:00
image3.addEventListener("mouseleave", () => {
2024-03-28 21:29:49 +00:00
image3.style.transform = "scale(1)";
});
2024-03-28 20:16:26 +00:00
// Tlačítko go to top
// Zobrazit tlačítko, pokud je uživatel dostatečně daleko od horní části stránky
2024-03-28 21:29:49 +00:00
window.onscroll = function () {
scrollFunction();
};
2024-03-28 20:16:26 +00:00
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
document.getElementById("scrollToTopBtn").style.display = "block";
} else {
document.getElementById("scrollToTopBtn").style.display = "none";
}
}
// Posunout nahoru, když uživatel klikne na tlačítko
function scrollToTop() {
document.body.scrollTop = 0; // Pro Safari
document.documentElement.scrollTop = 0; // Pro ostatní prohlížeče
}