-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
299 lines (240 loc) · 10 KB
/
script.js
File metadata and controls
299 lines (240 loc) · 10 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
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
// ==========================================
// 0. PENGATURAN AWAL (SCROLL LOCK) - BARU
// ==========================================
// Kunci scroll saat website baru dibuka agar tetap di overlay
document.body.style.overflow = 'hidden';
// ==========================================
// 1. GENERATOR BINTANG 3D (WARP EFFECT)
// ==========================================
function createWarpStars() {
const container = document.querySelector('.warp-container');
const numberOfStars = 300; // Jumlah bintang
for (let i = 0; i < numberOfStars; i++) {
const star = document.createElement('div');
star.className = 'star';
const x = (Math.random() * 200 - 50) + '%';
const y = (Math.random() * 200 - 50) + '%';
star.style.left = x;
star.style.top = y;
// Durasi: 3s sampai 9s (Sedikit lebih cepat dari sebelumnya agar kerasa "warp"-nya)
const duration = Math.random() * 6 + 6 + 's';
const delay = Math.random() * -7 + 's';
star.style.animation = `warpMove ${duration} linear infinite ${delay}`;
container.appendChild(star);
}
}
createWarpStars();
// ==========================================
// 2. LOGIKA OVERLAY SPACE JOURNEY
// ==========================================
const music = document.getElementById('bg-music');
const musicIcon = document.getElementById('music-icon');
const musicBtn = document.querySelector('.music-btn');
const overlay = document.getElementById('space-overlay');
const startTriggerBox = document.getElementById('start-trigger-box');
const textSequenceBox = document.getElementById('text-sequence-box');
let isPlaying = false;
function beginJourney() {
music.volume = 0.6;
music.play().then(() => { isPlaying = true; }).catch(err => { console.log("Gagal autoplay: " + err); });
startTriggerBox.style.display = 'none';
textSequenceBox.style.display = 'block';
const text1 = document.querySelector('.text-1');
const text2 = document.querySelector('.text-2');
const text3 = document.querySelector('.text-3');
const textFinal = document.querySelector('.text-final');
const finalBtn = document.getElementById('final-open-btn');
setTimeout(() => { text1.classList.add('show'); }, 500);
setTimeout(() => { text1.classList.remove('show'); }, 3500);
setTimeout(() => { text2.classList.add('show'); }, 4500);
setTimeout(() => { text2.classList.remove('show'); }, 7500);
setTimeout(() => { text3.classList.add('show'); }, 8500);
setTimeout(() => { text3.classList.remove('show'); }, 11500);
setTimeout(() => { textFinal.classList.add('show-drop'); }, 12500);
setTimeout(() => {
finalBtn.classList.remove('hidden');
finalBtn.classList.add('visible');
}, 14000);
}
function enterWebsite() {
overlay.style.opacity = '0';
setTimeout(() => {
overlay.style.display = 'none';
musicBtn.style.display = 'flex';
// --- UPDATE BARU: IZINKAN SCROLL SETELAH MASUK ---
document.body.style.overflow = 'auto';
// -------------------------------------------------
initScrollAnimations();
}, 1500);
}
// Toggle Musik
function toggleMusic() {
if (isPlaying) {
music.pause();
musicIcon.innerHTML = '<i class="fa-solid fa-volume-xmark"></i>';
isPlaying = false;
} else {
music.play();
musicIcon.innerHTML = '<i class="fa-solid fa-music"></i>';
isPlaying = true;
}
}
// ==========================================
// 3. ANIMASI SCROLL
// ==========================================
function initScrollAnimations() {
window.scrollTo(0, 0);
const observerOptions = { threshold: 0.1 };
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
}
});
}, observerOptions);
document.querySelectorAll('.fade-in').forEach((el) => {
observer.observe(el);
});
}
// ==========================================
// 4. FITUR LAIN (MODAL & HEARTS)
// ==========================================
const modal = document.getElementById("imageModal");
const modalImg = document.getElementById("modal-img");
const modalTitle = document.getElementById("modal-title");
const modalStory = document.getElementById("modal-story");
function openModal(element) {
const imgSrc = element.querySelector('img').src;
const title = element.getAttribute('data-title');
const story = element.getAttribute('data-story');
modalImg.src = imgSrc;
modalTitle.innerText = title;
modalStory.innerText = story;
modal.classList.add("show");
}
function closeModal() { modal.classList.remove("show"); }
window.onclick = function(event) { if (event.target == modal) closeModal(); }
// Floating Hearts
function createHearts() {
const container = document.getElementById('heart-container');
const heart = document.createElement('div');
heart.className = 'floating-heart';
heart.innerHTML = '<i class="fa-solid fa-heart"></i>';
heart.style.left = Math.random() * 100 + 'vw';
heart.style.fontSize = (Math.random() * 20 + 10) + 'px';
heart.style.animationDuration = (Math.random() * 5 + 5) + 's';
container.appendChild(heart);
setTimeout(() => { heart.remove(); }, 10000);
}
setInterval(createHearts, 400);
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({ behavior: 'smooth' });
});
});
// ==========================================
// 5. BUKA SURAT INTERAKTIF (ANIMASI HALUS)
// ==========================================
function openLetter() {
const cover = document.getElementById('envelope-cover');
const letter = document.getElementById('main-letter');
// 1. Hilangkan Amplop Perlahan
cover.classList.add('fade-out');
// 2. Tunggu 0.5 detik, lalu munculkan surat
setTimeout(() => {
cover.style.display = 'none';
letter.classList.add('show-letter-content');
letter.scrollIntoView({ behavior: 'smooth', block: 'center' });
}, 500);
}
// ==========================================
// 6. TIME TOGETHER COUNTER
// ==========================================
function startTimer() {
// --- GANTI TANGGAL JADIAN DI SINI (Format: YYYY-MM-DD) ---
const startDate = new Date("2025-07-19"); // Contoh: 14 Feb 2023
// ---------------------------------------------------------
const daysElem = document.getElementById("days");
const hoursElem = document.getElementById("hours");
const minutesElem = document.getElementById("minutes");
const secondsElem = document.getElementById("seconds");
function updateTimer() {
const now = new Date();
const diff = now - startDate;
const days = Math.floor(diff / (1000 * 60 * 60 * 24));
const hours = Math.floor((diff / (1000 * 60 * 60)) % 24);
const minutes = Math.floor((diff / 1000 / 60) % 60);
const seconds = Math.floor((diff / 1000) % 60);
daysElem.innerText = days;
hoursElem.innerText = hours;
minutesElem.innerText = minutes;
secondsElem.innerText = seconds;
}
setInterval(updateTimer, 1000); // Update setiap 1 detik
updateTimer(); // Jalankan langsung saat load
}
// Panggil fungsi ini
startTimer();
// ==========================================
// 7. KIRIM PESAN KE WHATSAPP & CUSTOM ALERT
// ==========================================
// Fungsi untuk Memunculkan Alert Custom
function showCustomAlert(message) {
const alertOverlay = document.getElementById('custom-alert');
const alertMsg = document.getElementById('alert-message');
alertMsg.innerText = message;
alertOverlay.style.display = 'flex';
// Sedikit delay biar animasi CSS jalan mulus
setTimeout(() => {
alertOverlay.classList.add('active');
}, 10);
}
// Fungsi untuk Menutup Alert
function closeCustomAlert() {
const alertOverlay = document.getElementById('custom-alert');
alertOverlay.classList.remove('active');
setTimeout(() => {
alertOverlay.style.display = 'none';
}, 300); // Tunggu animasi selesai baru hilang
}
function sendToWA() {
const inputPesan = document.getElementById('msg-input').value;
if (inputPesan.trim() === "") {
// GANTI ALERT BAWAAN DENGAN CUSTOM ALERT
showCustomAlert("Tulis pesannya dulu dong sayang :(");
return;
}
// --- NOMOR WA (Pastikan sudah diganti dengan nomor kamu) ---
const nomorHP = "6281234567890";
// -----------------------------------------------------------
const url = `https://wa.me/${nomorHP}?text=${encodeURIComponent(inputPesan)}`;
window.open(url, '_blank');
}
// ==========================================
// 8. INTERACTIVE QUIZ
// ==========================================
function wrongAnswer(button) {
// Tambahkan efek getar
button.classList.add('shake');
// Ganti teks sebentar
const originalText = button.innerText;
button.innerText = "Salah wlee 😝";
setTimeout(() => {
button.classList.remove('shake');
button.innerText = originalText;
}, 1000);
}
function rightAnswer(currentQuestion) {
// Sembunyikan pertanyaan sekarang
document.getElementById(`q${currentQuestion}`).classList.add('hidden');
// Cek apakah ada pertanyaan berikutnya
const nextQ = document.getElementById(`q${currentQuestion + 1}`);
if (nextQ) {
nextQ.classList.remove('hidden');
} else {
// Kalau sudah habis, munculkan reward
document.getElementById('reward').classList.remove('hidden');
createHearts(); // Hujan hati
}
}