document.addEventListener("DOMContentLoaded", allTimer);
function allTimer() {
let timeNY = new Date("Jan 1 2023 00:00:00");
let timeGD = new Date("Mar 8 2023 00:00:00");
let fNY = true;
let fGD = false;
const timerNY = () => {
let now = new Date();
let getLeft = timeNY - now;
const titleNY = "New Year";
const zero = "0";
let days = Math.floor(getLeft / 1000 / 60 / 60 / 24);
let hours = Math.floor(getLeft / 1000 / 60 / 60) % 24;
let minutes = Math.floor(getLeft / 1000 / 60) % 60;
let seconds = Math.floor(getLeft / 1000) % 60;
if (days < 10) days = zero + days;
if (hours < 10) hours = zero + hours;
if (minutes < 10) minutes = zero + minutes;
if (seconds < 10) seconds = zero + seconds;
document.querySelector(".title-big").textContent = titleNY;
document.querySelector(".timer-days__days").innerHTML = days;
document.querySelector(".timer-hours__hours").innerHTML = hours;
document.querySelector(".timer-minutes__minutes").innerHTML = minutes;
document.querySelector(".timer-seconds__seconds").innerHTML = seconds;
if (!fNY) clearInterval(clearNY);
};
timerNY();
const clearNY = setInterval(timerNY, 1000);
const timerGD = () => {
let now = new Date();
let getLeft = timeGD - now;
const titleGD = "Woman's Day";
const zero = "0";
let days = Math.floor(getLeft / 1000 / 60 / 60 / 24);
let hours = Math.floor(getLeft / 1000 / 60 / 60) % 24;
let minutes = Math.floor(getLeft / 1000 / 60) % 60;
let seconds = Math.floor(getLeft / 1000) % 60;
if (days < 10) days = zero + days;
if (hours < 10) hours = zero + hours;
if (minutes < 10) minutes = zero + minutes;
if (seconds < 10) seconds = zero + seconds;
document.querySelector(".title-big").textContent = titleGD;
document.querySelector(".timer-days__days").innerHTML = days;
document.querySelector(".timer-hours__hours").innerHTML = hours;
document.querySelector(".timer-minutes__minutes").innerHTML = minutes;
document.querySelector(".timer-seconds__seconds").innerHTML = seconds;
if (!fGD) clearInterval(clearGD);
};
const clearGD = setInterval(timerGD, 1000);
const switchesTarget = () => {
const switches = document.querySelector(".switches");
switches.addEventListener("click", (event) => {
if (event.target.id == "NY") {
timerNY();
fNY = true;
fGD = false;
console.log(fNY, fGD);
}
if (event.target.id == "GD") {
timerGD();
fNY = false;
fGD = true;
console.log(fNY, fGD);
}
});
};
switchesTarget();
}
export function timerGD() {
let timeGD = new Date("Mar 8 2023 00:00:00");
const timer = () => {
let now = new Date();
let getLeft = timeGD - now;
const titleNY = "Eigth March";
const zero = "0";
let days = Math.floor(getLeft / 1000 / 60 / 60 / 24);
let hours = Math.floor(getLeft / 1000 / 60 / 60) % 24;
let minutes = Math.floor(getLeft / 1000 / 60) % 60;
let seconds = Math.floor(getLeft / 1000) % 60;
if (days < 10) days = zero + days;
if (hours < 10) hours = zero + hours;
if (minutes < 10) minutes = zero + minutes;
if (seconds < 10) seconds = zero + seconds;
document.querySelector(".title-big").textContent = titleNY;
document.querySelector(".timer-days__days").innerHTML = days;
document.querySelector(".timer-hours__hours").innerHTML = hours;
document.querySelector(".timer-minutes__minutes").innerHTML = minutes;
document.querySelector(".timer-seconds__seconds").innerHTML = seconds;
};
timer();
setInterval(timer, 1000);
}
Тут я думаю будет понятней
картинка без тени. Там просто путь до svg иконки
с тенями, но без ссылки на svg, а именно указанно в html
https://codepen.io/Alexxxsander/pen/ExozmML