-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
53 lines (45 loc) · 1.86 KB
/
script.js
File metadata and controls
53 lines (45 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
document.getElementById('menuIcon').addEventListener('click', function() {
document.getElementById('navLinks').classList.toggle('active');
});
document.addEventListener("DOMContentLoaded", function () {
const navLinks = document.querySelectorAll(".nav-links a");
const currentPage = window.location.pathname.split("/").pop();
navLinks.forEach(link => {
if (link.getAttribute("href") === currentPage) {
link.classList.add("active");
}
});
});
document.querySelector(".logo").addEventListener("click", function() {
document.body.style.backgroundImage = "url(peter.jpg)"; // Ändra till din bild
document.body.style.backgroundSize = "cover";
document.body.style.backgroundPosition = "center";
});
document.addEventListener("DOMContentLoaded", function() {
let typedText = ""; // Sparar vad användaren skriver
document.addEventListener("keydown", function(event) {
typedText += event.key.toLowerCase(); // Lägger till varje tangenttryck i strängen
if (typedText.includes("peter")) {
showModal(); // Visa modalen när "peter" skrivs
typedText = ""; // Återställ input
}
// Begränsar textlängden så att det inte blir för långt
if (typedText.length > 5) {
typedText = typedText.slice(-5);
}
});
function showModal() {
const modal = document.getElementById("modal");
modal.style.display = "block";
}
document.getElementById("closeModal").addEventListener("click", function() {
document.getElementById("modal").style.display = "none";
});
// Stänger modalen om man klickar utanför
window.addEventListener("click", function(event) {
const modal = document.getElementById("modal");
if (event.target === modal) {
modal.style.display = "none";
}
});
});