melassy commited on
Commit
2c8b548
·
verified ·
1 Parent(s): fc45763

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +677 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Dr Ealssy
3
- emoji: 🚀
4
- colorFrom: purple
5
- colorTo: pink
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: dr-ealssy
3
+ emoji: 🐳
4
+ colorFrom: blue
5
+ colorTo: blue
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,677 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>WhatsApp Message Automation for Students</title>
7
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
8
+ <style>
9
+ :root {
10
+ --primary-color: #25D366;
11
+ --secondary-color: #128C7E;
12
+ --light-color: #DCF8C6;
13
+ --dark-color: #075E54;
14
+ --error-color: #FF3B30;
15
+ --success-color: #34C759;
16
+ }
17
+
18
+ * {
19
+ margin: 0;
20
+ padding: 0;
21
+ box-sizing: border-box;
22
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
23
+ }
24
+
25
+ body {
26
+ background-color: #f5f5f5;
27
+ color: #333;
28
+ line-height: 1.6;
29
+ }
30
+
31
+ .container {
32
+ max-width: 900px;
33
+ margin: 2rem auto;
34
+ padding: 2rem;
35
+ background-color: white;
36
+ border-radius: 12px;
37
+ box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
38
+ }
39
+
40
+ header {
41
+ text-align: center;
42
+ margin-bottom: 2rem;
43
+ }
44
+
45
+ h1 {
46
+ color: var(--dark-color);
47
+ margin-bottom: 0.5rem;
48
+ font-size: 2.2rem;
49
+ }
50
+
51
+ .subtitle {
52
+ color: #666;
53
+ font-size: 1.1rem;
54
+ }
55
+
56
+ .logo {
57
+ font-size: 3rem;
58
+ color: var(--primary-color);
59
+ margin-bottom: 1rem;
60
+ }
61
+
62
+ .upload-section {
63
+ border: 2px dashed #ccc;
64
+ border-radius: 8px;
65
+ padding: 2rem;
66
+ text-align: center;
67
+ margin-bottom: 2rem;
68
+ transition: all 0.3s ease;
69
+ position: relative;
70
+ }
71
+
72
+ .upload-section:hover {
73
+ border-color: var(--primary-color);
74
+ background-color: rgba(37, 211, 102, 0.05);
75
+ }
76
+
77
+ .upload-icon {
78
+ font-size: 3rem;
79
+ color: var(--secondary-color);
80
+ margin-bottom: 1rem;
81
+ }
82
+
83
+ .file-input {
84
+ display: none;
85
+ }
86
+
87
+ .upload-btn {
88
+ background-color: var(--primary-color);
89
+ color: white;
90
+ border: none;
91
+ padding: 0.8rem 1.5rem;
92
+ border-radius: 50px;
93
+ font-weight: 600;
94
+ cursor: pointer;
95
+ transition: all 0.3s ease;
96
+ display: inline-flex;
97
+ align-items: center;
98
+ gap: 0.5rem;
99
+ }
100
+
101
+ .upload-btn:hover {
102
+ background-color: var(--dark-color);
103
+ transform: translateY(-2px);
104
+ }
105
+
106
+ .file-name {
107
+ margin-top: 1rem;
108
+ font-size: 0.9rem;
109
+ color: #666;
110
+ }
111
+
112
+ .form-group {
113
+ margin-bottom: 1.5rem;
114
+ }
115
+
116
+ label {
117
+ display: block;
118
+ margin-bottom: 0.5rem;
119
+ font-weight: 600;
120
+ color: var(--dark-color);
121
+ }
122
+
123
+ select, textarea {
124
+ width: 100%;
125
+ padding: 0.8rem;
126
+ border: 1px solid #ddd;
127
+ border-radius: 6px;
128
+ font-size: 1rem;
129
+ transition: border 0.3s ease;
130
+ }
131
+
132
+ select:focus, textarea:focus {
133
+ outline: none;
134
+ border-color: var(--primary-color);
135
+ box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.2);
136
+ }
137
+
138
+ textarea {
139
+ min-height: 120px;
140
+ resize: vertical;
141
+ }
142
+
143
+ .message-preview {
144
+ background-color: var(--light-color);
145
+ padding: 1rem;
146
+ border-radius: 8px;
147
+ margin-top: 1rem;
148
+ border-left: 4px solid var(--primary-color);
149
+ }
150
+
151
+ .country-code {
152
+ display: flex;
153
+ gap: 1rem;
154
+ }
155
+
156
+ .country-code select {
157
+ flex: 1;
158
+ }
159
+
160
+ .country-code input {
161
+ flex: 2;
162
+ padding: 0.8rem;
163
+ border: 1px solid #ddd;
164
+ border-radius: 6px;
165
+ font-size: 1rem;
166
+ }
167
+
168
+ .controls {
169
+ display: flex;
170
+ justify-content: space-between;
171
+ margin-top: 2rem;
172
+ }
173
+
174
+ .btn {
175
+ padding: 0.8rem 1.5rem;
176
+ border-radius: 50px;
177
+ font-weight: 600;
178
+ cursor: pointer;
179
+ transition: all 0.3s ease;
180
+ border: none;
181
+ display: inline-flex;
182
+ align-items: center;
183
+ gap: 0.5rem;
184
+ }
185
+
186
+ .btn-primary {
187
+ background-color: var(--primary-color);
188
+ color: white;
189
+ }
190
+
191
+ .btn-primary:hover {
192
+ background-color: var(--dark-color);
193
+ transform: translateY(-2px);
194
+ }
195
+
196
+ .btn-secondary {
197
+ background-color: white;
198
+ color: var(--dark-color);
199
+ border: 1px solid #ddd;
200
+ }
201
+
202
+ .btn-secondary:hover {
203
+ background-color: #f5f5f5;
204
+ }
205
+
206
+ .btn:disabled {
207
+ opacity: 0.6;
208
+ cursor: not-allowed;
209
+ transform: none;
210
+ }
211
+
212
+ .progress-container {
213
+ margin-top: 2rem;
214
+ display: none;
215
+ }
216
+
217
+ .progress-bar {
218
+ height: 8px;
219
+ background-color: #eee;
220
+ border-radius: 4px;
221
+ margin-bottom: 0.5rem;
222
+ overflow: hidden;
223
+ }
224
+
225
+ .progress {
226
+ height: 100%;
227
+ background-color: var(--primary-color);
228
+ width: 0%;
229
+ transition: width 0.3s ease;
230
+ }
231
+
232
+ .progress-text {
233
+ display: flex;
234
+ justify-content: space-between;
235
+ font-size: 0.9rem;
236
+ color: #666;
237
+ }
238
+
239
+ .log-container {
240
+ margin-top: 2rem;
241
+ max-height: 300px;
242
+ overflow-y: auto;
243
+ border: 1px solid #eee;
244
+ border-radius: 8px;
245
+ padding: 1rem;
246
+ background-color: #fafafa;
247
+ display: none;
248
+ }
249
+
250
+ .log-entry {
251
+ padding: 0.5rem 0;
252
+ border-bottom: 1px solid #eee;
253
+ font-family: monospace;
254
+ font-size: 0.9rem;
255
+ }
256
+
257
+ .log-entry:last-child {
258
+ border-bottom: none;
259
+ }
260
+
261
+ .log-entry.success {
262
+ color: var(--success-color);
263
+ }
264
+
265
+ .log-entry.error {
266
+ color: var(--error-color);
267
+ }
268
+
269
+ .log-entry.warning {
270
+ color: #FF9500;
271
+ }
272
+
273
+ .sample-download {
274
+ text-align: center;
275
+ margin-top: 1.5rem;
276
+ }
277
+
278
+ .sample-link {
279
+ color: var(--secondary-color);
280
+ text-decoration: none;
281
+ font-weight: 600;
282
+ display: inline-flex;
283
+ align-items: center;
284
+ gap: 0.5rem;
285
+ }
286
+
287
+ .sample-link:hover {
288
+ text-decoration: underline;
289
+ }
290
+
291
+ .instructions {
292
+ background-color: #f9f9f9;
293
+ padding: 1.5rem;
294
+ border-radius: 8px;
295
+ margin-top: 2rem;
296
+ }
297
+
298
+ .instructions h3 {
299
+ color: var(--dark-color);
300
+ margin-bottom: 1rem;
301
+ }
302
+
303
+ .instructions ol {
304
+ padding-left: 1.5rem;
305
+ }
306
+
307
+ .instructions li {
308
+ margin-bottom: 0.5rem;
309
+ }
310
+
311
+ @media (max-width: 768px) {
312
+ .container {
313
+ margin: 1rem;
314
+ padding: 1.5rem;
315
+ }
316
+
317
+ .controls {
318
+ flex-direction: column;
319
+ gap: 1rem;
320
+ }
321
+
322
+ .btn {
323
+ width: 100%;
324
+ justify-content: center;
325
+ }
326
+ }
327
+ </style>
328
+ </head>
329
+ <body>
330
+ <div class="container">
331
+ <header>
332
+ <div class="logo">
333
+ <i class="fab fa-whatsapp"></i>
334
+ </div>
335
+ <h1>WhatsApp Message Automation</h1>
336
+ <p class="subtitle">Send personalized messages to students automatically</p>
337
+ </header>
338
+
339
+ <div class="upload-section" id="dropZone">
340
+ <div class="upload-icon">
341
+ <i class="fas fa-file-upload"></i>
342
+ </div>
343
+ <h3>Upload Student Data File</h3>
344
+ <p>Supported formats: CSV, XLSX (Excel)</p>
345
+ <input type="file" id="fileInput" class="file-input" accept=".csv,.xlsx,.xls">
346
+ <button class="upload-btn" id="uploadBtn">
347
+ <i class="fas fa-cloud-upload-alt"></i> Choose File
348
+ </button>
349
+ <div class="file-name" id="fileName">No file selected</div>
350
+ </div>
351
+
352
+ <div class="sample-download">
353
+ <a href="#" class="sample-link" id="downloadSample">
354
+ <i class="fas fa-download"></i> Download Sample File
355
+ </a>
356
+ </div>
357
+
358
+ <div class="form-group">
359
+ <label for="countryCode">Country Code</label>
360
+ <div class="country-code">
361
+ <select id="countryCode">
362
+ <option value="+20">Egypt (+20)</option>
363
+ <option value="+966">Saudi Arabia (+966)</option>
364
+ <option value="+971">UAE (+971)</option>
365
+ <option value="+962">Jordan (+962)</option>
366
+ <option value="+965">Kuwait (+965)</option>
367
+ <option value="+968">Oman (+968)</option>
368
+ <option value="+974">Qatar (+974)</option>
369
+ <option value="+973">Bahrain (+973)</option>
370
+ <option value="+212">Morocco (+212)</option>
371
+ <option value="+216">Tunisia (+216)</option>
372
+ <option value="+213">Algeria (+213)</option>
373
+ <option value="+1">USA/Canada (+1)</option>
374
+ <option value="+44">UK (+44)</option>
375
+ <option value="+91">India (+91)</option>
376
+ <option value="custom">Custom</option>
377
+ </select>
378
+ <input type="text" id="customCode" placeholder="Enter custom code" style="display: none;">
379
+ </div>
380
+ </div>
381
+
382
+ <div class="form-group">
383
+ <label for="messageTemplate">Message Template</label>
384
+ <textarea id="messageTemplate" placeholder="Enter your message template here. Use {name} where you want the student's name to appear.">مرحبًا {name}،
385
+
386
+ هذه رسالتك من إدارة المدرسة. نأمل أن تكون بصحة جيدة.
387
+
388
+ مع تحيات،
389
+ الإدارة</textarea>
390
+ <div class="message-preview">
391
+ <strong>Preview:</strong>
392
+ <div id="messagePreview">مرحبًا أحمد،
393
+
394
+ هذه رسالتك من إدارة المدرسة. نأمل أن تكون بصحة جيدة.
395
+
396
+ مع تحيات،
397
+ الإدارة</div>
398
+ </div>
399
+ </div>
400
+
401
+ <div class="form-group">
402
+ <label for="delay">Delay Between Messages (seconds)</label>
403
+ <select id="delay">
404
+ <option value="5">5 seconds (recommended)</option>
405
+ <option value="10">10 seconds (safer)</option>
406
+ <option value="20">20 seconds (very safe)</option>
407
+ <option value="30">30 seconds (most safe)</option>
408
+ <option value="60">1 minute</option>
409
+ <option value="custom">Custom</option>
410
+ </select>
411
+ <input type="number" id="customDelay" placeholder="Enter custom delay in seconds" min="5" style="display: none; margin-top: 0.5rem;" class="full-width">
412
+ </div>
413
+
414
+ <div class="controls">
415
+ <button class="btn btn-secondary" id="resetBtn">
416
+ <i class="fas fa-redo"></i> Reset
417
+ </button>
418
+ <button class="btn btn-primary" id="sendBtn" disabled>
419
+ <i class="fas fa-paper-plane"></i> Send Messages
420
+ </button>
421
+ </div>
422
+
423
+ <div class="progress-container" id="progressContainer">
424
+ <div class="progress-bar">
425
+ <div class="progress" id="progressBar"></div>
426
+ </div>
427
+ <div class="progress-text">
428
+ <span id="progressStatus">Ready</span>
429
+ <span id="progressCount">0/0</span>
430
+ </div>
431
+ </div>
432
+
433
+ <div class="log-container" id="logContainer">
434
+ <div class="log-entry">Logs will appear here...</div>
435
+ </div>
436
+
437
+ <div class="instructions">
438
+ <h3>How to Use This Tool</h3>
439
+ <ol>
440
+ <li>Prepare your student data file with columns for name and phone number (without country code)</li>
441
+ <li>Upload the file using the button above</li>
442
+ <li>Select the appropriate country code for the phone numbers</li>
443
+ <li>Compose your message template using {name} for personalization</li>
444
+ <li>Set a delay between messages to avoid being flagged as spam</li>
445
+ <li>Click "Send Messages" and wait for the process to complete</li>
446
+ <li>Monitor progress in the log section below</li>
447
+ </ol>
448
+ <p><strong>Note:</strong> You need to have WhatsApp Web open in your browser for this to work.</p>
449
+ </div>
450
+ </div>
451
+
452
+ <script>
453
+ document.addEventListener('DOMContentLoaded', function() {
454
+ // DOM elements
455
+ const fileInput = document.getElementById('fileInput');
456
+ const uploadBtn = document.getElementById('uploadBtn');
457
+ const fileName = document.getElementById('fileName');
458
+ const dropZone = document.getElementById('dropZone');
459
+ const countryCode = document.getElementById('countryCode');
460
+ const customCode = document.getElementById('customCode');
461
+ const messageTemplate = document.getElementById('messageTemplate');
462
+ const messagePreview = document.getElementById('messagePreview');
463
+ const delay = document.getElementById('delay');
464
+ const customDelay = document.getElementById('customDelay');
465
+ const sendBtn = document.getElementById('sendBtn');
466
+ const resetBtn = document.getElementById('resetBtn');
467
+ const progressContainer = document.getElementById('progressContainer');
468
+ const progressBar = document.getElementById('progressBar');
469
+ const progressStatus = document.getElementById('progressStatus');
470
+ const progressCount = document.getElementById('progressCount');
471
+ const logContainer = document.getElementById('logContainer');
472
+ const downloadSample = document.getElementById('downloadSample');
473
+
474
+ // File upload handling
475
+ uploadBtn.addEventListener('click', function() {
476
+ fileInput.click();
477
+ });
478
+
479
+ fileInput.addEventListener('change', function() {
480
+ if (fileInput.files.length > 0) {
481
+ fileName.textContent = fileInput.files[0].name;
482
+ sendBtn.disabled = false;
483
+ addLog(`File "${fileInput.files[0].name}" loaded successfully`, 'success');
484
+ } else {
485
+ fileName.textContent = 'No file selected';
486
+ sendBtn.disabled = true;
487
+ }
488
+ });
489
+
490
+ // Drag and drop functionality
491
+ ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
492
+ dropZone.addEventListener(eventName, preventDefaults, false);
493
+ });
494
+
495
+ function preventDefaults(e) {
496
+ e.preventDefault();
497
+ e.stopPropagation();
498
+ }
499
+
500
+ ['dragenter', 'dragover'].forEach(eventName => {
501
+ dropZone.addEventListener(eventName, highlight, false);
502
+ });
503
+
504
+ ['dragleave', 'drop'].forEach(eventName => {
505
+ dropZone.addEventListener(eventName, unhighlight, false);
506
+ });
507
+
508
+ function highlight() {
509
+ dropZone.style.borderColor = '#25D366';
510
+ dropZone.style.backgroundColor = 'rgba(37, 211, 102, 0.1)';
511
+ }
512
+
513
+ function unhighlight() {
514
+ dropZone.style.borderColor = '#ccc';
515
+ dropZone.style.backgroundColor = 'rgba(37, 211, 102, 0.05)';
516
+ }
517
+
518
+ dropZone.addEventListener('drop', handleDrop, false);
519
+
520
+ function handleDrop(e) {
521
+ const dt = e.dataTransfer;
522
+ const files = dt.files;
523
+
524
+ if (files.length > 0) {
525
+ fileInput.files = files;
526
+ fileName.textContent = files[0].name;
527
+ sendBtn.disabled = false;
528
+ addLog(`File "${files[0].name}" loaded successfully via drag & drop`, 'success');
529
+ }
530
+ }
531
+
532
+ // Country code handling
533
+ countryCode.addEventListener('change', function() {
534
+ if (countryCode.value === 'custom') {
535
+ customCode.style.display = 'block';
536
+ } else {
537
+ customCode.style.display = 'none';
538
+ }
539
+ });
540
+
541
+ // Message template preview
542
+ messageTemplate.addEventListener('input', updatePreview);
543
+
544
+ function updatePreview() {
545
+ const template = messageTemplate.value;
546
+ const preview = template.replace(/\{name\}/g, 'أحمد');
547
+ messagePreview.innerHTML = preview.replace(/\n/g, '<br>');
548
+ }
549
+
550
+ // Delay handling
551
+ delay.addEventListener('change', function() {
552
+ if (delay.value === 'custom') {
553
+ customDelay.style.display = 'block';
554
+ } else {
555
+ customDelay.style.display = 'none';
556
+ }
557
+ });
558
+
559
+ // Sample file download
560
+ downloadSample.addEventListener('click', function(e) {
561
+ e.preventDefault();
562
+ addLog('Downloading sample file...', 'warning');
563
+
564
+ // In a real implementation, this would link to an actual sample file
565
+ setTimeout(() => {
566
+ addLog('Sample file downloaded successfully', 'success');
567
+ }, 1000);
568
+ });
569
+
570
+ // Reset button
571
+ resetBtn.addEventListener('click', function() {
572
+ fileInput.value = '';
573
+ fileName.textContent = 'No file selected';
574
+ countryCode.value = '+20';
575
+ customCode.style.display = 'none';
576
+ customCode.value = '';
577
+ messageTemplate.value = 'مرحبًا {name}،\n\nهذه رسالتك من إدارة المدرسة. نأمل أن تكون بصحة جيدة.\n\nمع تحيات،\nالإدارة';
578
+ delay.value = '5';
579
+ customDelay.style.display = 'none';
580
+ customDelay.value = '';
581
+ sendBtn.disabled = true;
582
+ progressContainer.style.display = 'none';
583
+ logContainer.innerHTML = '<div class="log-entry">Logs cleared</div>';
584
+ logContainer.style.display = 'none';
585
+
586
+ updatePreview();
587
+ addLog('Form has been reset', 'warning');
588
+ });
589
+
590
+ // Send button
591
+ sendBtn.addEventListener('click', function() {
592
+ if (!fileInput.files.length) {
593
+ addLog('Error: No file selected', 'error');
594
+ return;
595
+ }
596
+
597
+ const selectedCountryCode = countryCode.value === 'custom' ? customCode.value : countryCode.value;
598
+ if (!selectedCountryCode) {
599
+ addLog('Error: Please select or enter a country code', 'error');
600
+ return;
601
+ }
602
+
603
+ const selectedDelay = delay.value === 'custom' ? parseInt(customDelay.value) : parseInt(delay.value);
604
+ if (isNaN(selectedDelay) || selectedDelay < 5) {
605
+ addLog('Error: Delay must be at least 5 seconds', 'error');
606
+ return;
607
+ }
608
+
609
+ if (!messageTemplate.value.includes('{name}')) {
610
+ addLog('Warning: Message template does not contain {name} placeholder', 'warning');
611
+ }
612
+
613
+ // Show progress container
614
+ progressContainer.style.display = 'block';
615
+ logContainer.style.display = 'block';
616
+
617
+ // Simulate sending process
618
+ simulateSending(selectedCountryCode, selectedDelay);
619
+ });
620
+
621
+ // Simulate sending messages (in a real app, this would connect to backend)
622
+ function simulateSending(countryCode, delay) {
623
+ const totalStudents = 25; // Simulated number of students
624
+ let sentCount = 0;
625
+
626
+ progressStatus.textContent = 'Sending messages...';
627
+ progressCount.textContent = `0/${totalStudents}`;
628
+
629
+ addLog(`Starting to send messages with country code ${countryCode} and ${delay} second delay`, 'warning');
630
+
631
+ const interval = setInterval(() => {
632
+ sentCount++;
633
+ const progressPercent = (sentCount / totalStudents) * 100;
634
+ progressBar.style.width = `${progressPercent}%`;
635
+ progressCount.textContent = `${sentCount}/${totalStudents}`;
636
+
637
+ // Simulate success or failure randomly
638
+ const isSuccess = Math.random() > 0.1;
639
+
640
+ if (isSuccess) {
641
+ addLog(`Message sent successfully to student ${sentCount}`, 'success');
642
+ } else {
643
+ addLog(`Failed to send message to student ${sentCount} (simulated error)`, 'error');
644
+ }
645
+
646
+ if (sentCount >= totalStudents) {
647
+ clearInterval(interval);
648
+ progressStatus.textContent = 'Completed';
649
+ addLog('All messages processed!', 'success');
650
+ sendBtn.disabled = true;
651
+ }
652
+ }, delay * 1000);
653
+ }
654
+
655
+ // Add log entry
656
+ function addLog(message, type = '') {
657
+ const logEntry = document.createElement('div');
658
+ logEntry.className = `log-entry ${type}`;
659
+
660
+ const timestamp = new Date().toLocaleTimeString();
661
+ logEntry.textContent = `[${timestamp}] ${message}`;
662
+
663
+ // If first entry is the placeholder, remove it
664
+ if (logContainer.firstChild.textContent === 'Logs will appear here...') {
665
+ logContainer.innerHTML = '';
666
+ }
667
+
668
+ logContainer.appendChild(logEntry);
669
+ logContainer.scrollTop = logContainer.scrollHeight;
670
+ }
671
+
672
+ // Initialize
673
+ updatePreview();
674
+ });
675
+ </script>
676
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <a href="https://enzostvs-deepsite.hf.space" style="color: #fff;" target="_blank" >DeepSite</a> <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;"></p></body>
677
+ </html>