-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathscript.js
45 lines (44 loc) · 1.42 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
(() => {
const urlParams = new URLSearchParams(window.location.search);
const valentine = urlParams.get("valentine");
if (valentine) {
document.getElementById("valentine").innerText = valentine;
}
const message = urlParams.get("message");
if (message) {
document.getElementById("message").innerText = message;
}
const randomInt = (n) => Math.floor(Math.random() * n);
document.getElementById("dynamic").innerText = `
@keyframes spin {
0% {
margin-top: 2vh;
opacity: 0;
}
20% {
opacity:1.0;
margin-top: 0vh;
margin-left: 0vw;
transform: rotate(${randomInt(90)}deg);
}
100% {
opacity: 0.4;
margin-top: 100vh;
margin-left: ${randomInt(4)}vw;
transform: rotate(1080deg);
}
};
`;
let numberOfHearts = 45;
while (numberOfHearts--) {
var heartDiv = document.createElement("div");
heartDiv.classList.add("heart");
heartDiv.style = `animation: spin ${randomInt(14) + 6}s ease-in infinite;
top: ${randomInt(40)}vh;
left: ${randomInt(100)}vw;
font-size: ${randomInt(40) + 20}px;
color: ${["#d00", "#e66", "#fcc"][randomInt(3)]};`;
heartDiv.textContent = ["\u2661", "\u2665"][randomInt(2)];
document.getElementById("falling-hearts").appendChild(heartDiv);
}
})();