-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
121 lines (102 loc) Β· 4.32 KB
/
script.js
File metadata and controls
121 lines (102 loc) Β· 4.32 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
// --- CONFIGURATION ---
const ADMIN_WHATSAPP = "2349120536618";
const ADMIN_EMAIL = "trojanity777@gmail.com";
let currentStep = 1;
// We will store the final message here so both buttons can use it
let generatedCaseID = "";
let finalMessageBody = "";
let finalEmailSubject = "";
// --- NAVIGATION ---
function nextStep(targetStep) {
// Simple Validation
const currentDiv = document.querySelector('.active-step');
const inputs = currentDiv.querySelectorAll('input, select, textarea');
let isValid = true;
inputs.forEach(input => {
if(!input.value.trim()){
isValid = false;
input.style.borderColor = "red";
} else {
input.style.borderColor = "rgba(255,255,255,0.1)";
}
});
if(isValid) {
document.querySelector('.active-step').classList.remove('active-step');
document.getElementById('step' + targetStep).classList.add('active-step');
document.getElementById('dot' + targetStep).classList.add('active');
currentStep = targetStep;
} else {
alert("Please fill all fields.");
}
}
function prevStep(targetStep) {
document.querySelector('.active-step').classList.remove('active-step');
document.getElementById('step' + targetStep).classList.add('active-step');
document.getElementById('dot' + (targetStep+1)).classList.remove('active');
currentStep = targetStep;
}
// --- SUBMIT: SHOW MODAL ---
document.getElementById('complaintForm').addEventListener('submit', function(e) {
e.preventDefault();
// 1. Generate Case ID
generatedCaseID = 'CASE-' + Math.floor(10000 + Math.random() * 90000);
document.getElementById('modalCaseId').innerText = generatedCaseID;
// 2. Collect Data
const source = document.getElementById('source').value;
const type = document.getElementById('type').value;
const scammerName = document.getElementById('scammerName').value;
const amountLost = document.getElementById('amountLost').value;
const narrative = document.getElementById('narrative').value;
const victimName = document.getElementById('victimName').value;
const victimPhone = document.getElementById('victimPhone').value;
// 3. Prepare the Text (Formatted)
// We use encodeURIComponent to ensure special characters work in URLs
// FOR EMAIL SUBJECT
finalEmailSubject = encodeURIComponent(`New Scam Complaint: ${generatedCaseID}`);
// FOR BODY (WhatsApp & Email)
let rawText = `π¨ *NEW COMPLAINT FILED*\n`;
rawText += `----------------------------\n`;
rawText += `π *Case ID:* ${generatedCaseID}\n`;
rawText += `----------------------------\n`;
rawText += `π€ *Victim Name:* ${victimName}\n`;
rawText += `π± *Victim Phone:* ${victimPhone}\n`;
rawText += `----------------------------\n`;
rawText += `π *Source:* ${source}\n`;
rawText += `β οΈ *Type:* ${type}\n`;
rawText += `π΅οΈ *Scammer:* ${scammerName}\n`;
rawText += `πΈ *Amount Lost:* $${amountLost}\n`;
rawText += `π *Story:* ${narrative}\n`;
rawText += `----------------------------\n`;
rawText += `π΄ *Please review immediately.*`;
// Encode for URL
finalMessageBody = encodeURIComponent(rawText);
// 4. Show the Modal
document.getElementById('selectionModal').style.display = 'flex';
});
// --- BUTTON ACTIONS ---
function sendViaWhatsApp() {
// We use the 'whatsapp://' protocol.
// This skips the browser loading screen entirely and opens the App directly.
const url = `whatsapp://send?phone=${ADMIN_WHATSAPP}&text=${finalMessageBody}`;
// Trigger the link
window.location.href = url;
}
function sendViaGmail() {
// This opens the Gmail app or default mail client
const url = `mailto:${ADMIN_EMAIL}?subject=${finalEmailSubject}&body=${finalMessageBody}`;
window.location.href = url;
}
function closeModal() {
document.getElementById('selectionModal').style.display = 'none';
}
function checkStatus() {
const input = document.getElementById('trackInput').value;
if(input.length > 0) {
const msg = encodeURIComponent(`Hello Admin, checking status for Case: ${input}`);
// Update this line to use whatsapp:// as well
const url = `whatsapp://send?phone=${ADMIN_WHATSAPP}&text=${msg}`;
window.location.href = url;
} else {
alert("Enter Case ID");
}
}