-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
88 lines (70 loc) · 2.58 KB
/
script.js
File metadata and controls
88 lines (70 loc) · 2.58 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
console.log("Scriptet laddades korrekt!");
document.addEventListener("scroll", function () {
const nav = document.querySelector("nav");
if (window.scrollY > 0) {
nav.classList.add("scrolled");
} else {
nav.classList.remove("scrolled");
}
});
function startCountdown(targetDate) {
const timerElement = document.getElementById("countdown-timer");
function updateCountdown() {
const now = new Date().getTime();
const timeLeft = targetDate - now;
if (timeLeft < 0) {
timerElement.innerHTML = "Countdown Complete!";
clearInterval(interval);
return;
}
const days = Math.floor(timeLeft / (1000 * 60 * 60 * 24));
timerElement.innerHTML = `${days}`;
}
const interval = setInterval(updateCountdown, 1000);
updateCountdown();
}
// Set the target date (YYYY-MM-DD format)
const targetDate = new Date("2025-02-01T23:59:59").getTime();
// Start the countdown
startCountdown(targetDate);
/* Nyhetsbrev */
const submitBtn = document.getElementById("submitBtn");
const emailInput = document.getElementById("emailInput");
const consentCheckbox = document.getElementById("consentCheckbox");
submitBtn.addEventListener("click", (e) => {
e.preventDefault(); // Förhindrar formulärets standardbeteende
if (!consentCheckbox.checked) {
alert("Du måste godkänna användarvillkoren!");
return;
}
emailInput.value = ""; // Rensar fältet efter skickning
submitBtn.style.backgroundColor = "#005a2f"; // Ändrar färgen till en grönare nyans
});
/* Flip card */
const flipCardContainer = document.querySelector(".transition");
const flipped = document.querySelector(".thecard");
flipCardContainer.addEventListener("click", function () {
flipped.classList.toggle("flip");
});
const flipCard = document.querySelector(".transition2");
flipCard.addEventListener("click", function () {
flipped.classList.toggle("flip");
});
// Get the expand button and product card
const expandButton = document.querySelector(".expand");
const productCard = document.querySelector(".products3");
const expandBackButton = document.querySelector(".expand-back");
const additionalContent = document.querySelector(".additional-content");
// Add click event listener to the expand button
expandButton.addEventListener("click", () => {
// Toggle the expanded class
productCard.classList.toggle("expanded");
expandButton.style.opacity = 0;
additionalContent.style.zIndex = 5;
});
expandBackButton.addEventListener("click", () => {
// Toggle the expanded class
productCard.classList.toggle("expanded");
expandButton.style.opacity = 1;
additionalContent.style.zIndex = -5;
});