This commit is contained in:
floppydiskette 2024-11-17 13:15:57 +00:00
parent eb92a7c2fd
commit c863dd4ad3
Signed by: fwoppydwisk
SSH key fingerprint: SHA256:Hqn452XQ1ETzUt/FthJu6+OFkS4NBxCv5VQSEvuk7CE
2 changed files with 21 additions and 14 deletions

View file

@ -1,10 +1,3 @@
<?php
$currentDate = new DateTime();
$currentYear = $currentDate->format('Y');
$startDate = new DateTime("$currentYear-11-10");
$endDate = new DateTime(($currentYear + 1) . '-03-01');
$christmas = ($currentDate > $startDate && $currentDate < $endDate);
?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
@ -13,9 +6,6 @@ $christmas = ($currentDate > $startDate && $currentDate < $endDate);
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/res/css/master.css"> <link rel="stylesheet" href="/res/css/master.css">
<title>~floppy</title> <title>~floppy</title>
<?php if ($christmas) { ?>
<script type="text/javascript" src="/res/js/snowstorm.js"></script>
<?php } ?>
</head> </head>
<body> <body>
@ -30,11 +20,7 @@ $christmas = ($currentDate > $startDate && $currentDate < $endDate);
"My life is a living nightmare!" "My life is a living nightmare!"
</p> </p>
</div> </div>
<?php if ($christmas) { ?>
<div><img src="/res/images/profile-christmas.jpg" class="profile-image"></div>
<?php } else { ?>
<div><img src="/res/images/profile.png" class="profile-image"></div> <div><img src="/res/images/profile.png" class="profile-image"></div>
<?php } ?>
<div> <div>
<ul> <ul>
<li>19 y/o, British</li> <li>19 y/o, British</li>
@ -62,6 +48,7 @@ $christmas = ($currentDate > $startDate && $currentDate < $endDate);
</div> </div>
</div> </div>
</div> </div>
<script type="text/javascript" src="/res/js/dynamic-content.js"></script>
</body> </body>
</html> </html>

20
res/js/dynamic-content.js Normal file
View 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;
}