Skip to content

Commit

Permalink
add confetti on anniversary
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Tacla committed Jul 19, 2019
1 parent 2c953d9 commit 2d1aedb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions confetti.css

Large diffs are not rendered by default.

21 changes: 20 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/solid.css" integrity="sha384-TbilV5Lbhlwdyc4RuIV/JhD8NR+BfMrvz4BL5QFa2we1hQu6wvREr3v6XSRfCTRp" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/fontawesome.css" integrity="sha384-ozJwkrqb90Oa3ZNb+yKFW2lToAWYdTiF1vt8JiH5ptTGHTGcN7qdoR1F95e0kYyG" crossorigin="anonymous">

<link rel="stylesheet" href="confetti.css">


<script src="https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.29.0/date_fns.min.js" integrity="sha256-J+IkOQfxSI1XzGtgoazVThPhunb79GLoKjW87erTCpM=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/odometer.js/0.4.8/odometer.min.js" integrity="sha256-65R1G5irU1VT+k8L4coqgd3saSvO/Wufson/w+v2Idw=" crossorigin="anonymous"></script>

Expand Down Expand Up @@ -124,6 +127,11 @@ <h1 class="yesno d-none">Não</h1>
document.addEventListener("DOMContentLoaded", function () {
let theParty = parties[0];

let isAnniv = false;
for (let possAnniv = theParty.date; dateFns.differenceInMonths(possAnniv, today) < 1; possAnniv = dateFns.addYears(possAnniv, 1)) {
isAnniv = Math.abs(dateFns.differenceInCalendarDays(possAnniv, today)) < 2;
}

if (dateFns.isToday(theParty.date)) {
yesNo.innerText = 'SIM!';

Expand All @@ -141,13 +149,24 @@ <h1 class="yesno d-none">Não</h1>

leadN.classList.remove('d-none');

if (isAnniv) {
var f = document.createDocumentFragment();

for (let i = 0; i <= 150; i++) {
var c = document.createElement('div');
c.className = `confetti-${i}`;
f.appendChild(c);
}

document.body.appendChild(f);
}

if (Math.random() < 0.1) {
FEEC.classList.remove('d-none');
}
}

yesNo.classList.remove('d-none');

});
</script>
</body>
Expand Down

0 comments on commit 2d1aedb

Please sign in to comment.