hello js
This commit is contained in:
parent
eb92a7c2fd
commit
c863dd4ad3
2 changed files with 21 additions and 14 deletions
|
@ -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>
|
||||
<html lang="en">
|
||||
|
||||
|
@ -13,9 +6,6 @@ $christmas = ($currentDate > $startDate && $currentDate < $endDate);
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="/res/css/master.css">
|
||||
<title>~floppy</title>
|
||||
<?php if ($christmas) { ?>
|
||||
<script type="text/javascript" src="/res/js/snowstorm.js"></script>
|
||||
<?php } ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -30,11 +20,7 @@ $christmas = ($currentDate > $startDate && $currentDate < $endDate);
|
|||
"My life is a living nightmare!"
|
||||
</p>
|
||||
</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>
|
||||
<?php } ?>
|
||||
<div>
|
||||
<ul>
|
||||
<li>19 y/o, British</li>
|
||||
|
@ -62,6 +48,7 @@ $christmas = ($currentDate > $startDate && $currentDate < $endDate);
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="/res/js/dynamic-content.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
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…
Reference in a new issue