var birthday = { now: null, day: 25, month: 6, // June match: false, check: function() { this.now = new Date(); if (this.now.getDate() == this.day && this.now.getMonth() + 1 == this.month) this.activate() else this.deactivate() }, activate: function() { document.getElementById('isit').innerHTML = "Yes!" elementClass.remove(document.getElementById('isit'), 'nope') elementClass.add(document.getElementById('isit'), 'yep') confetti.render(); }, deactivate: function() { document.getElementById('isit').innerHTML = "No" elementClass.remove(document.getElementById('isit'), 'yep') elementClass.add(document.getElementById('isit'), 'nope') confetti.clear(); } } var confetti = { displayed: false, confetti: null, target: 'confetti-holder', max: null, size: 1, animate: true, props: ['circle', 'square', 'triangle', 'line'], colors: [[165,104,246], [230,61,135], [0,199,228], [253,214,126]], clock: 25, rotate: true, width: null, height: null, render: function() { this.width = window.innerWidth this.height = window.innerHeight this.max = Math.floor(this.width * this.height / 1799.04) if (this.confetti) this.confetti.clear(); this.confetti = new ConfettiGenerator(this) this.confetti.render(); this.displayed = true; }, clear: function() { if (!this.displayed) return; this.confetti.clear(); this.displayed = false; } } var elementClass = { has: function(e, c) { return !!e.className.match(new RegExp('(\\s|^)' + c + '(\\s|$)')); }, add: function(e, c) { if (!this.has(e,c)) e.className += " " + c; }, remove: function(e, c) { if (this.has(e,c)) { var r = new RegExp('(\\s|^)' + c + '(\\s|$)'); e.className=e.className.replace(r, ' '); } }, } window.onload = function() { birthday.check(); }; window.addEventListener('resize', function() { if (confetti.displayed) confetti.render(); }, false); window.setInterval(function(){ birthday.check(); }, 5000);