From 95fc7df227545e5cc028315b1ad1ccd73eb9fa66 Mon Sep 17 00:00:00 2001 From: Wruczek Date: Fri, 2 Dec 2016 05:32:17 +0100 Subject: [PATCH] Fixed more problems with snowfall not being loaded --- js/christmas.js | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/js/christmas.js b/js/christmas.js index 8c27804..3801814 100644 --- a/js/christmas.js +++ b/js/christmas.js @@ -12,34 +12,22 @@ if (new Date().getMonth() === 11) { // Load and enable the snow var script = document.createElement('script'); - script.src = 'https://cdnjs.cloudflare.com/ajax/libs/JQuery-Snowfall/1.7.4/snowfall.jquery.min.js'; + script.src = 'https://cdnjs.cloudflare.com/ajax/libs/JQuery-Snowfall/1.7.4/snowfall.min.js'; document.head.appendChild(script); - // Wait for the snowfall script and jQuery to load window.addEventListener('load', function () { - defer(proceedWithJquery); + snowFall.snow(document.body, { + flakeCount: (document.body.clientWidth > 992 ? 500 : 100), + flakeIndex: -1, + minSize: 4, + maxSize: 5, + minSpeed: 1, + maxSpeed: 2, + round: true, + shadow: true + }); + + // Change background artist in the footer + document.getElementById('background-artist').innerHTML = 'Debi Geroux - Public Domain'; }); } - -function defer(method) { - if (window.jQuery) - method(); - else - setTimeout(function() { defer(method) }, 50); -} - -function proceedWithJquery() { - $(document).snowfall({ - flakeCount: ($(document).width() > 992 ? 500 : 100), - flakeIndex: -1, - minSize: 4, - maxSize: 5, - minSpeed: 1, - maxSpeed: 2, - round: true, - shadow: true - }); - - // Change background artist in the footer - $('#background-artist').html('Debi Geroux - Public Domain'); -}