melassy commited on
Commit
cdcf27a
·
verified ·
1 Parent(s): 8f2cec5

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +6 -4
  2. index.html +735 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Api Whats App
3
- emoji: 🚀
4
  colorFrom: blue
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: api-whats-app
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,735 @@
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="ar" dir="rtl">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>نظام إرسال رسائل الواتساب للطلاب</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
+ --accent-color: #34B7F1;
13
+ --text-color: #333;
14
+ --light-bg: #f5f5f5;
15
+ --white: #ffffff;
16
+ --error-color: #ff4444;
17
+ --success-color: #00C851;
18
+ }
19
+
20
+ * {
21
+ box-sizing: border-box;
22
+ margin: 0;
23
+ padding: 0;
24
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
25
+ }
26
+
27
+ body {
28
+ background-color: var(--light-bg);
29
+ color: var(--text-color);
30
+ line-height: 1.6;
31
+ }
32
+
33
+ .container {
34
+ max-width: 1000px;
35
+ margin: 0 auto;
36
+ padding: 20px;
37
+ }
38
+
39
+ header {
40
+ background-color: var(--secondary-color);
41
+ color: var(--white);
42
+ padding: 20px 0;
43
+ text-align: center;
44
+ border-radius: 10px 10px 0 0;
45
+ margin-bottom: 30px;
46
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
47
+ }
48
+
49
+ header h1 {
50
+ font-size: 28px;
51
+ margin-bottom: 10px;
52
+ }
53
+
54
+ header p {
55
+ font-size: 16px;
56
+ opacity: 0.9;
57
+ }
58
+
59
+ .app-logo {
60
+ font-size: 40px;
61
+ margin-bottom: 15px;
62
+ color: var(--white);
63
+ }
64
+
65
+ .main-container {
66
+ background-color: var(--white);
67
+ border-radius: 10px;
68
+ padding: 30px;
69
+ box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
70
+ }
71
+
72
+ .upload-section {
73
+ margin-bottom: 30px;
74
+ border-bottom: 1px solid #eee;
75
+ padding-bottom: 30px;
76
+ }
77
+
78
+ .upload-container {
79
+ border: 2px dashed #ccc;
80
+ padding: 30px;
81
+ text-align: center;
82
+ border-radius: 8px;
83
+ transition: all 0.3s;
84
+ background-color: var(--light-bg);
85
+ }
86
+
87
+ .upload-container:hover {
88
+ border-color: var(--accent-color);
89
+ background-color: rgba(52, 183, 241, 0.05);
90
+ }
91
+
92
+ .upload-container i {
93
+ font-size: 48px;
94
+ color: var(--accent-color);
95
+ margin-bottom: 15px;
96
+ }
97
+
98
+ .upload-container p {
99
+ margin-bottom: 20px;
100
+ color: #666;
101
+ }
102
+
103
+ .btn {
104
+ background-color: var(--primary-color);
105
+ color: var(--white);
106
+ border: none;
107
+ padding: 12px 25px;
108
+ border-radius: 50px;
109
+ cursor: pointer;
110
+ font-size: 16px;
111
+ font-weight: 600;
112
+ transition: all 0.3s;
113
+ display: inline-flex;
114
+ align-items: center;
115
+ justify-content: center;
116
+ }
117
+
118
+ .btn:hover {
119
+ background-color: var(--secondary-color);
120
+ transform: translateY(-2px);
121
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
122
+ }
123
+
124
+ .btn i {
125
+ margin-left: 8px;
126
+ }
127
+
128
+ .btn-secondary {
129
+ background-color: #6c757d;
130
+ }
131
+
132
+ .btn-secondary:hover {
133
+ background-color: #5a6268;
134
+ }
135
+
136
+ .form-group {
137
+ margin-bottom: 25px;
138
+ }
139
+
140
+ .form-group label {
141
+ display: block;
142
+ margin-bottom: 8px;
143
+ font-weight: 600;
144
+ color: var(--text-color);
145
+ }
146
+
147
+ .form-control {
148
+ width: 100%;
149
+ padding: 12px 15px;
150
+ border: 1px solid #ddd;
151
+ border-radius: 6px;
152
+ font-size: 16px;
153
+ transition: border 0.3s;
154
+ }
155
+
156
+ .form-control:focus {
157
+ border-color: var(--accent-color);
158
+ outline: none;
159
+ box-shadow: 0 0 0 3px rgba(52, 183, 241, 0.2);
160
+ }
161
+
162
+ textarea.form-control {
163
+ min-height: 120px;
164
+ resize: vertical;
165
+ }
166
+
167
+ .preview-section {
168
+ background-color: var(--light-bg);
169
+ padding: 20px;
170
+ border-radius: 8px;
171
+ margin-top: 30px;
172
+ border: 1px solid #eee;
173
+ }
174
+
175
+ .preview-header {
176
+ display: flex;
177
+ justify-content: space-between;
178
+ align-items: center;
179
+ margin-bottom: 15px;
180
+ }
181
+
182
+ .preview-content {
183
+ background-color: var(--white);
184
+ padding: 15px;
185
+ border-radius: 8px;
186
+ border: 1px solid #ddd;
187
+ max-height: 300px;
188
+ overflow-y: auto;
189
+ }
190
+
191
+ .student-list {
192
+ list-style: none;
193
+ }
194
+
195
+ .student-item {
196
+ padding: 12px 15px;
197
+ border-bottom: 1px solid #eee;
198
+ display: flex;
199
+ justify-content: space-between;
200
+ align-items: center;
201
+ }
202
+
203
+ .student-item:last-child {
204
+ border-bottom: none;
205
+ }
206
+
207
+ .send-section {
208
+ margin-top: 40px;
209
+ text-align: center;
210
+ }
211
+
212
+ .send-btn {
213
+ padding: 15px 40px;
214
+ font-size: 18px;
215
+ }
216
+
217
+ .modal {
218
+ display: none;
219
+ position: fixed;
220
+ top: 0;
221
+ left: 0;
222
+ width: 100%;
223
+ height: 100%;
224
+ background-color: rgba(0, 0, 0, 0.5);
225
+ z-index: 1000;
226
+ justify-content: center;
227
+ align-items: center;
228
+ }
229
+
230
+ .modal-content {
231
+ background-color: var(--white);
232
+ padding: 30px;
233
+ border-radius: 10px;
234
+ width: 90%;
235
+ max-width: 500px;
236
+ max-height: 80vh;
237
+ overflow-y: auto;
238
+ }
239
+
240
+ .modal-header {
241
+ display: flex;
242
+ justify-content: space-between;
243
+ align-items: center;
244
+ margin-bottom: 20px;
245
+ }
246
+
247
+ .modal-title {
248
+ font-size: 20px;
249
+ font-weight: 600;
250
+ }
251
+
252
+ .close-modal {
253
+ background: none;
254
+ border: none;
255
+ font-size: 24px;
256
+ cursor: pointer;
257
+ color: #666;
258
+ }
259
+
260
+ .progress-container {
261
+ margin: 20px 0;
262
+ }
263
+
264
+ .progress-bar {
265
+ height: 10px;
266
+ background-color: #eee;
267
+ border-radius: 5px;
268
+ overflow: hidden;
269
+ }
270
+
271
+ .progress {
272
+ height: 100%;
273
+ background-color: var(--primary-color);
274
+ width: 0;
275
+ transition: width 0.3s;
276
+ }
277
+
278
+ .status-message {
279
+ text-align: center;
280
+ margin: 15px 0;
281
+ font-size: 14px;
282
+ color: #666;
283
+ }
284
+
285
+ .error {
286
+ color: var(--error-color);
287
+ }
288
+
289
+ .success {
290
+ color: var(--success-color);
291
+ }
292
+
293
+ .template-tags {
294
+ display: flex;
295
+ flex-wrap: wrap;
296
+ gap: 8px;
297
+ margin-top: 10px;
298
+ }
299
+
300
+ .tag {
301
+ background-color: var(--light-bg);
302
+ padding: 5px 10px;
303
+ border-radius: 4px;
304
+ font-size: 14px;
305
+ cursor: pointer;
306
+ border: 1px solid #ddd;
307
+ transition: all 0.2s;
308
+ }
309
+
310
+ .tag:hover {
311
+ background-color: var(--accent-color);
312
+ color: var(--white);
313
+ }
314
+
315
+ @media (max-width: 768px) {
316
+ .container {
317
+ padding: 15px;
318
+ }
319
+
320
+ .main-container {
321
+ padding: 20px;
322
+ }
323
+
324
+ .upload-container {
325
+ padding: 20px 15px;
326
+ }
327
+
328
+ .btn {
329
+ padding: 10px 20px;
330
+ font-size: 14px;
331
+ }
332
+ }
333
+ </style>
334
+ </head>
335
+ <body>
336
+ <header>
337
+ <div class="container">
338
+ <div class="app-logo">
339
+ <i class="fab fa-whatsapp"></i>
340
+ </div>
341
+ <h1>نظام إرسال رسائل الواتساب للطلاب</h1>
342
+ <p>أرسل رسائل مخصصة للطلاب بسهولة وبشكل آلي</p>
343
+ </div>
344
+ </header>
345
+
346
+ <div class="container">
347
+ <div class="main-container">
348
+ <section class="upload-section">
349
+ <h2><i class="fas fa-file-upload"></i> تحميل ملف الطلاب</h2>
350
+ <div class="upload-container" id="uploadContainer">
351
+ <i class="fas fa-file-excel"></i>
352
+ <p>قم بسحب وإسقاط ملف Excel هنا أو انقر لاختيار الملف</p>
353
+ <input type="file" id="fileInput" accept=".xlsx,.xls,.csv" style="display: none;">
354
+ <button class="btn" id="selectFileBtn">
355
+ <i class="fas fa-folder-open"></i> اختر ملف
356
+ </button>
357
+ </div>
358
+ <div id="fileInfo" style="margin-top: 15px; display: none;">
359
+ <div class="file-details" style="display: flex; align-items: center;">
360
+ <i class="fas fa-file-excel" style="color: var(--success-color); font-size: 24px; margin-left: 10px;"></i>
361
+ <div>
362
+ <p style="font-weight: 600; margin-bottom: 5px;" id="fileName"></p>
363
+ <p style="color: #666; font-size: 14px;" id="fileSize"></p>
364
+ </div>
365
+ <button id="clearFileBtn" style="background: none; border: none; margin-right: auto; color: var(--error-color); cursor: pointer;">
366
+ <i class="fas fa-times"></i>
367
+ </button>
368
+ </div>
369
+ </div>
370
+ </section>
371
+
372
+ <section class="message-section">
373
+ <h2><i class="fas fa-comment-alt"></i> تكوين الرسالة</h2>
374
+ <div class="form-group">
375
+ <label for="messageTemplate">نموذج الرسالة</label>
376
+ <textarea id="messageTemplate" class="form-control" placeholder="عزيزي {اسم الطالب}، نود إعلامك بأن... الرابط: {الرابط}"></textarea>
377
+ <div class="template-tags">
378
+ <span class="tag" data-tag="{اسم الطالب}">{اسم الطالب}</span>
379
+ <span class="tag" data-tag="{الرابط}">{الرابط}</span>
380
+ <span class="tag" data-tag="{الرقم}">{الرقم}</span>
381
+ <span class="tag" data-tag="{التاريخ}">{التاريخ}</span>
382
+ </div>
383
+ </div>
384
+
385
+ <div class="form-group">
386
+ <label for="customLink">رابط مخصص (اختياري)</label>
387
+ <input type="url" id="customLink" class="form-control" placeholder="https://example.com">
388
+ </div>
389
+
390
+ <div class="preview-section">
391
+ <div class="preview-header">
392
+ <h3><i class="fas fa-eye"></i> معاينة الرسائل</h3>
393
+ </div>
394
+ <div class="preview-content">
395
+ <p id="previewMessage">سيتم عرض معاينة الرسائل هنا بعد تحميل الملف وإدخال نموذج الرسالة.</p>
396
+ <ul class="student-list" id="studentList" style="display: none;"></ul>
397
+ </div>
398
+ </div>
399
+ </section>
400
+
401
+ <section class="send-section">
402
+ <button class="btn send-btn" id="sendMessagesBtn" disabled>
403
+ <i class="fab fa-whatsapp"></i> إرسال الرسائل
404
+ </button>
405
+ </section>
406
+ </div>
407
+ </div>
408
+
409
+ <!-- Progress Modal -->
410
+ <div class="modal" id="progressModal">
411
+ <div class="modal-content">
412
+ <div class="modal-header">
413
+ <h3 class="modal-title"><i class="fas fa-paper-plane"></i> جارٍ إرسال الرسائل</h3>
414
+ <button class="close-modal" id="closeModalBtn">&times;</button>
415
+ </div>
416
+
417
+ <div class="progress-container">
418
+ <div class="progress-bar">
419
+ <div class="progress" id="progressBar"></div>
420
+ </div>
421
+ <div class="status-message" id="statusMessage">
422
+ جاهز للبدء...
423
+ </div>
424
+ </div>
425
+
426
+ <div style="text-align: center;">
427
+ <button class="btn btn-secondary" id="cancelSendingBtn">
428
+ <i class="fas fa-stop"></i> إلغاء العملية
429
+ </button>
430
+ </div>
431
+ </div>
432
+ </div>
433
+
434
+ <!-- Success Modal -->
435
+ <div class="modal" id="successModal">
436
+ <div class="modal-content">
437
+ <div style="text-align: center; margin: 20px 0;">
438
+ <i class="fas fa-check-circle" style="font-size: 60px; color: var(--success-color);"></i>
439
+ <h3 style="margin-top: 15px;">تم إرسال الرسائل بنجاح!</h3>
440
+ </div>
441
+
442
+ <div style="margin: 20px 0; text-align: center;">
443
+ <p id="successMessage"></p>
444
+ </div>
445
+
446
+ <div style="text-align: center;">
447
+ <button class="btn" id="okSuccessBtn">
448
+ <i class="fas fa-check"></i> حسناً
449
+ </button>
450
+ </div>
451
+ </div>
452
+ </div>
453
+
454
+ <script>
455
+ document.addEventListener('DOMContentLoaded', function() {
456
+ // DOM Elements
457
+ const uploadContainer = document.getElementById('uploadContainer');
458
+ const fileInput = document.getElementById('fileInput');
459
+ const selectFileBtn = document.getElementById('selectFileBtn');
460
+ const fileInfo = document.getElementById('fileInfo');
461
+ const fileName = document.getElementById('fileName');
462
+ const fileSize = document.getElementById('fileSize');
463
+ const clearFileBtn = document.getElementById('clearFileBtn');
464
+ const messageTemplate = document.getElementById('messageTemplate');
465
+ const customLink = document.getElementById('customLink');
466
+ const previewMessage = document.getElementById('previewMessage');
467
+ const studentList = document.getElementById('studentList');
468
+ const sendMessagesBtn = document.getElementById('sendMessagesBtn');
469
+ const progressModal = document.getElementById('progressModal');
470
+ const progressBar = document.getElementById('progressBar');
471
+ const statusMessage = document.getElementById('statusMessage');
472
+ const closeModalBtn = document.getElementById('closeModalBtn');
473
+ const cancelSendingBtn = document.getElementById('cancelSendingBtn');
474
+ const successModal = document.getElementById('successModal');
475
+ const successMessage = document.getElementById('successMessage');
476
+ const okSuccessBtn = document.getElementById('okSuccessBtn');
477
+
478
+ // Variables
479
+ let studentsData = [];
480
+ let sendingProcess = null;
481
+
482
+ // Event Listeners
483
+ selectFileBtn.addEventListener('click', function() {
484
+ fileInput.click();
485
+ });
486
+
487
+ uploadContainer.addEventListener('dragover', function(e) {
488
+ e.preventDefault();
489
+ uploadContainer.style.borderColor = var('--accent-color');
490
+ uploadContainer.style.backgroundColor = 'rgba(52, 183, 241, 0.1)';
491
+ });
492
+
493
+ uploadContainer.addEventListener('dragleave', function() {
494
+ uploadContainer.style.borderColor = '#ccc';
495
+ uploadContainer.style.backgroundColor = 'var(--light-bg)';
496
+ });
497
+
498
+ uploadContainer.addEventListener('drop', function(e) {
499
+ e.preventDefault();
500
+ uploadContainer.style.borderColor = '#ccc';
501
+ uploadContainer.style.backgroundColor = 'var(--light-bg)';
502
+
503
+ if (e.dataTransfer.files.length) {
504
+ fileInput.files = e.dataTransfer.files;
505
+ handleFileUpload();
506
+ }
507
+ });
508
+
509
+ fileInput.addEventListener('change', handleFileUpload);
510
+
511
+ clearFileBtn.addEventListener('click', function() {
512
+ fileInput.value = '';
513
+ fileInfo.style.display = 'none';
514
+ studentsData = [];
515
+ updatePreview();
516
+ updateSendButtonState();
517
+ });
518
+
519
+ messageTemplate.addEventListener('input', function() {
520
+ updatePreview();
521
+ });
522
+
523
+ customLink.addEventListener('input', function() {
524
+ updatePreview();
525
+ });
526
+
527
+ sendMessagesBtn.addEventListener('click', startSendingProcess);
528
+
529
+ closeModalBtn.addEventListener('click', function() {
530
+ progressModal.style.display = 'none';
531
+ });
532
+
533
+ cancelSendingBtn.addEventListener('click', function() {
534
+ if (sendingProcess) {
535
+ clearInterval(sendingProcess);
536
+ statusMessage.innerHTML = '<span class="error">تم إيقاف عملية الإرسال</span>';
537
+ cancelSendingBtn.disabled = true;
538
+ }
539
+ });
540
+
541
+ okSuccessBtn.addEventListener('click', function() {
542
+ successModal.style.display = 'none';
543
+ });
544
+
545
+ // Add event listeners for template tags
546
+ document.querySelectorAll('.tag').forEach(tag => {
547
+ tag.addEventListener('click', function() {
548
+ const tagValue = this.getAttribute('data-tag');
549
+ insertAtCursor(messageTemplate, tagValue);
550
+ messageTemplate.focus();
551
+ });
552
+ });
553
+
554
+ // Functions
555
+ function handleFileUpload() {
556
+ const file = fileInput.files[0];
557
+ if (!file) return;
558
+
559
+ // Simulate file processing (in a real app, you'd use SheetJS or similar)
560
+ setTimeout(() => {
561
+ studentsData = generateSampleData();
562
+
563
+ fileName.textContent = file.name;
564
+ fileSize.textContent = formatFileSize(file.size);
565
+ fileInfo.style.display = 'block';
566
+
567
+ updatePreview();
568
+ updateSendButtonState();
569
+ }, 500);
570
+ }
571
+
572
+ function generateSampleData() {
573
+ // In a real app, you would parse the actual Excel file
574
+ const mockData = [];
575
+ const names = [
576
+ "أحمد محمد", "فاطمة علي", "يوسف إبراهيم",
577
+ "سارة خالد", "محمد حسن", "نورا عبدالله",
578
+ "عمر كمال", "لمى سعيد", "خالد وليد",
579
+ "هناء مصطفى", "حسين رضا", "آية محمود"
580
+ ];
581
+
582
+ for (let i = 0; i < 12; i++) {
583
+ mockData.push({
584
+ name: names[i],
585
+ phone: `9665${Math.floor(10000000 + Math.random() * 90000000)}`
586
+ });
587
+ }
588
+
589
+ return mockData;
590
+ }
591
+
592
+ function formatFileSize(bytes) {
593
+ if (bytes === 0) return '0 Bytes';
594
+ const k = 1024;
595
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
596
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
597
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i];
598
+ }
599
+
600
+ function updatePreview() {
601
+ if (studentsData.length === 0) {
602
+ studentList.style.display = 'none';
603
+ previewMessage.style.display = 'block';
604
+ previewMessage.textContent = 'سيتم عرض معاينة الرسائل هنا بعد تحميل الملف وإدخال نموذج الرسالة.';
605
+ return;
606
+ }
607
+
608
+ let message = messageTemplate.value;
609
+ if (!message) {
610
+ studentList.style.display = 'none';
611
+ previewMessage.style.display = 'block';
612
+ previewMessage.textContent = 'الرجاء إدخال نموذج الرسالة لمعاينة الرسائل.';
613
+ return;
614
+ }
615
+
616
+ studentList.innerHTML = '';
617
+ previewMessage.style.display = 'none';
618
+ studentList.style.display = 'block';
619
+
620
+ // Show preview for first 3 students
621
+ const previewCount = Math.min(3, studentsData.length);
622
+ for (let i = 0; i < previewCount; i++) {
623
+ const student = studentsData[i];
624
+ const link = customLink.value || '{الرابط}';
625
+ const processedMessage = processMessage(message, student.name, link);
626
+
627
+ const li = document.createElement('li');
628
+ li.className = 'student-item';
629
+ li.innerHTML = `
630
+ <div style="flex: 1;">
631
+ <strong>${student.name}</strong>
632
+ <div style="font-size: 12px; color: #666; margin-top: 4px;">${student.phone}</div>
633
+ </div>
634
+ <div style="max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
635
+ ${processedMessage}
636
+ </div>
637
+ `;
638
+ studentList.appendChild(li);
639
+ }
640
+
641
+ if (studentsData.length > 3) {
642
+ const li = document.createElement('li');
643
+ li.className = 'student-item';
644
+ li.style.textAlign = 'center';
645
+ li.style.color = '#666';
646
+ li.textContent = `و ${studentsData.length - 3} طلاب آخرين...`;
647
+ studentList.appendChild(li);
648
+ }
649
+ }
650
+
651
+ function processMessage(template, name, link) {
652
+ const today = new Date();
653
+ const dateStr = `${today.getDate()}/${today.getMonth() + 1}/${today.getFullYear()}`;
654
+
655
+ return template
656
+ .replace(/{اسم الطالب}/g, name)
657
+ .replace(/{الرابط}/g, link)
658
+ .replace(/{الرقم}/g, '+9665XXXXXX')
659
+ .replace(/{التاريخ}/g, dateStr);
660
+ }
661
+
662
+ function updateSendButtonState() {
663
+ sendMessagesBtn.disabled = studentsData.length === 0 || !messageTemplate.value;
664
+ }
665
+
666
+ function insertAtCursor(textarea, text) {
667
+ const startPos = textarea.selectionStart;
668
+ const endPos = textarea.selectionEnd;
669
+ const beforeText = textarea.value.substring(0, startPos);
670
+ const afterText = textarea.value.substring(endPos, textarea.value.length);
671
+
672
+ textarea.value = beforeText + text + afterText;
673
+ textarea.selectionStart = startPos + text.length;
674
+ textarea.selectionEnd = startPos + text.length;
675
+ textarea.focus();
676
+
677
+ // Trigger input event to update preview
678
+ const event = new Event('input', { bubbles: true });
679
+ textarea.dispatchEvent(event);
680
+ }
681
+
682
+ function startSendingProcess() {
683
+ progressModal.style.display = 'flex';
684
+ progressBar.style.width = '0%';
685
+ cancelSendingBtn.disabled = false;
686
+
687
+ let progress = 0;
688
+ const totalStudents = studentsData.length;
689
+ const link = customLink.value || '{الرابط}';
690
+
691
+ sendingProcess = setInterval(() => {
692
+ if (progress >= totalStudents) {
693
+ clearInterval(sendingProcess);
694
+ sendingProcess = null;
695
+
696
+ // Show success message
697
+ progressModal.style.display = 'none';
698
+ successMessage.textContent = `تم إرسال ${totalStudents} رسالة بنجاح إلى الطلاب.`;
699
+ successModal.style.display = 'flex';
700
+ return;
701
+ }
702
+
703
+ progress++;
704
+ const percent = Math.round((progress / totalStudents) * 100);
705
+ progressBar.style.width = `${percent}%`;
706
+
707
+ // Simulate sending message (in a real app, you would send via WhatsApp API)
708
+ const currentStudent = studentsData[progress - 1];
709
+ const message = processMessage(messageTemplate.value, currentStudent.name, link);
710
+
711
+ statusMessage.innerHTML = `جاري إرسال الرسالة إلى <strong>${currentStudent.name}</strong>...`;
712
+
713
+ // Randomly simulate failures (for demo purposes)
714
+ if (Math.random() < 0.1 && progress < totalStudents) {
715
+ setTimeout(() => {
716
+ statusMessage.innerHTML = `<span class="error">فشل إرسال الرسالة إلى ${currentStudent.name} - سيتم إعادة المحاولة...</span>`;
717
+ progress--; // Retry this one
718
+ }, 1500);
719
+ }
720
+ }, 1500);
721
+ }
722
+
723
+ // Handle clicks outside modal to close it
724
+ window.addEventListener('click', function(event) {
725
+ if (event.target === progressModal) {
726
+ progressModal.style.display = 'none';
727
+ }
728
+ if (event.target === successModal) {
729
+ successModal.style.display = 'none';
730
+ }
731
+ });
732
+ });
733
+ </script>
734
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: absolute; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">This website has been generated by <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>
735
+ </html>