public-html/res/js/dynamic-content.js

21 lines
696 B
JavaScript
Raw Permalink Normal View History

2024-11-17 13:15:57 +00:00
const christmas = isItChristmas();
if (christmas) {
var head = document.getElementsByTagName('head')[0];
var snowJS = document.createElement("script");
snowJS.type = "text/javascript";
2024-11-17 13:18:43 +00:00
snowJS.src = "./res/js/snowstorm.js";
2024-11-17 13:15:57 +00:00
head.appendChild(snowJS);
const profileImage = document.querySelector("img.profile-image");
2024-11-17 13:18:43 +00:00
profileImage.src = "./res/images/profile-christmas.jpg";
2024-11-17 13:15:57 +00:00
}
function isItChristmas() {
const currentDate = new Date();
const currentYear = currentDate.getFullYear();
const startDate = new Date(`${currentYear}-11-10`);
const endDate = new Date(`${currentYear + 1}-03-01`);
return currentDate > startDate && currentDate < endDate;
}