-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathscript.js
More file actions
153 lines (131 loc) Β· 5.35 KB
/
Copy pathscript.js
File metadata and controls
153 lines (131 loc) Β· 5.35 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
document.addEventListener('DOMContentLoaded', function() {
// --- Live Age Counter ---
const birthDate = new Date('2006-08-14T00:00:00');
const countdownElement = document.getElementById('countdown');
function updateAge() {
const now = new Date();
let years = now.getFullYear() - birthDate.getFullYear();
let months = now.getMonth() - birthDate.getMonth();
let days = now.getDate() - birthDate.getDate();
let hours = now.getHours() - birthDate.getHours();
let minutes = now.getMinutes() - birthDate.getMinutes();
let seconds = now.getSeconds() - birthDate.getSeconds();
if (seconds < 0) { seconds += 60; minutes--; }
if (minutes < 0) { minutes += 60; hours--; }
if (hours < 0) { hours += 24; days--; }
if (days < 0) {
const prevMonth = new Date(now.getFullYear(), now.getMonth(), 0);
days += prevMonth.getDate();
months--;
}
if (months < 0) { months += 12; years--; }
countdownElement.innerHTML = `${years}y ${months}m ${days}d <br> ${hours}h ${minutes}m ${seconds}s`;
}
setInterval(updateAge, 1000);
updateAge();
// --- Initialize AOS (Animate on Scroll) ---
AOS.init({
duration: 800,
once: true,
});
// --- Initialize LightGallery ---
lightGallery(document.getElementById('lightgallery'), {
speed: 500,
download: false
});
// --- Hall of Fame Scroller ---
const scroller = document.getElementById('hall-of-fame-scroller');
const scrollLeftBtn = document.getElementById('scroll-left-btn');
const scrollRightBtn = document.getElementById('scroll-right-btn');
if (scroller && scrollLeftBtn && scrollRightBtn) {
const card = scroller.querySelector('.snap-center');
const cardWidth = card.offsetWidth + parseInt(getComputedStyle(card.parentElement).gap);
scrollRightBtn.addEventListener('click', () => {
scroller.scrollBy({ left: cardWidth, behavior: 'smooth' });
});
scrollLeftBtn.addEventListener('click', () => {
scroller.scrollBy({ left: -cardWidth, behavior: 'smooth' });
});
}
// --- Video Uploader ---
const videoUploadInput = document.getElementById('video-upload');
const videoPlayer = document.getElementById('video-player');
const videoUploadLabel = document.getElementById('video-upload-label');
if(videoUploadInput && videoPlayer && videoUploadLabel) {
videoUploadLabel.addEventListener('click', () => {
videoUploadInput.click();
});
videoUploadInput.addEventListener('change', (event) => {
const file = event.target.files[0];
if (file) {
const videoURL = URL.createObjectURL(file);
videoPlayer.src = videoURL;
videoPlayer.classList.remove('hidden');
videoUploadLabel.classList.add('hidden');
videoPlayer.play();
}
});
}
// --- Sakura Petal Animation ---
const canvas = document.getElementById('sakura-canvas');
if (canvas) {
const ctx = canvas.getContext('2d');
let petals = [];
const numPetals = 50;
function resizeCanvas() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
function Petal() {
this.x = Math.random() * canvas.width;
this.y = Math.random() * canvas.height * 2 - canvas.height;
this.w = 25 + Math.random() * 15;
this.h = 20 + Math.random() * 10;
this.opacity = this.w / 40;
this.flip = Math.random();
this.xSpeed = 1.5 + Math.random() * 2;
this.ySpeed = 1 + Math.random() * 1;
this.flipSpeed = Math.random() * 0.03;
}
Petal.prototype.draw = function() {
if (this.y > canvas.height || this.x > canvas.width) {
this.x = -this.w;
this.y = Math.random() * canvas.height * 2 - canvas.height;
this.xSpeed = 1.5 + Math.random() * 2;
this.ySpeed = 1 + Math.random() * 1;
this.flip = Math.random();
}
ctx.globalAlpha = this.opacity;
ctx.beginPath();
ctx.moveTo(this.x, this.y);
ctx.bezierCurveTo(this.x + this.w / 2, this.y - this.h / 2, this.x + this.w, this.y, this.x + this.w / 2, this.y + this.h / 2);
ctx.bezierCurveTo(this.x, this.y + this.h, this.x - this.w / 2, this.y, this.x, this.y);
ctx.closePath();
ctx.fillStyle = '#FFB7C5';
ctx.fill();
}
Petal.prototype.update = function() {
this.x += this.xSpeed;
this.y += this.ySpeed;
this.flip += this.flipSpeed;
this.draw();
}
function createPetals() {
petals = [];
for (let i = 0; i < numPetals; i++) {
petals.push(new Petal());
}
}
function animate() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
petals.forEach(petal => {
petal.update();
});
requestAnimationFrame(animate);
}
createPetals();
animate();
}
});