-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
167 lines (146 loc) · 5.71 KB
/
Copy pathscript.js
File metadata and controls
167 lines (146 loc) · 5.71 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/* Under Construction — a little interactivity to keep things fun. */
(function () {
"use strict";
/* --------- Rotating taglines --------- */
var taglines = [
"Pardon our dust — we're building something awesome.",
"Our hamsters are running as fast as they can. 🐹",
"Measuring twice, cutting once. ✂️",
"Pouring fresh pixels as we speak. 🎨",
"Tightening the last few bolts. 🔧",
"We promise it'll be worth the wait!",
"Currently herding bytes into place… 🐑",
"Brewing something special. ☕",
];
var taglineEl = document.getElementById("tagline");
var taglineIndex = 0;
function rotateTagline() {
taglineIndex = (taglineIndex + 1) % taglines.length;
taglineEl.style.opacity = "0";
setTimeout(function () {
taglineEl.textContent = taglines[taglineIndex];
taglineEl.style.transition = "opacity 0.4s ease";
taglineEl.style.opacity = "0.9";
}, 400);
}
setInterval(rotateTagline, 3500);
/* --------- Faux progress bar that never quite finishes --------- */
var fill = document.getElementById("progressFill");
var label = document.getElementById("progressLabel");
var progress = 0;
function tickProgress() {
// Creep toward 99% with diminishing steps — the classic "almost done".
var remaining = 99 - progress;
progress += Math.max(0.2, remaining * 0.04);
if (progress > 99) progress = 99;
fill.style.width = progress + "%";
label.textContent = Math.floor(progress) + "%";
document.querySelector(".progress").setAttribute("aria-valuenow", Math.floor(progress));
}
tickProgress();
setInterval(tickProgress, 600);
/* --------- "Hammer Time" button: bumps progress + celebratory burst --------- */
var btn = document.getElementById("ctaBtn");
var hardhat = document.querySelector(".hardhat");
var clicks = 0;
var quips = [
"BONK! 🔨",
"Nailed it! 🔨",
"Stop! Hammer time. 🎵",
"Construction intensifies… 🏗️",
"+1 productivity ⚡",
"You can't touch this. ✋",
];
btn.addEventListener("click", function () {
clicks++;
btn.textContent = quips[clicks % quips.length];
// Give the worker a celebratory spin.
hardhat.classList.remove("spin");
void hardhat.offsetWidth; // force reflow to restart animation
hardhat.classList.add("spin");
burstConfetti();
// Nudge progress forward as a reward.
progress = Math.min(99, progress + 3);
fill.style.width = progress + "%";
label.textContent = Math.floor(progress) + "%";
});
/* --------- Floating tool emojis --------- */
var emojis = ["🔧", "🔨", "🪛", "⚙️", "🚧", "🏗️", "🧱", "📐", "🪜", "🛠️"];
var floaties = document.querySelector(".floaties");
function spawnFloatie() {
var el = document.createElement("span");
el.className = "floatie";
el.textContent = emojis[Math.floor(Math.random() * emojis.length)];
el.style.left = Math.random() * 100 + "vw";
el.style.fontSize = 1.4 + Math.random() * 1.8 + "rem";
var duration = 8 + Math.random() * 8;
el.style.animationDuration = duration + "s";
floaties.appendChild(el);
setTimeout(function () {
el.remove();
}, duration * 1000);
}
var prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
if (!prefersReducedMotion) {
setInterval(spawnFloatie, 1400);
for (var i = 0; i < 4; i++) setTimeout(spawnFloatie, i * 500);
}
/* --------- Tiny confetti burst (canvas-free, DOM based) --------- */
function burstConfetti() {
if (prefersReducedMotion) return;
var colors = ["#ffcb05", "#ff6b35", "#533483", "#0f3460", "#ffffff"];
var rect = btn.getBoundingClientRect();
var originX = rect.left + rect.width / 2;
var originY = rect.top + rect.height / 2;
for (var i = 0; i < 18; i++) {
var piece = document.createElement("div");
piece.style.position = "fixed";
piece.style.left = originX + "px";
piece.style.top = originY + "px";
piece.style.width = "8px";
piece.style.height = "8px";
piece.style.background = colors[Math.floor(Math.random() * colors.length)];
piece.style.borderRadius = Math.random() > 0.5 ? "50%" : "2px";
piece.style.pointerEvents = "none";
piece.style.zIndex = "999";
document.body.appendChild(piece);
var angle = Math.random() * Math.PI * 2;
var velocity = 60 + Math.random() * 120;
var dx = Math.cos(angle) * velocity;
var dy = Math.sin(angle) * velocity - 80;
piece.animate(
[
{ transform: "translate(0, 0) rotate(0deg)", opacity: 1 },
{
transform: "translate(" + dx + "px, " + (dy + 200) + "px) rotate(" + Math.random() * 720 + "deg)",
opacity: 0,
},
],
{ duration: 900 + Math.random() * 400, easing: "cubic-bezier(0.2, 0.8, 0.3, 1)" }
).onfinish = function () {
this.effect.target.remove();
};
}
}
/* --------- Worker high-fives you back on click --------- */
hardhat.addEventListener("click", function () {
hardhat.classList.remove("spin");
void hardhat.offsetWidth;
hardhat.classList.add("spin");
burstConfetti();
});
/* --------- Konami-ish easter egg: type "build" --------- */
var buffer = "";
document.addEventListener("keydown", function (e) {
buffer = (buffer + e.key).slice(-5).toLowerCase();
if (buffer === "build") {
document.body.style.transition = "filter 0.5s";
document.body.style.filter = "hue-rotate(180deg)";
taglineEl.textContent = "🎉 Secret build mode activated! 🎉";
for (var i = 0; i < 5; i++) setTimeout(burstConfetti, i * 150);
setTimeout(function () {
document.body.style.filter = "";
}, 3000);
}
});
})();