Skip to content

Commit

Permalink
Added a option to disable snow effect
Browse files Browse the repository at this point in the history
  • Loading branch information
Wruczek committed Dec 4, 2016
1 parent 283bd9e commit 40813f6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
5 changes: 5 additions & 0 deletions css/christmas-theme.css
Expand Up @@ -9,6 +9,11 @@ body {
background-image: url(../img/christmas-bg.jpg);
}

.disableSnowLink {
position: fixed;
bottom: 0;
}

.panel {
background-color: #410b13;
}
Expand Down
1 change: 1 addition & 0 deletions include/footer.php
Expand Up @@ -54,6 +54,7 @@

<script src="js/script.js"></script>
<script src="js/status.js"></script>

</body>

</html>
Expand Down
47 changes: 44 additions & 3 deletions js/christmas.js
Expand Up @@ -16,6 +16,18 @@ if (new Date().getMonth() === 11) {
document.head.appendChild(script);

window.addEventListener('load', function () {
// Change background artist in the footer
document.getElementById('background-artist').innerHTML = '<a href="http://www.publicdomainpictures.net/view-image.php?image=28562&picture=christmas-bulbs-red-background">Debi Geroux - Public Domain</a>';

if(getCookie('snoweffect') === 'false') {
document.getElementsByTagName('body')[0].innerHTML += '<a class="disableSnowLink" href="#" onclick="enableSnowEffect()">Enable snow effect</a>';
return;
}

// Add a link to disable the effect
document.getElementsByTagName('body')[0].innerHTML += '<a class="disableSnowLink" href="#" onclick="disableSnowEffect()">Disable snow effect</a>';

// Add the snow effect
snowFall.snow(document.body, {
flakeCount: (document.body.clientWidth > 992 ? 500 : 100),
flakeIndex: -1,
Expand All @@ -26,8 +38,37 @@ if (new Date().getMonth() === 11) {
round: true,
shadow: true
});

// Change background artist in the footer
document.getElementById('background-artist').innerHTML = '<a href="http://www.publicdomainpictures.net/view-image.php?image=28562&picture=christmas-bulbs-red-background">Debi Geroux - Public Domain</a>';
});
}

function disableSnowEffect() {
setCookie('snoweffect', 'false', 30);
location.reload();
}

function enableSnowEffect() {
setCookie('snoweffect', 'true', 30);
location.reload();
}

function setCookie(cname,cvalue,exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires=" + d.toGMTString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}

0 comments on commit 40813f6

Please sign in to comment.