hello js
This commit is contained in:
parent
eb92a7c2fd
commit
c863dd4ad3
3 changed files with 74 additions and 67 deletions
20
res/js/dynamic-content.js
Normal file
20
res/js/dynamic-content.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
const christmas = isItChristmas();
|
||||
|
||||
if (christmas) {
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
var snowJS = document.createElement("script");
|
||||
snowJS.type = "text/javascript";
|
||||
snowJS.src = "/res/js/snowstorm.js";
|
||||
head.appendChild(snowJS);
|
||||
|
||||
const profileImage = document.querySelector("img.profile-image");
|
||||
profileImage.src = "/res/images/profile-christmas.jpg";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue