2024-04-19 21:02:56 +00:00
|
|
|
const menuIcon = document.querySelector(".menu-icon");
|
|
|
|
const menuList = document.querySelector("nav");
|
|
|
|
const hamburgerIcon = document.querySelector(".fa-solid");
|
|
|
|
|
|
|
|
menuIcon.addEventListener("click", () => {
|
2024-08-26 19:53:00 +00:00
|
|
|
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-04-19 21:02:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Tlačítko go to top
|
|
|
|
// Zobrazení tlačítka od rolovaní části stránky (víc logické než až na konci)
|
|
|
|
window.onscroll = function () {
|
2024-08-26 19:53:00 +00:00
|
|
|
scrollFunction();
|
2024-04-19 21:02:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
function scrollFunction() {
|
2024-08-26 19:53:00 +00:00
|
|
|
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
|
|
|
|
document.getElementById("scrollToTopBtn").style.display = "block";
|
|
|
|
} else {
|
|
|
|
document.getElementById("scrollToTopBtn").style.display = "none";
|
|
|
|
}
|
2024-04-19 21:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Posunout nahoru, když uživatel klikne na tlačítko
|
|
|
|
function scrollToTop() {
|
2024-08-26 19:53:00 +00:00
|
|
|
document.body.scrollTop = 0; // Pro Safari
|
|
|
|
document.documentElement.scrollTop = 0; // Pro ostatní prohlížeče
|
2024-04-19 21:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Code-box
|
|
|
|
document.getElementById("copy-button").addEventListener("click", function () {
|
2024-08-26 19:53:00 +00:00
|
|
|
var codeContent = document.getElementById("code-content");
|
|
|
|
var range = document.createRange();
|
|
|
|
range.selectNode(codeContent);
|
|
|
|
window.getSelection().removeAllRanges();
|
|
|
|
window.getSelection().addRange(range);
|
|
|
|
document.execCommand("copy");
|
|
|
|
window.getSelection().removeAllRanges();
|
2024-04-19 21:02:56 +00:00
|
|
|
});
|