-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathscript.js
448 lines (383 loc) · 13.3 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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
// Fungsi untuk memulai musik
function playMusic() {
const music = document.getElementById('background-music');
music.play();
}
window.addEventListener('DOMContentLoaded', function() {
playMusic();
});
document.body.addEventListener('click', playMusic, { once: true });
const content = document.getElementById('content');
const footer = document.getElementsByTagName('footer')[0];
const timer = document.getElementById('timer');
const second = 1000,
minute = second * 60,
hour = minute * 60,
day = hour * 24;
let countDown = new Date('Oct 22, 2023 00:00:00').getTime(),
x = setInterval(function () {
let now = new Date().getTime(),
distance = countDown - now;
// document.getElementById('days').innerText = Math.floor(distance / (day)),
document.getElementById('hours').innerText = Math.floor(distance / (hour)),
document.getElementById('minutes').innerText = Math.floor((distance % (hour)) / (minute)),
document.getElementById('seconds').innerText = Math.floor((distance % (minute)) / second);
if (distance < 0) {
timer.classList.add('d-none');
confetti();
clearInterval(x);
_slideSatu();
}
}, second)
const _slideSatu = function () {
const tap = document.getElementById('tap');
const slideSatu = document.getElementById('slideSatu');
slideSatu.classList.remove('d-none');
setTimeout(function () {
tap.classList.remove('d-none');
document.body.addEventListener('click', function () {
_slideDua();
})
}, 7000);
};
const _slideDua = function () {
const slideSatu = document.getElementById('slideSatu');
const tap = document.getElementById('tap');
const slideDua = document.getElementById('slideDua');
setTimeout(function () {
slideSatu.classList.replace('animate__slideInDown', 'animate__backOutDown');
tap.classList.add('d-none');
setTimeout(function () {
slideSatu.classList.add('d-none');
}, 1000);
}, 1000);
slideDua.classList.remove('d-none');
setTimeout(function () {
tap.classList.remove('d-none');
document.body.addEventListener('click', function () {
slideDua.classList.replace('animate__zoomInDown', 'animate__fadeOutLeft');
slideDua.classList.remove('animate__delay-2s', 'animate__slow');
tap.classList.add('d-none');
setTimeout(function () {
slideDua.remove();
_slideTiga();
}, 1000);
})
}, 40000);
};
const _slideTiga = function () {
const tap = document.getElementById('tap');
const slideTiga = document.getElementById('slideTiga');
slideTiga.classList.remove('d-none');
setTimeout(function () {
tap.classList.remove('d-none');
document.body.addEventListener('click', function () {
slideTiga.classList.remove('animate__delay-2s', 'animate__slow');
slideTiga.classList.replace('animate__fadeInRight', 'animate__fadeOut');
tap.remove();
setTimeout(function () {
slideTiga.remove();
_slideEmpat();
}, 1000);
})
}, 43000);
}
function getRandomPosition(element) {
var x = document.body.offsetHeight - element.clientHeight;
var y = document.body.offsetWidth - element.clientWidth;
var randomX = Math.floor(Math.random() * 500);
var randomY = Math.floor(Math.random() * y);
return [randomX, randomY];
};
const _slideEmpat = function () {
const slideEmpat = document.getElementById('slideEmpat');
const btn = document.getElementsByTagName('button');
slideEmpat.classList.remove('d-none');
btn[0].addEventListener('click', function () {
var xy = getRandomPosition(slideEmpat);
slideEmpat.style.top = xy[0] + 'px';
// slideEmpat.style.left = xy[1] + 'px';
});
btn[1].addEventListener('click', function () {
slideEmpat.classList.replace('animate__fadeInDown', 'animate__bounceOut');
slideEmpat.classList.remove('animate__delay-2s');
setTimeout(function () {
slideEmpat.remove()
setTimeout(() => {
_slideLima();
}, 500);
}, 1000);
})
};
const _slideLima = function () {
const slideLima = document.getElementById('slideLima');
slideLima.classList.remove('d-none');
const trims = document.getElementById('trims');
setTimeout(() => {
trims.classList.remove('d-none');
}, 1000);
slideLima.addEventListener('animationend', () => {
slideLima.classList.add('animate__delay-3s')
slideLima.classList.replace('animate__bounceIn', 'animate__fadeOut');
trims.classList.add('animate__animated', 'animate__fadeOut', 'animate__delay-3s');
setTimeout(() => {
trims.remove();
setTimeout(() => {
slideLima.remove();
_slideEnam();
}, 1000);
}, 6000);
});
};
const _slideEnam = function () {
const slideEnam = document.getElementById('slideEnam');
slideEnam.classList.remove('d-none');
};
new TypeIt("#teks1", {
strings: ["Hari ini, saya langitkan semua doa terbaik saya untuk kamu.", "Semoga hal-hal yang membuat kamu runtuh turut menjadi alasan kamu untuk tetap tumbuh.", "Semoga dunia senantiasa menjaga kamu dimanapun kamu berada.", "Semoga hari-hari kamu selalu diiringi cinta yang tak pernah ada batasnya." , "Semoga setiap langkahmu dimudahkan hingga tercapai apa yang kamu inginkan."],
startDelay: 4000,
speed: 75,
waitUntilVisible: true
}).go();
new TypeIt("#teks2", {
strings: ["Dengan ataupun tanpaku, semoga semesta selalu membahagiakan kamu bagimanapun caranya.", " ", "barakallah fi umrik, terima kasih sudah bertahan sampai sejauh ini.", " ", "- Wish all you the best"],
startDelay: 2000,
speed: 75,
waitUntilVisible: true
}).go();
new TypeIt("#trims", {
strings: ["Terimakasih."],
startDelay: 2000,
speed: 150,
loop: false,
waitUntilVisible: true,
}).go();
'use strict';
var onlyOnKonami = false;
function confetti() {
// Globals
var $window = $(window),
random = Math.random,
cos = Math.cos,
sin = Math.sin,
PI = Math.PI,
PI2 = PI * 2,
timer = undefined,
frame = undefined,
confetti = [];
var runFor = 2000
var isRunning = true
setTimeout(() => {
isRunning = false
}, runFor);
// Settings
var konami = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65],
pointer = 0;
var particles = 150,
spread = 20,
sizeMin = 5,
sizeMax = 12 - sizeMin,
eccentricity = 10,
deviation = 100,
dxThetaMin = -.1,
dxThetaMax = -dxThetaMin - dxThetaMin,
dyMin = .13,
dyMax = .18,
dThetaMin = .4,
dThetaMax = .7 - dThetaMin;
var colorThemes = [
function () {
return color(200 * random() | 0, 200 * random() | 0, 200 * random() | 0);
},
function () {
var black = 200 * random() | 0;
return color(200, black, black);
},
function () {
var black = 200 * random() | 0;
return color(black, 200, black);
},
function () {
var black = 200 * random() | 0;
return color(black, black, 200);
},
function () {
return color(200, 100, 200 * random() | 0);
},
function () {
return color(200 * random() | 0, 200, 200);
},
function () {
var black = 256 * random() | 0;
return color(black, black, black);
},
function () {
return colorThemes[random() < .5 ? 1 : 2]();
},
function () {
return colorThemes[random() < .5 ? 3 : 5]();
},
function () {
return colorThemes[random() < .5 ? 2 : 4]();
}
];
function color(r, g, b) {
return 'rgb(' + r + ',' + g + ',' + b + ')';
}
// Cosine interpolation
function interpolation(a, b, t) {
return (1 - cos(PI * t)) / 2 * (b - a) + a;
}
// Create a 1D Maximal Poisson Disc over [0, 1]
var radius = 1 / eccentricity,
radius2 = radius + radius;
function createPoisson() {
// domain is the set of points which are still available to pick from
// D = union{ [d_i, d_i+1] | i is even }
var domain = [radius, 1 - radius],
measure = 1 - radius2,
spline = [0, 1];
while (measure) {
var dart = measure * random(),
i, l, interval, a, b, c, d;
// Find where dart lies
for (i = 0, l = domain.length, measure = 0; i < l; i += 2) {
a = domain[i], b = domain[i + 1], interval = b - a;
if (dart < measure + interval) {
spline.push(dart += a - measure);
break;
}
measure += interval;
}
c = dart - radius, d = dart + radius;
for (i = domain.length - 1; i > 0; i -= 2) {
l = i - 1, a = domain[l], b = domain[i];
// c---d c---d Do nothing
// c-----d c-----d Move interior
// c--------------d Delete interval
// c--d Split interval
// a------b
if (a >= c && a < d)
if (b > d) domain[l] = d; // Move interior (Left case)
else domain.splice(l, 2); // Delete interval
else if (a < c && b > c)
if (b <= d) domain[i] = c; // Move interior (Right case)
else domain.splice(i, 0, c, d); // Split interval
}
for (i = 0, l = domain.length, measure = 0; i < l; i += 2)
measure += domain[i + 1] - domain[i];
}
return spline.sort();
}
var container = document.createElement('div');
container.style.position = 'fixed';
container.style.top = '0';
container.style.left = '0';
container.style.width = '100%';
container.style.height = '0';
container.style.overflow = 'visible';
container.style.zIndex = '9999';
// Confetto constructor
function Confetto(theme) {
this.frame = 0;
this.outer = document.createElement('div');
this.inner = document.createElement('div');
this.outer.appendChild(this.inner);
var outerStyle = this.outer.style,
innerStyle = this.inner.style;
outerStyle.position = 'absolute';
outerStyle.width = (sizeMin + sizeMax * random()) + 'px';
outerStyle.height = (sizeMin + sizeMax * random()) + 'px';
innerStyle.width = '100%';
innerStyle.height = '100%';
innerStyle.backgroundColor = theme();
outerStyle.perspective = '50px';
outerStyle.transform = 'rotate(' + (360 * random()) + 'deg)';
this.axis = 'rotate3D(' +
cos(360 * random()) + ',' +
cos(360 * random()) + ',0,';
this.theta = 360 * random();
this.dTheta = dThetaMin + dThetaMax * random();
innerStyle.transform = this.axis + this.theta + 'deg)';
this.x = $window.width() * random();
this.y = -deviation;
this.dx = sin(dxThetaMin + dxThetaMax * random());
this.dy = dyMin + dyMax * random();
outerStyle.left = this.x + 'px';
outerStyle.top = this.y + 'px';
// Create the periodic spline
this.splineX = createPoisson();
this.splineY = [];
for (var i = 1, l = this.splineX.length - 1; i < l; ++i)
this.splineY[i] = deviation * random();
this.splineY[0] = this.splineY[l] = deviation * random();
this.update = function (height, delta) {
this.frame += delta;
this.x += this.dx * delta;
this.y += this.dy * delta;
this.theta += this.dTheta * delta;
// Compute spline and convert to polar
var phi = this.frame % 7777 / 7777,
i = 0,
j = 1;
while (phi >= this.splineX[j]) i = j++;
var rho = interpolation(
this.splineY[i],
this.splineY[j],
(phi - this.splineX[i]) / (this.splineX[j] - this.splineX[i])
);
phi *= PI2;
outerStyle.left = this.x + rho * cos(phi) + 'px';
outerStyle.top = this.y + rho * sin(phi) + 'px';
innerStyle.transform = this.axis + this.theta + 'deg)';
return this.y > height + deviation;
};
}
function poof() {
if (!frame) {
// Append the container
document.body.appendChild(container);
// Add confetti
var theme = colorThemes[onlyOnKonami ? colorThemes.length * random() | 0 : 0],
count = 0;
(function addConfetto() {
if (onlyOnKonami && ++count > particles)
return timer = undefined;
if (isRunning) {
var confetto = new Confetto(theme);
confetti.push(confetto);
container.appendChild(confetto.outer);
timer = setTimeout(addConfetto, spread * random());
}
})(0);
// Start the loop
var prev = undefined;
requestAnimationFrame(function loop(timestamp) {
var delta = prev ? timestamp - prev : 0;
prev = timestamp;
var height = $window.height();
for (var i = confetti.length - 1; i >= 0; --i) {
if (confetti[i].update(height, delta)) {
container.removeChild(confetti[i].outer);
confetti.splice(i, 1);
}
}
if (timer || confetti.length)
return frame = requestAnimationFrame(loop);
// Cleanup
document.body.removeChild(container);
frame = undefined;
});
}
}
$window.keydown(function (event) {
pointer = konami[pointer] === event.which ?
pointer + 1 :
+(event.which === konami[0]);
if (pointer === konami.length) {
pointer = 0;
poof();
}
});
if (!onlyOnKonami) poof();
};