ReyDiablo commited on
Commit
cac098e
·
verified ·
1 Parent(s): 9c05472

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +1160 -1085
index.html CHANGED
@@ -1,1103 +1,1178 @@
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>NFC Data Transfer Hub</title>
7
- <style>
8
- * {
9
- margin: 0;
10
- padding: 0;
11
- box-sizing: border-box;
12
- }
13
-
14
- :root {
15
- --primary: #6366f1;
16
- --primary-dark: #4f46e5;
17
- --secondary: #22d3ee;
18
- --success: #10b981;
19
- --warning: #f59e0b;
20
- --danger: #ef4444;
21
- --dark: #1e293b;
22
- --light: #f1f5f9;
23
- --white: #ffffff;
24
- --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
25
- --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.15);
26
- }
27
-
28
- body {
29
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
30
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
31
- min-height: 100vh;
32
- color: var(--dark);
33
- position: relative;
34
- overflow-x: hidden;
35
- }
36
-
37
- .animated-bg {
38
- position: fixed;
39
- width: 100%;
40
- height: 100%;
41
- top: 0;
42
- left: 0;
43
- z-index: -1;
44
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
45
- }
46
-
47
- .animated-bg::before {
48
- content: '';
49
- position: absolute;
50
- width: 200%;
51
- height: 200%;
52
- top: -50%;
53
- left: -50%;
54
- background: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
55
- background-size: 50px 50px;
56
- animation: bgMove 20s linear infinite;
57
- }
58
-
59
- @keyframes bgMove {
60
- 0% { transform: translate(0, 0); }
61
- 100% { transform: translate(50px, 50px); }
62
- }
63
-
64
- header {
65
- background: rgba(255, 255, 255, 0.95);
66
- backdrop-filter: blur(10px);
67
- padding: 1rem 2rem;
68
- box-shadow: var(--shadow);
69
- position: sticky;
70
- top: 0;
71
- z-index: 100;
72
- }
73
-
74
- .header-content {
75
- max-width: 1400px;
76
- margin: 0 auto;
77
- display: flex;
78
- justify-content: space-between;
79
- align-items: center;
80
- }
81
-
82
- .logo {
83
- display: flex;
84
- align-items: center;
85
- gap: 1rem;
86
- }
87
-
88
- .logo-icon {
89
- width: 40px;
90
- height: 40px;
91
- background: linear-gradient(135deg, var(--primary), var(--secondary));
92
- border-radius: 12px;
93
- display: flex;
94
- align-items: center;
95
- justify-content: center;
96
- color: white;
97
- font-weight: bold;
98
- font-size: 1.2rem;
99
- }
100
-
101
- .logo h1 {
102
- font-size: 1.5rem;
103
- background: linear-gradient(135deg, var(--primary), var(--secondary));
104
- -webkit-background-clip: text;
105
- -webkit-text-fill-color: transparent;
106
- }
107
-
108
- .status-indicator {
109
- display: flex;
110
- align-items: center;
111
- gap: 0.5rem;
112
- padding: 0.5rem 1rem;
113
- background: var(--light);
114
- border-radius: 20px;
115
- font-size: 0.9rem;
116
- }
117
-
118
- .status-dot {
119
- width: 8px;
120
- height: 8px;
121
- border-radius: 50%;
122
- background: var(--success);
123
- animation: pulse 2s infinite;
124
- }
125
-
126
- @keyframes pulse {
127
- 0%, 100% { opacity: 1; }
128
- 50% { opacity: 0.5; }
129
- }
130
-
131
- main {
132
- max-width: 1400px;
133
- margin: 2rem auto;
134
- padding: 0 2rem;
135
- }
136
-
137
- .app-container {
138
- display: grid;
139
- grid-template-columns: 1fr 1fr;
140
- gap: 2rem;
141
- margin-bottom: 2rem;
142
- }
143
-
144
- .panel {
145
- background: rgba(255, 255, 255, 0.95);
146
- backdrop-filter: blur(10px);
147
- border-radius: 20px;
148
- padding: 2rem;
149
- box-shadow: var(--shadow-lg);
150
- transition: transform 0.3s, box-shadow 0.3s;
151
- }
152
-
153
- .panel:hover {
154
- transform: translateY(-5px);
155
- box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
156
- }
157
-
158
- .panel-header {
159
- display: flex;
160
- align-items: center;
161
- gap: 1rem;
162
- margin-bottom: 1.5rem;
163
- padding-bottom: 1rem;
164
- border-bottom: 2px solid var(--light);
165
- }
166
-
167
- .panel-icon {
168
- width: 40px;
169
- height: 40px;
170
- background: linear-gradient(135deg, var(--primary), var(--secondary));
171
- border-radius: 10px;
172
- display: flex;
173
- align-items: center;
174
- justify-content: center;
175
- color: white;
176
- }
177
-
178
- .panel h2 {
179
- font-size: 1.3rem;
180
- color: var(--dark);
181
- }
182
-
183
- .nfc-simulator {
184
- display: flex;
185
- flex-direction: column;
186
- align-items: center;
187
- gap: 2rem;
188
- }
189
-
190
- .nfc-device {
191
- width: 200px;
192
- height: 200px;
193
- background: linear-gradient(135deg, var(--primary), var(--primary-dark));
194
- border-radius: 20px;
195
- display: flex;
196
- align-items: center;
197
- justify-content: center;
198
- position: relative;
199
- cursor: pointer;
200
- transition: all 0.3s;
201
- box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3);
202
- }
203
-
204
- .nfc-device:hover {
205
- transform: scale(1.05);
206
- box-shadow: 0 15px 40px rgba(99, 102, 241, 0.4);
207
- }
208
-
209
- .nfc-device.active {
210
- animation: nfcPulse 1s infinite;
211
- }
212
-
213
- @keyframes nfcPulse {
214
- 0%, 100% {
215
- box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
216
- }
217
- 50% {
218
- box-shadow: 0 0 0 20px rgba(99, 102, 241, 0);
219
- }
220
- }
221
-
222
- .nfc-symbol {
223
- font-size: 4rem;
224
- color: white;
225
- }
226
 
227
- .data-types {
228
- display: grid;
229
- grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
230
- gap: 1rem;
231
- width: 100%;
232
- }
233
-
234
- .data-type-btn {
235
- padding: 1rem;
236
- background: var(--light);
237
- border: 2px solid transparent;
238
- border-radius: 12px;
239
- cursor: pointer;
240
- transition: all 0.3s;
241
- text-align: center;
242
- }
243
-
244
- .data-type-btn:hover {
245
- background: white;
246
- border-color: var(--primary);
247
- transform: translateY(-2px);
248
- }
249
-
250
- .data-type-btn.active {
251
- background: var(--primary);
252
- color: white;
253
- }
254
-
255
- .data-type-icon {
256
- font-size: 2rem;
257
- margin-bottom: 0.5rem;
258
- }
259
-
260
- .data-input-section {
261
- margin-top: 2rem;
262
- }
263
-
264
- .input-group {
265
- margin-bottom: 1rem;
266
- }
267
-
268
- .input-group label {
269
- display: block;
270
- margin-bottom: 0.5rem;
271
- font-weight: 500;
272
- color: var(--dark);
273
- }
274
-
275
- .input-group input,
276
- .input-group textarea,
277
- .input-group select {
278
- width: 100%;
279
- padding: 0.75rem;
280
- border: 2px solid var(--light);
281
- border-radius: 10px;
282
- font-size: 1rem;
283
- transition: all 0.3s;
284
- }
285
-
286
- .input-group input:focus,
287
- .input-group textarea:focus,
288
- .input-group select:focus {
289
- outline: none;
290
- border-color: var(--primary);
291
- box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
292
- }
293
-
294
- .input-group textarea {
295
- resize: vertical;
296
- min-height: 100px;
297
- }
298
-
299
- .btn {
300
- padding: 0.75rem 1.5rem;
301
- background: linear-gradient(135deg, var(--primary), var(--primary-dark));
302
- color: white;
303
- border: none;
304
- border-radius: 10px;
305
- font-size: 1rem;
306
- font-weight: 500;
307
- cursor: pointer;
308
- transition: all 0.3s;
309
- display: inline-flex;
310
- align-items: center;
311
- gap: 0.5rem;
312
- }
313
-
314
- .btn:hover {
315
- transform: translateY(-2px);
316
- box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
317
- }
318
-
319
- .btn:active {
320
- transform: translateY(0);
321
- }
322
-
323
- .btn-secondary {
324
- background: var(--light);
325
- color: var(--dark);
326
- }
327
-
328
- .btn-success {
329
- background: linear-gradient(135deg, var(--success), #059669);
330
- }
331
-
332
- .btn-danger {
333
- background: linear-gradient(135deg, var(--danger), #dc2626);
334
- }
335
-
336
- .action-buttons {
337
- display: flex;
338
- gap: 1rem;
339
- margin-top: 1.5rem;
340
- }
341
-
342
- .history-section {
343
- background: rgba(255, 255, 255, 0.95);
344
- backdrop-filter: blur(10px);
345
- border-radius: 20px;
346
- padding: 2rem;
347
- box-shadow: var(--shadow-lg);
348
- }
349
-
350
- .history-list {
351
- display: flex;
352
- flex-direction: column;
353
- gap: 1rem;
354
- max-height: 400px;
355
- overflow-y: auto;
356
- }
357
-
358
- .history-item {
359
- padding: 1rem;
360
- background: var(--light);
361
- border-radius: 12px;
362
- display: flex;
363
- justify-content: space-between;
364
- align-items: center;
365
- transition: all 0.3s;
366
- }
367
-
368
- .history-item:hover {
369
- background: white;
370
- transform: translateX(5px);
371
- }
372
-
373
- .history-info {
374
- flex: 1;
375
- }
376
-
377
- .history-type {
378
- font-weight: 600;
379
- color: var(--primary);
380
- margin-bottom: 0.25rem;
381
- }
382
-
383
- .history-time {
384
- font-size: 0.85rem;
385
- color: #64748b;
386
- }
387
-
388
- .history-actions {
389
- display: flex;
390
- gap: 0.5rem;
391
- }
392
-
393
- .icon-btn {
394
- width: 35px;
395
- height: 35px;
396
- border-radius: 8px;
397
- border: none;
398
- background: white;
399
- color: var(--primary);
400
- cursor: pointer;
401
- transition: all 0.3s;
402
- display: flex;
403
- align-items: center;
404
- justify-content: center;
405
- }
406
-
407
- .icon-btn:hover {
408
- background: var(--primary);
409
- color: white;
410
- }
411
-
412
- .toast {
413
- position: fixed;
414
- bottom: 2rem;
415
- right: 2rem;
416
- padding: 1rem 1.5rem;
417
- background: white;
418
- border-radius: 12px;
419
- box-shadow: var(--shadow-lg);
420
- display: flex;
421
- align-items: center;
422
- gap: 1rem;
423
- transform: translateX(400px);
424
- transition: transform 0.3s;
425
- z-index: 1000;
426
- }
427
-
428
- .toast.show {
429
- transform: translateX(0);
430
- }
431
-
432
- .toast-icon {
433
- width: 30px;
434
- height: 30px;
435
- border-radius: 50%;
436
- display: flex;
437
- align-items: center;
438
- justify-content: center;
439
- }
440
-
441
- .toast.success .toast-icon {
442
- background: var(--success);
443
- color: white;
444
- }
445
-
446
- .toast.error .toast-icon {
447
- background: var(--danger);
448
- color: white;
449
- }
450
-
451
- .modal {
452
- display: none;
453
- position: fixed;
454
- top: 0;
455
- left: 0;
456
- width: 100%;
457
- height: 100%;
458
- background: rgba(0, 0, 0, 0.5);
459
- backdrop-filter: blur(5px);
460
- align-items: center;
461
- justify-content: center;
462
- z-index: 200;
463
- }
464
-
465
- .modal.active {
466
- display: flex;
467
- }
468
-
469
- .modal-content {
470
- background: white;
471
- border-radius: 20px;
472
- padding: 2rem;
473
- max-width: 500px;
474
- width: 90%;
475
- max-height: 80vh;
476
- overflow-y: auto;
477
- animation: modalSlideIn 0.3s;
478
- }
479
-
480
- @keyframes modalSlideIn {
481
- from {
482
- transform: translateY(-50px);
483
- opacity: 0;
484
- }
485
- to {
486
- transform: translateY(0);
487
- opacity: 1;
488
- }
489
- }
490
-
491
- .modal-header {
492
- display: flex;
493
- justify-content: space-between;
494
- align-items: center;
495
- margin-bottom: 1.5rem;
496
- }
497
-
498
- .modal-close {
499
- width: 30px;
500
- height: 30px;
501
- border-radius: 50%;
502
- border: none;
503
- background: var(--light);
504
- cursor: pointer;
505
- transition: all 0.3s;
506
- }
507
-
508
- .modal-close:hover {
509
- background: var(--danger);
510
- color: white;
511
- }
512
-
513
- @media (max-width: 968px) {
514
- .app-container {
515
- grid-template-columns: 1fr;
516
- }
517
-
518
- .header-content {
519
- flex-direction: column;
520
- gap: 1rem;
521
- }
522
-
523
- main {
524
- padding: 0 1rem;
525
- }
526
- }
527
-
528
- @media (max-width: 480px) {
529
- .data-types {
530
- grid-template-columns: repeat(2, 1fr);
531
- }
532
-
533
- .action-buttons {
534
- flex-direction: column;
535
- }
536
-
537
- .btn {
538
- width: 100%;
539
- justify-content: center;
540
- }
541
- }
542
-
543
- .progress-bar {
544
- width: 100%;
545
- height: 6px;
546
- background: var(--light);
547
- border-radius: 3px;
548
- overflow: hidden;
549
- margin-top: 1rem;
550
- }
551
-
552
- .progress-fill {
553
- height: 100%;
554
- background: linear-gradient(90deg, var(--primary), var(--secondary));
555
- border-radius: 3px;
556
- width: 0;
557
- transition: width 0.3s;
558
- }
559
-
560
- .format-options {
561
- display: flex;
562
- gap: 0.5rem;
563
- margin-top: 1rem;
564
- flex-wrap: wrap;
565
- }
566
-
567
- .format-chip {
568
- padding: 0.5rem 1rem;
569
- background: var(--light);
570
- border: 2px solid transparent;
571
- border-radius: 20px;
572
- cursor: pointer;
573
- transition: all 0.3s;
574
- font-size: 0.9rem;
575
- }
576
-
577
- .format-chip:hover {
578
- border-color: var(--primary);
579
- }
580
-
581
- .format-chip.active {
582
- background: var(--primary);
583
- color: white;
584
- }
585
- </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
586
  </head>
 
587
  <body>
588
- <div class="animated-bg"></div>
589
-
590
- <header>
591
- <div class="header-content">
592
- <div class="logo">
593
- <div class="logo-icon">N</div>
594
- <h1>NFC Data Transfer Hub</h1>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
595
  </div>
596
- <div class="status-indicator">
597
- <span class="status-dot"></span>
598
- <span>Ready to Transfer</span>
599
  </div>
600
- <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" style="color: var(--primary); text-decoration: none; font-weight: 500;">
601
- Built with anycoder
602
- </a>
603
- </div>
604
- </header>
605
-
606
- <main>
607
- <div class="app-container">
608
- <!-- NFC Simulator Panel -->
609
- <div class="panel">
610
- <div class="panel-header">
611
- <div class="panel-icon">📡</div>
612
- <h2>NFC Simulator</h2>
613
- </div>
614
- <div class="nfc-simulator">
615
- <div class="nfc-device" id="nfcDevice">
616
- <div class="nfc-symbol">📱</div>
617
- </div>
618
- <div class="data-types">
619
- <div class="data-type-btn active" data-type="text">
620
- <div class="data-type-icon">📝</div>
621
- <div>Text</div>
622
- </div>
623
- <div class="data-type-btn" data-type="url">
624
- <div class="data-type-icon">🔗</div>
625
- <div>URL</div>
626
- </div>
627
- <div class="data-type-btn" data-type="contact">
628
- <div class="data-type-icon">👤</div>
629
- <div>Contact</div>
630
- </div>
631
- <div class="data-type-btn" data-type="wifi">
632
- <div class="data-type-icon">📶</div>
633
- <div>WiFi</div>
634
- </div>
635
- </div>
636
- </div>
637
  </div>
638
-
639
- <!-- Data Input Panel -->
640
- <div class="panel">
641
- <div class="panel-header">
642
- <div class="panel-icon">💾</div>
643
- <h2>Data Input</h2>
644
- </div>
645
- <div class="data-input-section" id="dataInputSection">
646
- <div class="input-group">
647
- <label for="textInput">Text Message</label>
648
- <textarea id="textInput" placeholder="Enter your text message here..."></textarea>
649
- </div>
650
- <div class="format-options">
651
- <div class="format-chip active" data-format="plain">Plain Text</div>
652
- <div class="format-chip" data-format="json">JSON</div>
653
- <div class="format-chip" data-format="base64">Base64</div>
654
- <div class="format-chip" data-format="hex">Hex</div>
655
- </div>
656
- </div>
657
- <div class="action-buttons">
658
- <button class="btn btn-success" id="transferBtn">
659
- <span>⚡</span>
660
- <span>Transfer Data</span>
661
- </button>
662
- <button class="btn btn-secondary" id="clearBtn">
663
- <span>🗑️</span>
664
- <span>Clear</span>
665
- </button>
666
- </div>
667
- <div class="progress-bar">
668
- <div class="progress-fill" id="progressBar"></div>
669
- </div>
670
  </div>
 
 
 
 
 
671
  </div>
 
672
 
673
- <!-- History Section -->
674
- <div class="history-section">
675
- <div class="panel-header">
676
- <div class="panel-icon">📋</div>
677
- <h2>Transfer History</h2>
678
- </div>
679
- <div class="history-list" id="historyList">
680
- <div class="history-item">
681
- <div class="history-info">
682
- <div class="history-type">Welcome Message</div>
683
- <div class="history-time">Just now</div>
684
- </div>
685
- <div class="history-actions">
686
- <button class="icon-btn">👁️</button>
687
- <button class="icon-btn">📋</button>
688
- <button class="icon-btn">🔄</button>
689
- </div>
690
- </div>
691
- </div>
692
  </div>
693
- </main>
694
-
695
- <!-- Modal for viewing data -->
696
- <div class="modal" id="viewModal">
697
- <div class="modal-content">
698
- <div class="modal-header">
699
- <h2>View Data</h2>
700
- <button class="modal-close" id="closeModal">✕</button>
701
- </div>
702
- <div id="modalBody"></div>
 
703
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
704
  </div>
705
 
706
- <!-- Toast Notification -->
707
- <div class="toast" id="toast">
708
- <div class="toast-icon">✓</div>
709
- <div class="toast-message" id="toastMessage">Transfer successful!</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
710
  </div>
711
-
712
- <script>
713
- // State management
714
- let currentDataType = 'text';
715
- let currentFormat = 'plain';
716
- let transferHistory = [];
717
- let isTransferring = false;
718
-
719
- // DOM elements
720
- const nfcDevice = document.getElementById('nfcDevice');
721
- const dataInputSection = document.getElementById('dataInputSection');
722
- const transferBtn = document.getElementById('transferBtn');
723
- const clearBtn = document.getElementById('clearBtn');
724
- const progressBar = document.getElementById('progressBar');
725
- const historyList = document.getElementById('historyList');
726
- const toast = document.getElementById('toast');
727
- const toastMessage = document.getElementById('toastMessage');
728
- const viewModal = document.getElementById('viewModal');
729
- const modalBody = document.getElementById('modalBody');
730
- const closeModal = document.getElementById('closeModal');
731
-
732
- // Data type templates
733
- const dataTemplates = {
734
- text: `
735
- <div class="input-group">
736
- <label for="textInput">Text Message</label>
737
- <textarea id="textInput" placeholder="Enter your text message here..."></textarea>
738
- </div>
739
- `,
740
- url: `
741
- <div class="input-group">
742
- <label for="urlInput">URL</label>
743
- <input type="url" id="urlInput" placeholder="https://example.com">
744
- </div>
745
- <div class="input-group">
746
- <label for="urlTitle">Title (Optional)</label>
747
- <input type="text" id="urlTitle" placeholder="Website Title">
748
- </div>
749
- `,
750
- contact: `
751
- <div class="input-group">
752
- <label for="contactName">Name</label>
753
- <input type="text" id="contactName" placeholder="John Doe">
754
- </div>
755
- <div class="input-group">
756
- <label for="contactPhone">Phone</label>
757
- <input type="tel" id="contactPhone" placeholder="+1234567890">
758
- </div>
759
- <div class="input-group">
760
- <label for="contactEmail">Email</label>
761
- <input type="email" id="contactEmail" placeholder="john@example.com">
762
- </div>
763
- `,
764
- wifi: `
765
- <div class="input-group">
766
- <label for="wifiSSID">Network Name (SSID)</label>
767
- <input type="text" id="wifiSSID" placeholder="MyWiFi">
768
- </div>
769
- <div class="input-group">
770
- <label for="wifiPassword">Password</label>
771
- <input type="password" id="wifiPassword" placeholder="••••••••">
772
- </div>
773
- <div class="input-group">
774
- <label for="wifiSecurity">Security Type</label>
775
- <select id="wifiSecurity">
776
- <option value="WPA">WPA/WPA2</option>
777
- <option value="WEP">WEP</option>
778
- <option value="nopass">Open Network</option>
779
- </select>
780
- </div>
781
- `
782
- };
783
-
784
- // Initialize event listeners
785
- document.querySelectorAll('.data-type-btn').forEach(btn => {
786
- btn.addEventListener('click', function() {
787
- document.querySelectorAll('.data-type-btn').forEach(b => b.classList.remove('active'));
788
- this.classList.add('active');
789
- currentDataType = this.dataset.type;
790
- updateDataInput();
791
- });
792
- });
793
-
794
- document.querySelectorAll('.format-chip').forEach(chip => {
795
- chip.addEventListener('click', function() {
796
- document.querySelectorAll('.format-chip').forEach(c => c.classList.remove('active'));
797
- this.classList.add('active');
798
- currentFormat = this.dataset.format;
799
- });
800
- });
801
-
802
- nfcDevice.addEventListener('click', simulateTransfer);
803
- transferBtn.addEventListener('click', initiateTransfer);
804
- clearBtn.addEventListener('click', clearData);
805
- closeModal.addEventListener('click', () => viewModal.classList.remove('active'));
806
-
807
- function updateDataInput() {
808
- dataInputSection.innerHTML = dataTemplates[currentDataType] + `
809
- <div class="format-options">
810
- <div class="format-chip ${currentFormat === 'plain' ? 'active' : ''}" data-format="plain">Plain Text</div>
811
- <div class="format-chip ${currentFormat === 'json' ? 'active' : ''}" data-format="json">JSON</div>
812
- <div class="format-chip ${currentFormat === 'base64' ? 'active' : ''}" data-format="base64">Base64</div>
813
- <div class="format-chip ${currentFormat === 'hex' ? 'active' : ''}" data-format="hex">Hex</div>
814
- </div>
815
- `;
816
-
817
- // Re-attach format chip listeners
818
- document.querySelectorAll('.format-chip').forEach(chip => {
819
- chip.addEventListener('click', function() {
820
- document.querySelectorAll('.format-chip').forEach(c => c.classList.remove('active'));
821
- this.classList.add('active');
822
- currentFormat = this.dataset.format;
823
- });
824
- });
825
- }
826
-
827
- function simulateTransfer() {
828
- if (isTransferring) return;
829
-
830
- nfcDevice.classList.add('active');
831
- setTimeout(() => {
832
- nfcDevice.classList.remove('active');
833
- }, 1000);
834
- }
835
-
836
- function initiateTransfer() {
837
- if (isTransferring) return;
838
-
839
- const data = collectData();
840
- if (!validateData(data)) {
841
- showToast('Please fill in the required fields', 'error');
842
- return;
843
- }
844
-
845
- isTransferring = true;
846
- nfcDevice.classList.add('active');
847
- transferBtn.disabled = true;
848
-
849
- // Simulate transfer progress
850
- let progress = 0;
851
- const interval = setInterval(() => {
852
- progress += 10;
853
- progressBar.style.width = progress + '%';
854
-
855
- if (progress >= 100) {
856
- clearInterval(interval);
857
- completeTransfer(data);
858
- }
859
- }, 200);
860
- }
861
-
862
- function collectData() {
863
- let data = { type: currentDataType, format: currentFormat };
864
-
865
- switch(currentDataType) {
866
- case 'text':
867
- data.content = document.getElementById('textInput')?.value || '';
868
- break;
869
- case 'url':
870
- data.url = document.getElementById('urlInput')?.value || '';
871
- data.title = document.getElementById('urlTitle')?.value || '';
872
- break;
873
- case 'contact':
874
- data.name = document.getElementById('contactName')?.value || '';
875
- data.phone = document.getElementById('contactPhone')?.value || '';
876
- data.email = document.getElementById('contactEmail')?.value || '';
877
- break;
878
- case 'wifi':
879
- data.ssid = document.getElementById('wifiSSID')?.value || '';
880
- data.password = document.getElementById('wifiPassword')?.value || '';
881
- data.security = document.getElementById('wifiSecurity')?.value || 'WPA';
882
- break;
883
- }
884
-
885
- // Apply format transformation
886
- if (currentFormat === 'json') {
887
- data.encoded = JSON.stringify(data);
888
- } else if (currentFormat === 'base64') {
889
- data.encoded = btoa(JSON.stringify(data));
890
- } else if (currentFormat === 'hex') {
891
- const str = JSON.stringify(data);
892
- data.encoded = Array.from(str).map(c => c.charCodeAt(0).toString(16).padStart(2, '0')).join('');
893
- }
894
-
895
- return data;
896
- }
897
-
898
- function validateData(data) {
899
- switch(currentDataType) {
900
- case 'text':
901
- return data.content.trim().length > 0;
902
- case 'url':
903
- return data.url.trim().length > 0;
904
- case 'contact':
905
- return data.name.trim().length > 0;
906
- case 'wifi':
907
- return data.ssid.trim().length > 0;
908
- default:
909
- return false;
910
- }
911
- }
912
-
913
- function completeTransfer(data) {
914
- isTransferring = false;
915
- nfcDevice.classList.remove('active');
916
- transferBtn.disabled = false;
917
- progressBar.style.width = '0%';
918
-
919
- // Add to history
920
- const historyItem = {
921
- id: Date.now(),
922
- type: data.type,
923
- data: data,
924
- timestamp: new Date()
925
- };
926
- transferHistory.unshift(historyItem);
927
- updateHistoryDisplay();
928
-
929
- showToast('Data transferred successfully!', 'success');
930
- }
931
-
932
- function clearData() {
933
- const inputs = dataInputSection.querySelectorAll('input, textarea');
934
- inputs.forEach(input => input.value = '');
935
- progressBar.style.width = '0%';
936
- showToast('Data cleared', 'success');
937
- }
938
-
939
- function updateHistoryDisplay() {
940
- const historyHTML = transferHistory.slice(0, 10).map(item => {
941
- const timeAgo = getTimeAgo(item.timestamp);
942
- const icon = getTypeIcon(item.type);
943
-
944
- return `
945
- <div class="history-item">
946
- <div class="history-info">
947
- <div class="history-type">${icon} ${item.type.toUpperCase()} Data</div>
948
- <div class="history-time">${timeAgo}</div>
949
- </div>
950
- <div class="history-actions">
951
- <button class="icon-btn" onclick="viewData(${item.id})">👁️</button>
952
- <button class="icon-btn" onclick="copyData(${item.id})">📋</button>
953
- <button class="icon-btn" onclick="retransferData(${item.id})">🔄</button>
954
- </div>
955
- </div>
956
- `;
957
- }).join('');
958
-
959
- historyList.innerHTML = historyHTML || '<p style="text-align: center; color: #64748b;">No transfer history yet</p>';
960
- }
961
-
962
- function getTypeIcon(type) {
963
- const icons = {
964
- text: '📝',
965
- url: '🔗',
966
- contact: '👤',
967
- wifi: '📶'
968
- };
969
- return icons[type] || '📄';
970
- }
971
-
972
- function getTimeAgo(date) {
973
- const seconds = Math.floor((new Date() - date) / 1000);
974
-
975
- if (seconds < 60) return 'Just now';
976
- if (seconds < 3600) return Math.floor(seconds / 60) + ' minutes ago';
977
- if (seconds < 86400) return Math.floor(seconds / 3600) + ' hours ago';
978
- return Math.floor(seconds / 86400) + ' days ago';
979
- }
980
-
981
- function viewData(id) {
982
- const item = transferHistory.find(h => h.id === id);
983
- if (!item) return;
984
-
985
- let content = '<div style="word-break: break-all;">';
986
-
987
- switch(item.type) {
988
- case 'text':
989
- content += `<strong>Content:</strong> ${item.data.content}`;
990
- break;
991
- case 'url':
992
- content += `<strong>URL:</strong> ${item.data.url}<br>`;
993
- content += `<strong>Title:</strong> ${item.data.title || 'N/A'}`;
994
- break;
995
- case 'contact':
996
- content += `<strong>Name:</strong> ${item.data.name}<br>`;
997
- content += `<strong>Phone:</strong> ${item.data.phone}<br>`;
998
- content += `<strong>Email:</strong> ${item.data.email}`;
999
- break;
1000
- case 'wifi':
1001
- content += `<strong>SSID:</strong> ${item.data.ssid}<br>`;
1002
- content += `<strong>Security:</strong> ${item.data.security}<br>`;
1003
- content += `<strong>Password:</strong> ${item.data.password ? '••••••••' : 'None'}`;
1004
- break;
1005
- }
1006
-
1007
- if (item.data.format !== 'plain') {
1008
- content += `<br><br><strong>Encoded (${item.data.format}):</strong><br><code style="background: #f1f5f9; padding: 10px; border-radius: 5px; display: block;">${item.data.encoded}</code>`;
1009
- }
1010
-
1011
- content += '</div>';
1012
-
1013
- modalBody.innerHTML = content;
1014
- viewModal.classList.add('active');
1015
- }
1016
-
1017
- function copyData(id) {
1018
- const item = transferHistory.find(h => h.id === id);
1019
- if (!item) return;
1020
-
1021
- const textToCopy = JSON.stringify(item.data, null, 2);
1022
- navigator.clipboard.writeText(textToCopy).then(() => {
1023
- showToast('Data copied to clipboard!', 'success');
1024
- });
1025
- }
1026
-
1027
- function retransferData(id) {
1028
- const item = transferHistory.find(h => h.id === id);
1029
- if (!item) return;
1030
-
1031
- // Fill the form with the data
1032
- currentDataType = item.type;
1033
- document.querySelectorAll('.data-type-btn').forEach(btn => {
1034
- btn.classList.toggle('active', btn.dataset.type === item.type);
1035
- });
1036
- updateDataInput();
1037
-
1038
- // Populate the form
1039
- setTimeout(() => {
1040
- switch(item.type) {
1041
- case 'text':
1042
- document.getElementById('textInput').value = item.data.content;
1043
- break;
1044
- case 'url':
1045
- document.getElementById('urlInput').value = item.data.url;
1046
- document.getElementById('urlTitle').value = item.data.title;
1047
- break;
1048
- case 'contact':
1049
- document.getElementById('contactName').value = item.data.name;
1050
- document.getElementById('contactPhone').value = item.data.phone;
1051
- document.getElementById('contactEmail').value = item.data.email;
1052
- break;
1053
- case 'wifi':
1054
- document.getElementById('wifiSSID').value = item.data.ssid;
1055
- document.getElementById('wifiPassword').value = item.data.password;
1056
- document.getElementById('wifiSecurity').value = item.data.security;
1057
- break;
1058
- }
1059
- }, 100);
1060
-
1061
- showToast('Data loaded for retransfer', 'success');
1062
- }
1063
-
1064
- function showToast(message, type = 'success') {
1065
- toastMessage.textContent = message;
1066
- toast.className = `toast ${type}`;
1067
- toast.classList.add('show');
1068
-
1069
- setTimeout(() => {
1070
- toast.classList.remove('show');
1071
- }, 3000);
1072
- }
1073
-
1074
- // Initialize with welcome message
1075
- window.addEventListener('load', () => {
1076
- const welcomeData = {
1077
- id: Date.now(),
1078
- type: 'text',
1079
- data: { content: 'Welcome to NFC Data Transfer Hub!', format: 'plain' },
1080
- timestamp: new Date()
1081
- };
1082
- transferHistory.push(welcomeData);
1083
- updateHistoryDisplay();
1084
  });
1085
-
1086
- // Keyboard shortcuts
1087
- document.addEventListener('keydown', (e) => {
1088
- if (e.ctrlKey || e.metaKey) {
1089
- switch(e.key) {
1090
- case 'Enter':
1091
- e.preventDefault();
1092
- initiateTransfer();
1093
- break;
1094
- case 'Delete':
1095
- e.preventDefault();
1096
- clearData();
1097
- break;
1098
- }
1099
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1100
  });
1101
- </script>
1102
- </body>
1103
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <!DOCTYPE html>
2
  <html lang="en">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>NFC Data Transfer Hub - Mobile Ready</title>
8
+ <style>
9
+ * {
10
+ margin: 0;
11
+ padding: 0;
12
+ box-sizing: border-box;
13
+ }
14
+
15
+ :root {
16
+ --primary: #6366f1;
17
+ --primary-dark: #4f46e5;
18
+ --secondary: #22d3ee;
19
+ --success: #10b981;
20
+ --warning: #f59e0b;
21
+ --danger: #ef4444;
22
+ --dark: #1e293b;
23
+ --light: #f1f5f9;
24
+ --white: #ffffff;
25
+ --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
26
+ --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.15);
27
+ }
28
+
29
+ body {
30
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
31
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
32
+ min-height: 100vh;
33
+ color: var(--dark);
34
+ position: relative;
35
+ overflow-x: hidden;
36
+ -webkit-tap-highlight-color: transparent;
37
+ }
38
+
39
+ .animated-bg {
40
+ position: fixed;
41
+ width: 100%;
42
+ height: 100%;
43
+ top: 0;
44
+ left: 0;
45
+ z-index: -1;
46
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
47
+ }
48
+
49
+ .animated-bg::before {
50
+ content: '';
51
+ position: absolute;
52
+ width: 200%;
53
+ height: 200%;
54
+ top: -50%;
55
+ left: -50%;
56
+ background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
57
+ background-size: 50px 50px;
58
+ animation: bgMove 20s linear infinite;
59
+ }
60
+
61
+ @keyframes bgMove {
62
+ 0% { transform: translate(0, 0); }
63
+ 100% { transform: translate(50px, 50px); }
64
+ }
65
+
66
+ header {
67
+ background: rgba(255, 255, 255, 0.95);
68
+ backdrop-filter: blur(10px);
69
+ padding: 1rem;
70
+ box-shadow: var(--shadow);
71
+ position: sticky;
72
+ top: 0;
73
+ z-index: 100;
74
+ }
75
+
76
+ .header-content {
77
+ max-width: 1400px;
78
+ margin: 0 auto;
79
+ display: flex;
80
+ justify-content: space-between;
81
+ align-items: center;
82
+ flex-wrap: wrap;
83
+ gap: 1rem;
84
+ }
85
+
86
+ .logo {
87
+ display: flex;
88
+ align-items: center;
89
+ gap: 0.75rem;
90
+ }
91
+
92
+ .logo-icon {
93
+ width: 40px;
94
+ height: 40px;
95
+ background: linear-gradient(135deg, var(--primary), var(--secondary));
96
+ border-radius: 12px;
97
+ display: flex;
98
+ align-items: center;
99
+ justify-content: center;
100
+ color: white;
101
+ font-weight: bold;
102
+ font-size: 1.2rem;
103
+ }
104
+
105
+ .logo h1 {
106
+ font-size: 1.3rem;
107
+ background: linear-gradient(135deg, var(--primary), var(--secondary));
108
+ -webkit-background-clip: text;
109
+ -webkit-text-fill-color: transparent;
110
+ }
111
+
112
+ .status-indicator {
113
+ display: flex;
114
+ align-items: center;
115
+ gap: 0.5rem;
116
+ padding: 0.5rem 1rem;
117
+ background: var(--light);
118
+ border-radius: 20px;
119
+ font-size: 0.85rem;
120
+ }
121
+
122
+ .status-dot {
123
+ width: 8px;
124
+ height: 8px;
125
+ border-radius: 50%;
126
+ background: var(--success);
127
+ animation: pulse 2s infinite;
128
+ }
129
+
130
+ .status-dot.error {
131
+ background: var(--danger);
132
+ }
133
+
134
+ @keyframes pulse {
135
+ 0%, 100% { opacity: 1; }
136
+ 50% { opacity: 0.5; }
137
+ }
138
+
139
+ main {
140
+ max-width: 1400px;
141
+ margin: 1rem auto;
142
+ padding: 0 1rem;
143
+ }
144
+
145
+ .nfc-mode-toggle {
146
+ background: rgba(255, 255, 255, 0.95);
147
+ backdrop-filter: blur(10px);
148
+ border-radius: 15px;
149
+ padding: 1rem;
150
+ margin-bottom: 1rem;
151
+ box-shadow: var(--shadow);
152
+ display: flex;
153
+ align-items: center;
154
+ justify-content: space-between;
155
+ flex-wrap: wrap;
156
+ gap: 1rem;
157
+ }
158
+
159
+ .toggle-switch {
160
+ display: flex;
161
+ align-items: center;
162
+ gap: 0.75rem;
163
+ }
164
+
165
+ .switch {
166
+ position: relative;
167
+ width: 60px;
168
+ height: 30px;
169
+ }
170
+
171
+ .switch input {
172
+ opacity: 0;
173
+ width: 0;
174
+ height: 0;
175
+ }
176
+
177
+ .slider {
178
+ position: absolute;
179
+ cursor: pointer;
180
+ top: 0;
181
+ left: 0;
182
+ right: 0;
183
+ bottom: 0;
184
+ background-color: #ccc;
185
+ transition: .4s;
186
+ border-radius: 34px;
187
+ }
188
+
189
+ .slider:before {
190
+ position: absolute;
191
+ content: "";
192
+ height: 22px;
193
+ width: 22px;
194
+ left: 4px;
195
+ bottom: 4px;
196
+ background-color: white;
197
+ transition: .4s;
198
+ border-radius: 50%;
199
+ }
200
+
201
+ input:checked + .slider {
202
+ background-color: var(--primary);
203
+ }
204
+
205
+ input:checked + .slider:before {
206
+ transform: translateX(30px);
207
+ }
208
+
209
+ .app-container {
210
+ display: grid;
211
+ grid-template-columns: 1fr;
212
+ gap: 1rem;
213
+ margin-bottom: 1rem;
214
+ }
215
+
216
+ .panel {
217
+ background: rgba(255, 255, 255, 0.95);
218
+ backdrop-filter: blur(10px);
219
+ border-radius: 20px;
220
+ padding: 1.5rem;
221
+ box-shadow: var(--shadow-lg);
222
+ transition: transform 0.3s, box-shadow 0.3s;
223
+ }
224
+
225
+ .panel:hover {
226
+ transform: translateY(-2px);
227
+ box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
228
+ }
229
+
230
+ .panel-header {
231
+ display: flex;
232
+ align-items: center;
233
+ gap: 1rem;
234
+ margin-bottom: 1.5rem;
235
+ padding-bottom: 1rem;
236
+ border-bottom: 2px solid var(--light);
237
+ }
238
+
239
+ .panel-icon {
240
+ width: 40px;
241
+ height: 40px;
242
+ background: linear-gradient(135deg, var(--primary), var(--secondary));
243
+ border-radius: 10px;
244
+ display: flex;
245
+ align-items: center;
246
+ justify-content: center;
247
+ color: white;
248
+ }
249
+
250
+ .panel h2 {
251
+ font-size: 1.2rem;
252
+ color: var(--dark);
253
+ }
254
+
255
+ .nfc-simulator {
256
+ display: flex;
257
+ flex-direction: column;
258
+ align-items: center;
259
+ gap: 1.5rem;
260
+ }
261
+
262
+ .nfc-device {
263
+ width: 150px;
264
+ height: 150px;
265
+ background: linear-gradient(135deg, var(--primary), var(--primary-dark));
266
+ border-radius: 20px;
267
+ display: flex;
268
+ align-items: center;
269
+ justify-content: center;
270
+ position: relative;
271
+ cursor: pointer;
272
+ transition: all 0.3s;
273
+ box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3);
274
+ }
275
+
276
+ .nfc-device:hover {
277
+ transform: scale(1.05);
278
+ box-shadow: 0 15px 40px rgba(99, 102, 241, 0.4);
279
+ }
280
+
281
+ .nfc-device.active {
282
+ animation: nfcPulse 1s infinite;
283
+ }
284
+
285
+ @keyframes nfcPulse {
286
+ 0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7); }
287
+ 50% { box-shadow: 0 0 0 20px rgba(99, 102, 241, 0); }
288
+ }
289
+
290
+ .nfc-symbol {
291
+ font-size: 3rem;
292
+ color: white;
293
+ }
294
+
295
+ .data-types {
296
+ display: grid;
297
+ grid-template-columns: repeat(2, 1fr);
298
+ gap: 0.75rem;
299
+ width: 100%;
300
+ }
301
+
302
+ .data-type-btn {
303
+ padding: 0.75rem;
304
+ background: var(--light);
305
+ border: 2px solid transparent;
306
+ border-radius: 12px;
307
+ cursor: pointer;
308
+ transition: all 0.3s;
309
+ text-align: center;
310
+ }
311
+
312
+ .data-type-btn:hover {
313
+ background: white;
314
+ border-color: var(--primary);
315
+ transform: translateY(-2px);
316
+ }
317
+
318
+ .data-type-btn.active {
319
+ background: var(--primary);
320
+ color: white;
321
+ }
322
+
323
+ .data-type-icon {
324
+ font-size: 1.5rem;
325
+ margin-bottom: 0.25rem;
326
+ }
327
+
328
+ .data-type-text {
329
+ font-size: 0.85rem;
330
+ font-weight: 500;
331
+ }
332
+
333
+ .data-input-section {
334
+ margin-top: 1.5rem;
335
+ }
336
+
337
+ .input-group {
338
+ margin-bottom: 1rem;
339
+ }
340
+
341
+ .input-group label {
342
+ display: block;
343
+ margin-bottom: 0.5rem;
344
+ font-weight: 500;
345
+ color: var(--dark);
346
+ font-size: 0.9rem;
347
+ }
348
+
349
+ .input-group input,
350
+ .input-group textarea,
351
+ .input-group select {
352
+ width: 100%;
353
+ padding: 0.75rem;
354
+ border: 2px solid var(--light);
355
+ border-radius: 10px;
356
+ font-size: 1rem;
357
+ transition: all 0.3s;
358
+ -webkit-appearance: none;
359
+ }
360
+
361
+ .input-group input:focus,
362
+ .input-group textarea:focus,
363
+ .input-group select:focus {
364
+ outline: none;
365
+ border-color: var(--primary);
366
+ box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
367
+ }
368
+
369
+ .input-group textarea {
370
+ resize: vertical;
371
+ min-height: 80px;
372
+ }
373
+
374
+ .btn {
375
+ padding: 0.75rem 1.5rem;
376
+ background: linear-gradient(135deg, var(--primary), var(--primary-dark));
377
+ color: white;
378
+ border: none;
379
+ border-radius: 10px;
380
+ font-size: 1rem;
381
+ font-weight: 500;
382
+ cursor: pointer;
383
+ transition: all 0.3s;
384
+ display: inline-flex;
385
+ align-items: center;
386
+ gap: 0.5rem;
387
+ width: 100%;
388
+ justify-content: center;
389
+ }
390
+
391
+ .btn:hover {
392
+ transform: translateY(-2px);
393
+ box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
394
+ }
395
+
396
+ .btn:active {
397
+ transform: translateY(0);
398
+ }
399
+
400
+ .btn:disabled {
401
+ opacity: 0.5;
402
+ cursor: not-allowed;
403
+ }
404
+
405
+ .btn-secondary {
406
+ background: var(--light);
407
+ color: var(--dark);
408
+ }
409
+
410
+ .btn-success {
411
+ background: linear-gradient(135deg, var(--success), #059669);
412
+ }
413
+
414
+ .btn-danger {
415
+ background: linear-gradient(135deg, var(--danger), #dc2626);
416
+ }
417
+
418
+ .action-buttons {
419
+ display: grid;
420
+ grid-template-columns: 1fr 1fr;
421
+ gap: 0.75rem;
422
+ margin-top: 1.5rem;
423
+ }
424
+
425
+ .history-section {
426
+ background: rgba(255, 255, 255, 0.95);
427
+ backdrop-filter: blur(10px);
428
+ border-radius: 20px;
429
+ padding: 1.5rem;
430
+ box-shadow: var(--shadow-lg);
431
+ }
432
+
433
+ .history-list {
434
+ display: flex;
435
+ flex-direction: column;
436
+ gap: 0.75rem;
437
+ max-height: 300px;
438
+ overflow-y: auto;
439
+ }
440
+
441
+ .history-item {
442
+ padding: 1rem;
443
+ background: var(--light);
444
+ border-radius: 12px;
445
+ display: flex;
446
+ justify-content: space-between;
447
+ align-items: center;
448
+ transition: all 0.3s;
449
+ }
450
+
451
+ .history-item:hover {
452
+ background: white;
453
+ transform: translateX(5px);
454
+ }
455
+
456
+ .history-info {
457
+ flex: 1;
458
+ min-width: 0;
459
+ }
460
+
461
+ .history-type {
462
+ font-weight: 600;
463
+ color: var(--primary);
464
+ margin-bottom: 0.25rem;
465
+ font-size: 0.9rem;
466
+ }
467
+
468
+ .history-time {
469
+ font-size: 0.75rem;
470
+ color: #64748b;
471
+ }
472
+
473
+ .history-actions {
474
+ display: flex;
475
+ gap: 0.25rem;
476
+ }
477
+
478
+ .icon-btn {
479
+ width: 32px;
480
+ height: 32px;
481
+ border-radius: 8px;
482
+ border: none;
483
+ background: white;
484
+ color: var(--primary);
485
+ cursor: pointer;
486
+ transition: all 0.3s;
487
+ display: flex;
488
+ align-items: center;
489
+ justify-content: center;
490
+ font-size: 0.9rem;
491
+ }
492
+
493
+ .icon-btn:hover {
494
+ background: var(--primary);
495
+ color: white;
496
+ }
497
+
498
+ .toast {
499
+ position: fixed;
500
+ bottom: 2rem;
501
+ right: 1rem;
502
+ left: 1rem;
503
+ padding: 1rem;
504
+ background: white;
505
+ border-radius: 12px;
506
+ box-shadow: var(--shadow-lg);
507
+ display: flex;
508
+ align-items: center;
509
+ gap: 1rem;
510
+ transform: translateY(100px);
511
+ transition: transform 0.3s;
512
+ z-index: 1000;
513
+ max-width: 400px;
514
+ margin: 0 auto;
515
+ }
516
+
517
+ .toast.show {
518
+ transform: translateY(0);
519
+ }
520
+
521
+ .toast-icon {
522
+ width: 30px;
523
+ height: 30px;
524
+ border-radius: 50%;
525
+ display: flex;
526
+ align-items: center;
527
+ justify-content: center;
528
+ flex-shrink: 0;
529
+ }
530
+
531
+ .toast.success .toast-icon {
532
+ background: var(--success);
533
+ color: white;
534
+ }
535
+
536
+ .toast.error .toast-icon {
537
+ background: var(--danger);
538
+ color: white;
539
+ }
540
+
541
+ .toast.info .toast-icon {
542
+ background: var(--primary);
543
+ color: white;
544
+ }
545
+
546
+ .modal {
547
+ display: none;
548
+ position: fixed;
549
+ top: 0;
550
+ left: 0;
551
+ width: 100%;
552
+ height: 100%;
553
+ background: rgba(0, 0, 0, 0.5);
554
+ backdrop-filter: blur(5px);
555
+ align-items: center;
556
+ justify-content: center;
557
+ z-index: 200;
558
+ padding: 1rem;
559
+ }
560
+
561
+ .modal.active {
562
+ display: flex;
563
+ }
564
+
565
+ .modal-content {
566
+ background: white;
567
+ border-radius: 20px;
568
+ padding: 1.5rem;
569
+ max-width: 500px;
570
+ width: 100%;
571
+ max-height: 80vh;
572
+ overflow-y: auto;
573
+ animation: modalSlideIn 0.3s;
574
+ }
575
+
576
+ @keyframes modalSlideIn {
577
+ from { transform: translateY(-50px); opacity: 0; }
578
+ to { transform: translateY(0); opacity: 1; }
579
+ }
580
+
581
+ .modal-header {
582
+ display: flex;
583
+ justify-content: space-between;
584
+ align-items: center;
585
+ margin-bottom: 1.5rem;
586
+ }
587
+
588
+ .modal-close {
589
+ width: 30px;
590
+ height: 30px;
591
+ border-radius: 50%;
592
+ border: none;
593
+ background: var(--light);
594
+ cursor: pointer;
595
+ transition: all 0.3s;
596
+ }
597
+
598
+ .modal-close:hover {
599
+ background: var(--danger);
600
+ color: white;
601
+ }
602
+
603
+ .progress-bar {
604
+ width: 100%;
605
+ height: 6px;
606
+ background: var(--light);
607
+ border-radius: 3px;
608
+ overflow: hidden;
609
+ margin-top: 1rem;
610
+ }
611
+
612
+ .progress-fill {
613
+ height: 100%;
614
+ background: linear-gradient(90deg, var(--primary), var(--secondary));
615
+ border-radius: 3px;
616
+ width: 0;
617
+ transition: width 0.3s;
618
+ }
619
+
620
+ .format-options {
621
+ display: flex;
622
+ gap: 0.5rem;
623
+ margin-top: 1rem;
624
+ flex-wrap: wrap;
625
+ }
626
+
627
+ .format-chip {
628
+ padding: 0.5rem 0.75rem;
629
+ background: var(--light);
630
+ border: 2px solid transparent;
631
+ border-radius: 20px;
632
+ cursor: pointer;
633
+ transition: all 0.3s;
634
+ font-size: 0.85rem;
635
+ }
636
+
637
+ .format-chip:hover {
638
+ border-color: var(--primary);
639
+ }
640
+
641
+ .format-chip.active {
642
+ background: var(--primary);
643
+ color: white;
644
+ }
645
+
646
+ .scan-overlay {
647
+ position: fixed;
648
+ top: 0;
649
+ left: 0;
650
+ width: 100%;
651
+ height: 100%;
652
+ background: rgba(0, 0, 0, 0.8);
653
+ display: none;
654
+ align-items: center;
655
+ justify-content: center;
656
+ z-index: 300;
657
+ }
658
+
659
+ .scan-overlay.active {
660
+ display: flex;
661
+ }
662
+
663
+ .scan-content {
664
+ text-align: center;
665
+ color: white;
666
+ }
667
+
668
+ .scan-animation {
669
+ width: 200px;
670
+ height: 200px;
671
+ border: 3px solid var(--primary);
672
+ border-radius: 20px;
673
+ margin: 0 auto 2rem;
674
+ position: relative;
675
+ animation: scanPulse 1.5s infinite;
676
+ }
677
+
678
+ @keyframes scanPulse {
679
+ 0%, 100% { transform: scale(1); opacity: 1; }
680
+ 50% { transform: scale(1.1); opacity: 0.8; }
681
+ }
682
+
683
+ .scan-animation::before {
684
+ content: '📱';
685
+ position: absolute;
686
+ top: 50%;
687
+ left: 50%;
688
+ transform: translate(-50%, -50%);
689
+ font-size: 3rem;
690
+ }
691
+
692
+ @media (min-width: 768px) {
693
+ .app-container {
694
+ grid-template-columns: 1fr 1fr;
695
+ }
696
+
697
+ .data-types {
698
+ grid-template-columns: repeat(4, 1fr);
699
+ }
700
+
701
+ .action-buttons {
702
+ grid-template-columns: 1fr 1fr;
703
+ }
704
+
705
+ main {
706
+ padding: 0 2rem;
707
+ }
708
+ }
709
+
710
+ @media (min-width: 1024px) {
711
+ .toast {
712
+ left: auto;
713
+ right: 2rem;
714
+ }
715
+ }
716
+ </style>
717
  </head>
718
+
719
  <body>
720
+ <div class="animated-bg"></div>
721
+
722
+ <header>
723
+ <div class="header-content">
724
+ <div class="logo">
725
+ <div class="logo-icon">N</div>
726
+ <h1>NFC Hub</h1>
727
+ </div>
728
+ <div class="status-indicator" id="statusIndicator">
729
+ <span class="status-dot" id="statusDot"></span>
730
+ <span id="statusText">Checking NFC...</span>
731
+ </div>
732
+ <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank"
733
+ style="color: var(--primary); text-decoration: none; font-weight: 500; font-size: 0.85rem;">
734
+ Built with anycoder
735
+ </a>
736
+ </div>
737
+ </header>
738
+
739
+ <main>
740
+ <div class="nfc-mode-toggle">
741
+ <div>
742
+ <strong>NFC Mode:</strong>
743
+ <span id="modeText">Real NFC</span>
744
+ </div>
745
+ <div class="toggle-switch">
746
+ <span>Simulator</span>
747
+ <label class="switch">
748
+ <input type="checkbox" id="modeToggle">
749
+ <span class="slider"></span>
750
+ </label>
751
+ <span>Real NFC</span>
752
+ </div>
753
+ </div>
754
+
755
+ <div class="app-container">
756
+ <!-- NFC Device Panel -->
757
+ <div class="panel">
758
+ <div class="panel-header">
759
+ <div class="panel-icon" id="deviceIcon">📡</div>
760
+ <h2 id="deviceTitle">NFC Device</h2>
761
+ </div>
762
+ <div class="nfc-simulator">
763
+ <div class="nfc-device" id="nfcDevice">
764
+ <div class="nfc-symbol">📱</div>
765
+ </div>
766
+ <div class="data-types">
767
+ <div class="data-type-btn active" data-type="text">
768
+ <div class="data-type-icon">📝</div>
769
+ <div class="data-type-text">Text</div>
770
  </div>
771
+ <div class="data-type-btn" data-type="url">
772
+ <div class="data-type-icon">🔗</div>
773
+ <div class="data-type-text">URL</div>
774
  </div>
775
+ <div class="data-type-btn" data-type="contact">
776
+ <div class="data-type-icon">👤</div>
777
+ <div class="data-type-text">Contact</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
778
  </div>
779
+ <div class="data-type-btn" data-type="wifi">
780
+ <div class="data-type-icon">📶</div>
781
+ <div class="data-type-text">WiFi</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
782
  </div>
783
+ </div>
784
+ <button class="btn btn-success" id="scanBtn" style="display: none;">
785
+ <span>🔍</span>
786
+ <span>Scan NFC Tag</span>
787
+ </button>
788
  </div>
789
+ </div>
790
 
791
+ <!-- Data Input Panel -->
792
+ <div class="panel">
793
+ <div class="panel-header">
794
+ <div class="panel-icon">💾</div>
795
+ <h2>Data Input</h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
796
  </div>
797
+ <div class="data-input-section" id="dataInputSection">
798
+ <div class="input-group">
799
+ <label for="textInput">Text Message</label>
800
+ <textarea id="textInput" placeholder="Enter your text message here..." rows="3"></textarea>
801
+ </div>
802
+ <div class="format-options">
803
+ <div class="format-chip active" data-format="plain">Plain</div>
804
+ <div class="format-chip" data-format="json">JSON</div>
805
+ <div class="format-chip" data-format="base64">Base64</div>
806
+ <div class="format-chip" data-format="hex">Hex</div>
807
+ </div>
808
  </div>
809
+ <div class="action-buttons">
810
+ <button class="btn btn-success" id="writeBtn">
811
+ <span>✍️</span>
812
+ <span>Write to NFC</span>
813
+ </button>
814
+ <button class="btn btn-secondary" id="clearBtn">
815
+ <span>🗑️</span>
816
+ <span>Clear</span>
817
+ </button>
818
+ </div>
819
+ <div class="progress-bar">
820
+ <div class="progress-fill" id="progressBar"></div>
821
+ </div>
822
+ </div>
823
  </div>
824
 
825
+ <!-- History Section -->
826
+ <div class="history-section">
827
+ <div class="panel-header">
828
+ <div class="panel-icon">📋</div>
829
+ <h2>Transfer History</h2>
830
+ </div>
831
+ <div class="history-list" id="historyList">
832
+ <div class="history-item">
833
+ <div class="history-info">
834
+ <div class="history-type">📝 Welcome Message</div>
835
+ <div class="history-time">Just now</div>
836
+ </div>
837
+ <div class="history-actions">
838
+ <button class="icon-btn">👁️</button>
839
+ <button class="icon-btn">📋</button>
840
+ <button class="icon-btn">🔄</button>
841
+ </div>
842
+ </div>
843
+ </div>
844
  </div>
845
+ </main>
846
+
847
+ <!-- Scan Overlay -->
848
+ <div class="scan-overlay" id="scanOverlay">
849
+ <div class="scan-content">
850
+ <div class="scan-animation"></div>
851
+ <h2>Hold your device near an NFC tag</h2>
852
+ <p id="scanStatus">Waiting for tag...</p>
853
+ <button class="btn btn-danger" id="cancelScan" style="margin-top: 2rem;">
854
+ Cancel Scan
855
+ </button>
856
+ </div>
857
+ </div>
858
+
859
+ <!-- Modal for viewing data -->
860
+ <div class="modal" id="viewModal">
861
+ <div class="modal-content">
862
+ <div class="modal-header">
863
+ <h2>View Data</h2>
864
+ <button class="modal-close" id="closeModal">✕</button>
865
+ </div>
866
+ <div id="modalBody"></div>
867
+ </div>
868
+ </div>
869
+
870
+ <!-- Toast Notification -->
871
+ <div class="toast" id="toast">
872
+ <div class="toast-icon">✓</div>
873
+ <div class="toast-message" id="toastMessage">Operation successful!</div>
874
+ </div>
875
+
876
+ <script>
877
+ // Global state
878
+ let currentDataType = 'text';
879
+ let currentFormat = 'plain';
880
+ let transferHistory = [];
881
+ let isTransferring = false;
882
+ let useRealNFC = false;
883
+ let nfcSupported = false;
884
+ let nfcPermission = false;
885
+
886
+ // DOM elements
887
+ const nfcDevice = document.getElementById('nfcDevice');
888
+ const dataInputSection = document.getElementById('dataInputSection');
889
+ const writeBtn = document.getElementById('writeBtn');
890
+ const scanBtn = document.getElementById('scanBtn');
891
+ const clearBtn = document.getElementById('clearBtn');
892
+ const progressBar = document.getElementById('progressBar');
893
+ const historyList = document.getElementById('historyList');
894
+ const toast = document.getElementById('toast');
895
+ const toastMessage = document.getElementById('toastMessage');
896
+ const viewModal = document.getElementById('viewModal');
897
+ const modalBody = document.getElementById('modalBody');
898
+ const closeModal = document.getElementById('closeModal');
899
+ const modeToggle = document.getElementById('modeToggle');
900
+ const modeText = document.getElementById('modeText');
901
+ const deviceTitle = document.getElementById('deviceTitle');
902
+ const deviceIcon = document.getElementById('deviceIcon');
903
+ const statusText = document.getElementById('statusText');
904
+ const statusDot = document.getElementById('statusDot');
905
+ const scanOverlay = document.getElementById('scanOverlay');
906
+ const cancelScan = document.getElementById('cancelScan');
907
+ const scanStatus = document.getElementById('scanStatus');
908
+
909
+ // Data type templates
910
+ const dataTemplates = {
911
+ text: `
912
+ <div class="input-group">
913
+ <label for="textInput">Text Message</label>
914
+ <textarea id="textInput" placeholder="Enter your text message here..." rows="3"></textarea>
915
+ </div>
916
+ `,
917
+ url: `
918
+ <div class="input-group">
919
+ <label for="urlInput">URL</label>
920
+ <input type="url" id="urlInput" placeholder="https://example.com">
921
+ </div>
922
+ <div class="input-group">
923
+ <label for="urlTitle">Title (Optional)</label>
924
+ <input type="text" id="urlTitle" placeholder="Website Title">
925
+ </div>
926
+ `,
927
+ contact: `
928
+ <div class="input-group">
929
+ <label for="contactName">Name</label>
930
+ <input type="text" id="contactName" placeholder="John Doe">
931
+ </div>
932
+ <div class="input-group">
933
+ <label for="contactPhone">Phone</label>
934
+ <input type="tel" id="contactPhone" placeholder="+1234567890">
935
+ </div>
936
+ <div class="input-group">
937
+ <label for="contactEmail">Email</label>
938
+ <input type="email" id="contactEmail" placeholder="john@example.com">
939
+ </div>
940
+ `,
941
+ wifi: `
942
+ <div class="input-group">
943
+ <label for="wifiSSID">Network Name (SSID)</label>
944
+ <input type="text" id="wifiSSID" placeholder="MyWiFi">
945
+ </div>
946
+ <div class="input-group">
947
+ <label for="wifiPassword">Password</label>
948
+ <input type="password" id="wifiPassword" placeholder="••••••••">
949
+ </div>
950
+ <div class="input-group">
951
+ <label for="wifiSecurity">Security Type</label>
952
+ <select id="wifiSecurity">
953
+ <option value="WPA">WPA/WPA2</option>
954
+ <option value="WEP">WEP</option>
955
+ <option value="nopass">Open Network</option>
956
+ </select>
957
+ </div>
958
+ `
959
+ };
960
+
961
+ // Initialize NFC support check
962
+ async function checkNFCSupport() {
963
+ if ('NDEFReader' in window) {
964
+ nfcSupported = true;
965
+ try {
966
+ const ndef = new NDEFReader();
967
+ await ndef.scan();
968
+ nfcPermission = true;
969
+ updateStatus('NFC Ready', true);
970
+ modeToggle.checked = true;
971
+ useRealNFC = true;
972
+ updateNFCMode(true);
973
+ } catch (error) {
974
+ if (error.name === 'NotAllowedError') {
975
+ updateStatus('NFC Permission Required', false);
976
+ showToast('NFC permission required. Please grant access.', 'info');
977
+ } else {
978
+ updateStatus('NFC Error', false);
979
+ }
980
+ }
981
+ } else {
982
+ nfcSupported = false;
983
+ updateStatus('NFC Not Supported', false);
984
+ modeToggle.checked = false;
985
+ useRealNFC = false;
986
+ updateNFCMode(false);
987
+ }
988
+ }
989
+
990
+ function updateStatus(text, success) {
991
+ statusText.textContent = text;
992
+ if (success) {
993
+ statusDot.classList.remove('error');
994
+ } else {
995
+ statusDot.classList.add('error');
996
+ }
997
+ }
998
+
999
+ function updateNFCMode(useReal) {
1000
+ useRealNFC = useReal;
1001
+ if (useReal) {
1002
+ modeText.textContent = 'Real NFC';
1003
+ deviceTitle.textContent = 'NFC Device';
1004
+ deviceIcon.textContent = '📱';
1005
+ scanBtn.style.display = 'block';
1006
+ writeBtn.innerHTML = '<span>✍️</span><span>Write to NFC</span>';
1007
+ } else {
1008
+ modeText.textContent = 'Simulator';
1009
+ deviceTitle.textContent = 'NFC Simulator';
1010
+ deviceIcon.textContent = '📡';
1011
+ scanBtn.style.display = 'none';
1012
+ writeBtn.innerHTML = '<span>⚡</span><span>Transfer Data</span>';
1013
+ }
1014
+ }
1015
+
1016
+ // Event listeners
1017
+ modeToggle.addEventListener('change', (e) => {
1018
+ updateNFCMode(e.target.checked);
1019
+ if (e.target.checked && !nfcSupported) {
1020
+ showToast('NFC not supported on this device', 'error');
1021
+ modeToggle.checked = false;
1022
+ updateNFCMode(false);
1023
+ }
1024
+ });
1025
+
1026
+ document.querySelectorAll('.data-type-btn').forEach(btn => {
1027
+ btn.addEventListener('click', function() {
1028
+ document.querySelectorAll('.data-type-btn').forEach(b => b.classList.remove('active'));
1029
+ this.classList.add('active');
1030
+ currentDataType = this.dataset.type;
1031
+ updateDataInput();
1032
+ });
1033
+ });
1034
+
1035
+ document.querySelectorAll('.format-chip').forEach(chip => {
1036
+ chip.addEventListener('click', function() {
1037
+ document.querySelectorAll('.format-chip').forEach(c => c.classList.remove('active'));
1038
+ this.classList.add('active');
1039
+ currentFormat = this.dataset.format;
1040
+ });
1041
+ });
1042
+
1043
+ nfcDevice.addEventListener('click', () => {
1044
+ if (useRealNFC) {
1045
+ requestNFCTap();
1046
+ } else {
1047
+ simulateTransfer();
1048
+ }
1049
+ });
1050
+
1051
+ writeBtn.addEventListener('click', () => {
1052
+ if (useRealNFC) {
1053
+ writeToNFC();
1054
+ } else {
1055
+ initiateTransfer();
1056
+ }
1057
+ });
1058
+
1059
+ clearBtn.addEventListener('click', clearData);
1060
+ scanBtn.addEventListener('click', scanNFC);
1061
+ cancelScan.addEventListener('click', () => {
1062
+ scanOverlay.classList.remove('active');
1063
+ });
1064
+ closeModal.addEventListener('click', () => viewModal.classList.remove('active'));
1065
+
1066
+ function updateDataInput() {
1067
+ dataInputSection.innerHTML = dataTemplates[currentDataType] + `
1068
+ <div class="format-options">
1069
+ <div class="format-chip ${currentFormat === 'plain' ? 'active' : ''}" data-format="plain">Plain</div>
1070
+ <div class="format-chip ${currentFormat === 'json' ? 'active' : ''}" data-format="json">JSON</div>
1071
+ <div class="format-chip ${currentFormat === 'base64' ? 'active' : ''}" data-format="base64">Base64</div>
1072
+ <div class="format-chip ${currentFormat === 'hex' ? 'active' : ''}" data-format="hex">Hex</div>
1073
+ </div>
1074
+ `;
1075
+
1076
+ // Re-attach format chip listeners
1077
+ document.querySelectorAll('.format-chip').forEach(chip => {
1078
+ chip.addEventListener('click', function() {
1079
+ document.querySelectorAll('.format-chip').forEach(c => c.classList.remove('active'));
1080
+ this.classList.add('active');
1081
+ currentFormat = this.dataset.format;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1082
  });
1083
+ });
1084
+ }
1085
+
1086
+ function simulateTransfer() {
1087
+ if (isTransferring) return;
1088
+ nfcDevice.classList.add('active');
1089
+ setTimeout(() => {
1090
+ nfcDevice.classList.remove('active');
1091
+ }, 1000);
1092
+ }
1093
+
1094
+ async function requestNFCTap() {
1095
+ if (!nfcSupported || !nfcPermission) {
1096
+ showToast('NFC not available or permission denied', 'error');
1097
+ return;
1098
+ }
1099
+
1100
+ showToast('Tap your phone on an NFC tag', 'info');
1101
+ nfcDevice.classList.add('active');
1102
+
1103
+ setTimeout(() => {
1104
+ nfcDevice.classList.remove('active');
1105
+ }, 2000);
1106
+ }
1107
+
1108
+ async function scanNFC() {
1109
+ if (!nfcSupported) {
1110
+ showToast('NFC not supported', 'error');
1111
+ return;
1112
+ }
1113
+
1114
+ try {
1115
+ const ndef = new NDEFReader();
1116
+ scanOverlay.classList.add('active');
1117
+ scanStatus.textContent = 'Scanning for NFC tags...';
1118
+
1119
+ await ndef.scan();
1120
+ showToast('Ready to scan', 'success');
1121
+
1122
+ ndef.addEventListener("reading", ({ message, serialNumber }) => {
1123
+ scanOverlay.classList.remove('active');
1124
+ handleNFCRead(message, serialNumber);
1125
  });
1126
+
1127
+ } catch (error) {
1128
+ scanOverlay.classList.remove('active');
1129
+ showToast('Failed to start NFC scan: ' + error.message, 'error');
1130
+ }
1131
+ }
1132
+
1133
+ function handleNFCRead(message, serialNumber) {
1134
+ let data = {
1135
+ type: 'text',
1136
+ content: '',
1137
+ serialNumber: serialNumber,
1138
+ timestamp: new Date()
1139
+ };
1140
+
1141
+ for (const record of message.records) {
1142
+ if (record.recordType === "text") {
1143
+ const textDecoder = new TextDecoder(record.encoding);
1144
+ data.content = textDecoder.decode(record.data);
1145
+ data.type = 'text';
1146
+ } else if (record.recordType === "url") {
1147
+ const textDecoder = new TextDecoder();
1148
+ data.content = textDecoder.decode(record.data);
1149
+ data.type = 'url';
1150
+ }
1151
+ }
1152
+
1153
+ const historyItem = {
1154
+ id: Date.now(),
1155
+ type: 'read',
1156
+ data: data,
1157
+ timestamp: new Date()
1158
+ };
1159
+
1160
+ transferHistory.unshift(historyItem);
1161
+ updateHistoryDisplay();
1162
+ showToast('NFC data read successfully!', 'success');
1163
+ }
1164
+
1165
+ async function writeToNFC() {
1166
+ if (!nfcSupported) {
1167
+ showToast('NFC not supported', 'error');
1168
+ return;
1169
+ }
1170
+
1171
+ const data = collectData();
1172
+ if (!validateData(data)) {
1173
+ showToast('Please fill in the required fields', 'error');
1174
+ return;
1175
+ }
1176
+
1177
+ try {
1178
+ isTransferring = true;