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