moha77edhassan commited on
Commit
2d8ab1b
·
verified ·
1 Parent(s): aa58534

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +677 -19
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="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
+ <!-- استيراد خط Cairo و مكتبة أيقونات FontAwesome -->
8
+ <link href="https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700&display=swap" rel="stylesheet">
9
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
10
+
11
+ <style>
12
+ /*
13
+ * إعدادات المتغيرات والألوان (Color Palette)
14
+ * تصميم Minimal بألوان هادئة (بنفسجي فاتح وأبيض)
15
+ */
16
+ :root {
17
+ --primary-color: #6c5ce7; /* بنفسجي رئيسي */
18
+ --primary-hover: #5649c0; /* لون التفاعل */
19
+ --bg-color: #f3f4f6; /* خلفية الصفحة */
20
+ --card-bg: #ffffff; /* خلفية البطاقة */
21
+ --text-main: #2d3436; /* النص الأساسي */
22
+ --text-secondary: #636e72; /* النص الثانوي */
23
+ --danger-color: #ff7675; /* لون الحذف */
24
+ --shadow-sm: 0 2px 5px rgba(0,0,0,0.05);
25
+ --shadow-md: 0 5px 15px rgba(0,0,0,0.08);
26
+ --radius: 16px; /* حواف دائرية */
27
+ --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
28
+ }
29
+
30
+ * {
31
+ box-sizing: border-box;
32
+ margin: 0;
33
+ padding: 0;
34
+ outline: none;
35
+ }
36
+
37
+ body {
38
+ font-family: 'Cairo', system-ui, -apple-system, sans-serif;
39
+ background-color: var(--bg-color);
40
+ color: var(--text-main);
41
+ line-height: 1.6;
42
+ min-height: 100vh;
43
+ display: flex;
44
+ flex-direction: column;
45
+ }
46
+
47
+ /* --- الهيدر وشريط البحث --- */
48
+ header {
49
+ background: var(--card-bg);
50
+ padding: 1.5rem 2rem;
51
+ box-shadow: var(--shadow-sm);
52
+ position: sticky;
53
+ top: 0;
54
+ z-index: 100;
55
+ backdrop-filter: blur(10px);
56
+ background: rgba(255, 255, 255, 0.9);
57
+ }
58
+
59
+ .header-content {
60
+ max-width: 1200px;
61
+ margin: 0 auto;
62
+ display: flex;
63
+ flex-wrap: wrap;
64
+ justify-content: space-between;
65
+ align-items: center;
66
+ gap: 1rem;
67
+ }
68
+
69
+ .logo {
70
+ font-size: 1.8rem;
71
+ font-weight: 700;
72
+ color: var(--primary-color);
73
+ display: flex;
74
+ align-items: center;
75
+ gap: 0.5rem;
76
+ }
77
+
78
+ .search-container {
79
+ position: relative;
80
+ flex-grow: 1;
81
+ max-width: 400px;
82
+ }
83
+
84
+ .search-input {
85
+ width: 100%;
86
+ padding: 0.8rem 1rem 0.8rem 2.5rem;
87
+ border: 2px solid #e0e0e0;
88
+ border-radius: 50px;
89
+ font-family: inherit;
90
+ font-size: 1rem;
91
+ transition: var(--transition);
92
+ }
93
+
94
+ .search-input:focus {
95
+ border-color: var(--primary-color);
96
+ box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.1);
97
+ }
98
+
99
+ .search-icon {
100
+ position: absolute;
101
+ left: 15px;
102
+ top: 50%;
103
+ transform: translateY(-50%);
104
+ color: var(--text-secondary);
105
+ }
106
+
107
+ .actions {
108
+ display: flex;
109
+ gap: 10px;
110
+ }
111
+
112
+ .btn {
113
+ padding: 0.6rem 1.2rem;
114
+ border: none;
115
+ border-radius: 12px;
116
+ cursor: pointer;
117
+ font-family: inherit;
118
+ font-weight: 600;
119
+ display: flex;
120
+ align-items: center;
121
+ gap: 0.5rem;
122
+ transition: var(--transition);
123
+ font-size: 0.9rem;
124
+ }
125
+
126
+ .btn-primary {
127
+ background-color: var(--primary-color);
128
+ color: white;
129
+ box-shadow: 0 4px 10px rgba(108, 92, 231, 0.3);
130
+ }
131
+
132
+ .btn-primary:hover {
133
+ background-color: var(--primary-hover);
134
+ transform: translateY(-2px);
135
+ }
136
+
137
+ .btn-danger {
138
+ background-color: #fff0f0;
139
+ color: var(--danger-color);
140
+ border: 1px solid #ffe0e0;
141
+ }
142
+
143
+ .btn-danger:hover {
144
+ background-color: var(--danger-color);
145
+ color: white;
146
+ }
147
+
148
+ /* --- حاوية الملاحظات (Grid) --- */
149
+ .container {
150
+ max-width: 1200px;
151
+ margin: 2rem auto;
152
+ padding: 0 1.5rem;
153
+ flex-grow: 1;
154
+ width: 100%;
155
+ }
156
+
157
+ .notes-grid {
158
+ display: grid;
159
+ grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
160
+ gap: 1.5rem;
161
+ }
162
+
163
+ /* --- بطاقة الملاحظة --- */
164
+ .note-card {
165
+ background: var(--card-bg);
166
+ border-radius: var(--radius);
167
+ padding: 1.5rem;
168
+ box-shadow: var(--shadow-sm);
169
+ transition: var(--transition);
170
+ position: relative;
171
+ display: flex;
172
+ flex-direction: column;
173
+ border: 1px solid transparent;
174
+ animation: fadeIn 0.4s ease-out forwards;
175
+ }
176
+
177
+ @keyframes fadeIn {
178
+ from { opacity: 0; transform: translateY(20px); }
179
+ to { opacity: 1; transform: translateY(0); }
180
+ }
181
+
182
+ .note-card:hover {
183
+ transform: translateY(-5px);
184
+ box-shadow: var(--shadow-md);
185
+ border-color: rgba(108, 92, 231, 0.1);
186
+ }
187
+
188
+ .note-header {
189
+ display: flex;
190
+ justify-content: space-between;
191
+ align-items: flex-start;
192
+ margin-bottom: 1rem;
193
+ }
194
+
195
+ .note-title {
196
+ font-size: 1.2rem;
197
+ font-weight: 700;
198
+ color: var(--text-main);
199
+ word-break: break-word;
200
+ }
201
+
202
+ .note-date {
203
+ font-size: 0.75rem;
204
+ color: var(--text-secondary);
205
+ background: #f0f0f0;
206
+ padding: 0.2rem 0.6rem;
207
+ border-radius: 20px;
208
+ white-space: nowrap;
209
+ }
210
+
211
+ .note-content {
212
+ color: var(--text-secondary);
213
+ font-size: 0.95rem;
214
+ margin-bottom: 1.5rem;
215
+ white-space: pre-wrap; /* للحفاظ على الأسطر الجديدة */
216
+ display: -webkit-box;
217
+ -webkit-line-clamp: 5; /* عرض 5 أسطر فقط */
218
+ -webkit-box-orient: vertical;
219
+ overflow: hidden;
220
+ flex-grow: 1;
221
+ }
222
+
223
+ .note-actions {
224
+ display: flex;
225
+ justify-content: flex-end;
226
+ gap: 0.5rem;
227
+ border-top: 1px solid #f0f0f0;
228
+ padding-top: 1rem;
229
+ }
230
+
231
+ .icon-btn {
232
+ background: none;
233
+ border: none;
234
+ cursor: pointer;
235
+ font-size: 1rem;
236
+ padding: 0.5rem;
237
+ border-radius: 8px;
238
+ transition: var(--transition);
239
+ color: var(--text-secondary);
240
+ }
241
+
242
+ .icon-btn:hover {
243
+ background-color: #f3f4f6;
244
+ color: var(--primary-color);
245
+ }
246
+
247
+ .icon-btn.delete:hover {
248
+ color: var(--danger-color);
249
+ background-color: #fff0f0;
250
+ }
251
+
252
+ /* --- حالة عدم وجود ملاحظات --- */
253
+ .empty-state {
254
+ text-align: center;
255
+ padding: 4rem 1rem;
256
+ color: var(--text-secondary);
257
+ display: none; /* مخفي افتراضياً */
258
+ }
259
+
260
+ .empty-state i {
261
+ font-size: 4rem;
262
+ color: #dfe6e9;
263
+ margin-bottom: 1rem;
264
+ }
265
+
266
+ .empty-state h3 {
267
+ font-size: 1.5rem;
268
+ margin-bottom: 0.5rem;
269
+ color: var(--text-main);
270
+ }
271
+
272
+ /* --- النافذة المنبثقة (Modal) --- */
273
+ .modal-overlay {
274
+ position: fixed;
275
+ top: 0;
276
+ left: 0;
277
+ width: 100%;
278
+ height: 100%;
279
+ background: rgba(0, 0, 0, 0.5);
280
+ backdrop-filter: blur(5px);
281
+ display: flex;
282
+ justify-content: center;
283
+ align-items: center;
284
+ z-index: 1000;
285
+ opacity: 0;
286
+ visibility: hidden;
287
+ transition: var(--transition);
288
+ }
289
+
290
+ .modal-overlay.active {
291
+ opacity: 1;
292
+ visibility: visible;
293
+ }
294
+
295
+ .modal {
296
+ background: var(--card-bg);
297
+ width: 90%;
298
+ max-width: 500px;
299
+ border-radius: 20px;
300
+ padding: 2rem;
301
+ transform: scale(0.9);
302
+ transition: var(--transition);
303
+ box-shadow: 0 10px 30px rgba(0,0,0,0.2);
304
+ }
305
+
306
+ .modal-overlay.active .modal {
307
+ transform: scale(1);
308
+ }
309
+
310
+ .modal-header {
311
+ display: flex;
312
+ justify-content: space-between;
313
+ align-items: center;
314
+ margin-bottom: 1.5rem;
315
+ }
316
+
317
+ .modal-title {
318
+ font-size: 1.4rem;
319
+ font-weight: 700;
320
+ }
321
+
322
+ .close-modal {
323
+ background: none;
324
+ border: none;
325
+ font-size: 1.5rem;
326
+ cursor: pointer;
327
+ color: var(--text-secondary);
328
+ }
329
+
330
+ .form-group {
331
+ margin-bottom: 1.2rem;
332
+ }
333
+
334
+ .form-label {
335
+ display: block;
336
+ margin-bottom: 0.5rem;
337
+ font-weight: 600;
338
+ font-size: 0.9rem;
339
+ }
340
+
341
+ .form-control {
342
+ width: 100%;
343
+ padding: 0.8rem;
344
+ border: 2px solid #e0e0e0;
345
+ border-radius: 12px;
346
+ font-family: inherit;
347
+ font-size: 1rem;
348
+ transition: var(--transition);
349
+ }
350
+
351
+ .form-control:focus {
352
+ border-color: var(--primary-color);
353
+ }
354
+
355
+ textarea.form-control {
356
+ resize: vertical;
357
+ min-height: 120px;
358
+ }
359
+
360
+ .modal-footer {
361
+ display: flex;
362
+ justify-content: flex-end;
363
+ gap: 1rem;
364
+ margin-top: 1.5rem;
365
+ }
366
+
367
+ /* --- الفوتر --- */
368
+ footer {
369
+ text-align: center;
370
+ padding: 1.5rem;
371
+ color: var(--text-secondary);
372
+ font-size: 0.9rem;
373
+ margin-top: auto;
374
+ }
375
+
376
+ .anycoder-link {
377
+ color: var(--primary-color);
378
+ text-decoration: none;
379
+ font-weight: 700;
380
+ transition: color 0.2s;
381
+ }
382
+
383
+ .anycoder-link:hover {
384
+ color: var(--primary-hover);
385
+ text-decoration: underline;
386
+ }
387
+
388
+ /* --- التجاوب (Responsive) --- */
389
+ @media (max-width: 768px) {
390
+ .header-content {
391
+ flex-direction: column;
392
+ align-items: stretch;
393
+ }
394
+
395
+ .logo {
396
+ justify-content: center;
397
+ margin-bottom: 1rem;
398
+ }
399
+
400
+ .search-container {
401
+ max-width: 100%;
402
+ }
403
+
404
+ .actions {
405
+ justify-content: center;
406
+ }
407
+
408
+ .notes-grid {
409
+ grid-template-columns: 1fr;
410
+ }
411
+ }
412
+ </style>
413
+ </head>
414
+ <body>
415
+
416
+ <!-- الهيدر -->
417
+ <header>
418
+ <div class="header-content">
419
+ <div class="logo">
420
+ <i class="fa-solid fa-note-sticky"></i>
421
+ ملاحظاتي
422
+ </div>
423
+
424
+ <div class="search-container">
425
+ <input type="text" id="searchInput" class="search-input" placeholder="ابحث في ملاحظاتك...">
426
+ <i class="fa-solid fa-search search-icon"></i>
427
+ </div>
428
+
429
+ <div class="actions">
430
+ <button class="btn btn-danger" onclick="clearAllNotes()">
431
+ <i class="fa-solid fa-trash-can"></i> مسح الكل
432
+ </button>
433
+ <button class="btn btn-primary" onclick="openModal()">
434
+ <i class="fa-solid fa-plus"></i> ملاحظة جديدة
435
+ </button>
436
+ </div>
437
+ </div>
438
+ </header>
439
+
440
+ <!-- المحتوى الرئيسي -->
441
+ <main class="container">
442
+ <!-- شبكة الملاحظات -->
443
+ <div id="notesGrid" class="notes-grid">
444
+ <!-- سيتم توليد الملاحظات هنا بواسطة JavaScript -->
445
+ </div>
446
+
447
+ <!-- رسالة الحالة الفارغة -->
448
+ <div id="emptyState" class="empty-state">
449
+ <i class="fa-regular fa-folder-open"></i>
450
+ <h3>لا توجد ملاحظات بعد</h3>
451
+ <p>ابدأ بإضافة ملاحظة جديدة لتوثيق أفكارك</p>
452
+ </div>
453
+ </main>
454
+
455
+ <!-- الفوتر -->
456
+ <footer>
457
+ <p>تم التطوير بواسطة <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link">Built with anycoder</a></p>
458
+ </footer>
459
+
460
+ <!-- النافذة المنبثقة (Modal) -->
461
+ <div id="noteModal" class="modal-overlay">
462
+ <div class="modal">
463
+ <div class="modal-header">
464
+ <h2 class="modal-title" id="modalTitleText">ملاحظة جديدة</h2>
465
+ <button class="close-modal" onclick="closeModal()">&times;</button>
466
+ </div>
467
+ <div class="form-group">
468
+ <label class="form-label">العنوان</label>
469
+ <input type="text" id="noteTitle" class="form-control" placeholder="اكتب عنواناً جذاباً...">
470
+ </div>
471
+ <div class="form-group">
472
+ <label class="form-label">المحتوى</label>
473
+ <textarea id="noteContent" class="form-control" placeholder="اكتب تفاصيل ملاحظتك هنا..."></textarea>
474
+ </div>
475
+ <div class="modal-footer">
476
+ <button class="btn" style="background: #eee; color: #333;" onclick="closeModal()">إلغاء</button>
477
+ <button class="btn btn-primary" onclick="saveNote()">حفظ الملاحظة</button>
478
+ </div>
479
+ </div>
480
+ </div>
481
+
482
+ <script>
483
+ // --- متغيرات الحالة (State) ---
484
+ let notes = [];
485
+ let isEditing = false;
486
+ let currentEditId = null;
487
+
488
+ // --- عناصر DOM ---
489
+ const notesGrid = document.getElementById('notesGrid');
490
+ const emptyState = document.getElementById('emptyState');
491
+ const modal = document.getElementById('noteModal');
492
+ const modalTitleText = document.getElementById('modalTitleText');
493
+ const titleInput = document.getElementById('noteTitle');
494
+ const contentInput = document.getElementById('noteContent');
495
+ const searchInput = document.getElementById('searchInput');
496
+
497
+ // --- التهيئة عند التحميل ---
498
+ document.addEventListener('DOMContentLoaded', () => {
499
+ loadNotes();
500
+ renderNotes();
501
+ });
502
+
503
+ // --- الوظائف الأساسية (CRUD) ---
504
+
505
+ // 1. تحميل الملاحظات من LocalStorage
506
+ function loadNotes() {
507
+ const storedNotes = localStorage.getItem('myNotesApp_data');
508
+ if (storedNotes) {
509
+ notes = JSON.parse(storedNotes);
510
+ }
511
+ }
512
+
513
+ // 2. حفظ الملاحظات في LocalStorage
514
+ function saveToLocalStorage() {
515
+ localStorage.setItem('myNotesApp_data', JSON.stringify(notes));
516
+ renderNotes();
517
+ }
518
+
519
+ // 3. إضافة أو تعديل ملاحظة
520
+ function saveNote() {
521
+ const title = titleInput.value.trim();
522
+ const content = contentInput.value.trim();
523
+
524
+ if (!title && !content) {
525
+ alert('الرجاء كتابة عنوان أو محتوى للملاحظة');
526
+ return;
527
+ }
528
+
529
+ if (isEditing) {
530
+ // وضع التعديل
531
+ const noteIndex = notes.findIndex(n => n.id === currentEditId);
532
+ if (noteIndex !== -1) {
533
+ notes[noteIndex].title = title;
534
+ notes[noteIndex].content = content;
535
+ notes[noteIndex].lastModified = new Date().toISOString();
536
+ }
537
+ } else {
538
+ // وضع الإضافة
539
+ const newNote = {
540
+ id: Date.now(), // استخدام الوقت كمعرف فريد
541
+ title: title,
542
+ content: content,
543
+ createdAt: new Date().toISOString(),
544
+ lastModified: new Date().toISOString()
545
+ };
546
+ notes.unshift(newNote); // إضافة في البداية
547
+ }
548
+
549
+ saveToLocalStorage();
550
+ closeModal();
551
+ }
552
+
553
+ // 4. حذف ملاحظة
554
+ function deleteNote(id) {
555
+ if (confirm('هل أنت متأكد من حذف هذه الملاحظة؟')) {
556
+ notes = notes.filter(note => note.id !== id);
557
+ saveToLocalStorage();
558
+ }
559
+ }
560
+
561
+ // 5. حذف جميع الملاحظات
562
+ function clearAllNotes() {
563
+ if (notes.length === 0) return;
564
+
565
+ if (confirm('تحذير: سيتم حذف جميع الملاحظات نهائياً. هل أنت متأكد؟')) {
566
+ notes = [];
567
+ saveToLocalStorage();
568
+ }
569
+ }
570
+
571
+ // 6. البحث في الملاحظات
572
+ searchInput.addEventListener('input', (e) => {
573
+ const searchTerm = e.target.value.toLowerCase();
574
+ const filteredNotes = notes.filter(note =>
575
+ note.title.toLowerCase().includes(searchTerm) ||
576
+ note.content.toLowerCase().includes(searchTerm)
577
+ );
578
+ renderNotes(filteredNotes);
579
+ });
580
+
581
+ // --- وظائف العرض (UI) ---
582
+
583
+ // عرض الملاحظات
584
+ function renderNotes(notesArray = notes) {
585
+ notesGrid.innerHTML = '';
586
+
587
+ if (notesArray.length === 0) {
588
+ emptyState.style.display = 'block';
589
+ return;
590
+ } else {
591
+ emptyState.style.display = 'none';
592
+ }
593
+
594
+ // ترتيب الملاحظات: الأحدث أولاً
595
+ // ملاحظة: عند البحث لا نقوم بالترتيب الزمني بل نعرض النتائج
596
+ const notesToRender = notesArray === notes ? [...notesArray].sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt)) : notesArray;
597
+
598
+ notesToRender.forEach(note => {
599
+ const dateObj = new Date(note.createdAt);
600
+ const dateStr = dateObj.toLocaleDateString('ar-EG', {
601
+ year: 'numeric',
602
+ month: 'long',
603
+ day: 'numeric',
604
+ hour: '2-digit',
605
+ minute: '2-digit'
606
+ });
607
+
608
+ const noteCard = document.createElement('div');
609
+ noteCard.className = 'note-card';
610
+ noteCard.innerHTML = `
611
+ <div class="note-header">
612
+ <h3 class="note-title">${escapeHtml(note.title) || '<i>بدون عنوان</i>'}</h3>
613
+ <span class="note-date">${dateStr}</span>
614
+ </div>
615
+ <div class="note-content">${escapeHtml(note.content)}</div>
616
+ <div class="note-actions">
617
+ <button class="icon-btn" onclick="editNote(${note.id})" title="تعديل">
618
+ <i class="fa-solid fa-pen-to-square"></i>
619
+ </button>
620
+ <button class="icon-btn delete" onclick="deleteNote(${note.id})" title="حذف">
621
+ <i class="fa-solid fa-trash"></i>
622
+ </button>
623
+ </div>
624
+ `;
625
+ notesGrid.appendChild(noteCard);
626
+ });
627
+ }
628
+
629
+ // --- وظائف المودال (Modal) ---
630
+
631
+ function openModal() {
632
+ isEditing = false;
633
+ currentEditId = null;
634
+ modalTitleText.textContent = 'ملاحظة جديدة';
635
+ titleInput.value = '';
636
+ contentInput.value = '';
637
+ modal.classList.add('active');
638
+ titleInput.focus();
639
+ }
640
+
641
+ function closeModal() {
642
+ modal.classList.remove('active');
643
+ }
644
+
645
+ function editNote(id) {
646
+ const note = notes.find(n => n.id === id);
647
+ if (note) {
648
+ isEditing = true;
649
+ currentEditId = id;
650
+ modalTitleText.textContent = 'تعديل الملاحظة';
651
+ titleInput.value = note.title;
652
+ contentInput.value = note.content;
653
+ modal.classList.add('active');
654
+ }
655
+ }
656
+
657
+ // إغلاق المودال عند النقر خارج الصندوق
658
+ modal.addEventListener('click', (e) => {
659
+ if (e.target === modal) {
660
+ closeModal();
661
+ }
662
+ });
663
+
664
+ // دالة مساعدة لمنع حقن HTML (Security)
665
+ function escapeHtml(text) {
666
+ if (!text) return '';
667
+ return text
668
+ .replace(/&/g, "&amp;")
669
+ .replace(/</g, "&lt;")
670
+ .replace(/>/g, "&gt;")
671
+ .replace(/"/g, "&quot;")
672
+ .replace(/'/g, "&#039;");
673
+ }
674
+
675
+ </script>
676
+ </body>
677
+ </html>