-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1493 lines (1314 loc) · 66.7 KB
/
Copy pathindex.html
File metadata and controls
1493 lines (1314 loc) · 66.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en" class="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nebula Notes | Futuristic Note-Taking App</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
colors: {
primary: {
100: '#a5f3fc',
200: '#67e8f9',
300: '#22d3ee',
400: '#06b6d4',
500: '#0891b2',
600: '#0e7490',
700: '#155e75',
},
dark: {
800: '#1e293b',
900: '#0f172a',
950: '#020617',
}
},
animation: {
'float': 'float 6s ease-in-out infinite',
'fade-in': 'fadeIn 0.5s ease-in',
},
keyframes: {
float: {
'0%, 100%': { transform: 'translateY(0)' },
'50%': { transform: 'translateY(-20px)' },
},
fadeIn: {
'0%': { opacity: '0' },
'100%': { opacity: '1' },
}
}
}
}
}
</script>
<!-- Bootstrap Icons -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
<!-- Material Icons -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons+Round" rel="stylesheet">
<!-- Anime.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js"></script>
<!-- Custom CSS -->
<style>
.glassmorphism {
background: rgba(15, 23, 42, 0.7);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.1);
}
.gradient-text {
background: linear-gradient(90deg, #22d3ee, #0ea5e9);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.btn-3d {
transition: all 0.3s ease;
box-shadow: 0 4px 0 #0e7490, 0 5px 10px rgba(0, 0, 0, 0.2);
}
.btn-3d:hover {
transform: translateY(-2px);
box-shadow: 0 6px 0 #0e7490, 0 8px 15px rgba(0, 0, 0, 0.3);
}
.btn-3d:active {
transform: translateY(2px);
box-shadow: 0 2px 0 #0e7490, 0 3px 5px rgba(0, 0, 0, 0.2);
}
.note-card {
transition: all 0.3s ease;
transform-style: preserve-3d;
perspective: 1000px;
}
.note-card:hover {
transform: translateY(-5px) rotateX(5deg);
box-shadow: 0 20px 30px rgba(0, 0, 0, 0.3);
}
.markdown-content h1 {
font-size: 2em;
font-weight: bold;
margin: 0.67em 0;
}
.markdown-content h2 {
font-size: 1.5em;
font-weight: bold;
margin: 0.83em 0;
}
.markdown-content ul {
list-style-type: disc;
padding-left: 2em;
}
.markdown-content ol {
list-style-type: decimal;
padding-left: 2em;
}
.markdown-content pre {
background: rgba(0, 0, 0, 0.2);
padding: 1em;
border-radius: 0.5em;
overflow-x: auto;
}
.markdown-content code {
font-family: monospace;
background: rgba(0, 0, 0, 0.2);
padding: 0.2em 0.4em;
border-radius: 0.3em;
}
.markdown-content blockquote {
border-left: 4px solid #22d3ee;
padding-left: 1em;
margin-left: 0;
color: #94a3b8;
}
/* Scrollbar styling */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: rgba(15, 23, 42, 0.5);
}
::-webkit-scrollbar-thumb {
background: #22d3ee;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #0ea5e9;
}
</style>
</head>
<body class="bg-dark-900 text-gray-200 min-h-screen flex flex-col">
<!-- Firebase SDK -->
<script src="https://www.gstatic.com/firebasejs/8.10.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.10.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.10.0/firebase-firestore.js"></script>
<script>
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyBj-41w7tC-in8Zl2MBnLip3vCxos6pTO0",
authDomain: "note-taking-bb637.firebaseapp.com",
projectId: "note-taking-bb637",
storageBucket: "note-taking-bb637.firebasestorage.app",
messagingSenderId: "262967302546",
appId: "1:262967302546:web:47125e648b8a17e93fc94b",
measurementId: "G-HC7RLJ61YQ"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
const auth = firebase.auth();
const db = firebase.firestore();
</script>
<!-- Auth Modal -->
<div id="authModal" class="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-70 hidden">
<div class="glassmorphism rounded-2xl p-8 max-w-md w-full mx-4 animate-fade-in">
<div class="flex justify-between items-center mb-6">
<h2 class="text-2xl font-bold gradient-text">Welcome to Nebula Notes</h2>
<button id="closeAuthModal" class="text-gray-400 hover:text-white">
<i class="material-icons-round">close</i>
</button>
</div>
<div class="space-y-4">
<button id="googleSignIn" class="w-full btn-3d bg-primary-500 hover:bg-primary-400 text-white py-3 px-4 rounded-lg flex items-center justify-center gap-2">
<i class="bi bi-google text-xl"></i>
Continue with Google
</button>
<div class="flex items-center my-4">
<div class="flex-1 border-t border-gray-700"></div>
<span class="px-3 text-gray-400">or</span>
<div class="flex-1 border-t border-gray-700"></div>
</div>
<div class="space-y-3">
<div>
<label for="email" class="block text-sm font-medium text-gray-300 mb-1">Email</label>
<input type="email" id="email" class="w-full bg-dark-800 border border-gray-700 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-primary-500">
</div>
<div>
<label for="password" class="block text-sm font-medium text-gray-300 mb-1">Password</label>
<input type="password" id="password" class="w-full bg-dark-800 border border-gray-700 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-primary-500">
</div>
</div>
<div class="flex justify-between items-center pt-2">
<button id="signInBtn" class="btn-3d bg-primary-600 hover:bg-primary-500 text-white py-2 px-6 rounded-lg">
Sign In
</button>
<button id="signUpBtn" class="text-primary-300 hover:text-primary-200 text-sm">
Create Account
</button>
</div>
</div>
</div>
</div>
<!-- Voice Input Modal -->
<div id="voiceModal" class="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-70 hidden">
<div class="glassmorphism rounded-2xl p-8 max-w-md w-full mx-4 animate-fade-in">
<div class="flex justify-between items-center mb-6">
<h2 class="text-2xl font-bold gradient-text">Voice Note</h2>
<button id="closeVoiceModal" class="text-gray-400 hover:text-white">
<i class="material-icons-round">close</i>
</button>
</div>
<div class="text-center py-8">
<div id="voiceStatus" class="text-xl mb-4">Click the microphone to start recording</div>
<button id="voiceRecordBtn" class="p-4 bg-primary-600 rounded-full hover:bg-primary-500 transition-all">
<i class="material-icons-round text-4xl">mic</i>
</button>
<div id="voiceTimer" class="mt-4 text-gray-400">00:00</div>
</div>
<div class="mt-6">
<textarea id="voiceResult" class="w-full bg-dark-800 border border-gray-700 rounded-lg px-4 py-2 h-32 focus:outline-none focus:ring-2 focus:ring-primary-500" placeholder="Your transcribed text will appear here..."></textarea>
</div>
<div class="flex justify-end gap-3 mt-4">
<button id="cancelVoiceBtn" class="px-4 py-2 rounded-lg border border-gray-700 hover:bg-dark-800">
Cancel
</button>
<button id="insertVoiceBtn" class="px-4 py-2 rounded-lg bg-primary-600 hover:bg-primary-500">
Insert Note
</button>
</div>
</div>
</div>
<!-- Export/Import Modal -->
<div id="exportImportModal" class="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-70 hidden">
<div class="glassmorphism rounded-2xl p-8 max-w-md w-full mx-4 animate-fade-in">
<div class="flex justify-between items-center mb-6">
<h2 class="text-2xl font-bold gradient-text">Export/Import Notes</h2>
<button id="closeExportImportModal" class="text-gray-400 hover:text-white">
<i class="material-icons-round">close</i>
</button>
</div>
<div class="space-y-6">
<div>
<h3 class="text-lg font-semibold mb-3 flex items-center gap-2">
<i class="material-icons-round">file_download</i>
Export Notes
</h3>
<p class="text-gray-400 mb-3">Export all your notes as a JSON file for backup or transfer.</p>
<button id="exportNotesBtn" class="w-full btn-3d bg-primary-600 hover:bg-primary-500 text-white py-3 px-4 rounded-lg flex items-center justify-center gap-2">
<i class="material-icons-round">save_alt</i>
Export Notes
</button>
</div>
<div class="border-t border-gray-700 pt-6">
<h3 class="text-lg font-semibold mb-3 flex items-center gap-2">
<i class="material-icons-round">file_upload</i>
Import Notes
</h3>
<p class="text-gray-400 mb-3">Import notes from a previously exported JSON file.</p>
<input type="file" id="importFileInput" class="hidden" accept=".json">
<button id="importNotesBtn" class="w-full btn-3d bg-primary-600 hover:bg-primary-500 text-white py-3 px-4 rounded-lg flex items-center justify-center gap-2">
<i class="material-icons-round">upload</i>
Choose File to Import
</button>
<div id="importFileName" class="text-sm text-gray-400 mt-2 hidden"></div>
</div>
</div>
</div>
</div>
<!-- Main App Layout -->
<div class="flex flex-1 overflow-hidden">
<!-- Sidebar -->
<div class="hidden md:flex md:w-64 bg-dark-800 flex-col border-r border-gray-800">
<div class="p-4 border-b border-gray-800 flex items-center justify-between">
<h1 class="text-xl font-bold flex items-center gap-2">
<i class="material-icons-round text-primary-400">auto_awesome</i>
<span class="gradient-text">Nebula Notes</span>
</h1>
<button id="toggleDarkMode" class="text-gray-400 hover:text-white p-1 rounded-full">
<i class="material-icons-round text-xl">dark_mode</i>
</button>
</div>
<div class="p-4 space-y-1">
<button id="newNoteBtn" class="w-full btn-3d bg-primary-600 hover:bg-primary-500 text-white py-2 px-4 rounded-lg flex items-center justify-center gap-2">
<i class="material-icons-round">add</i>
New Note
</button>
</div>
<div class="p-4 border-t border-gray-800">
<h3 class="text-sm uppercase text-gray-500 mb-2">Collections</h3>
<ul class="space-y-1">
<li>
<button class="w-full text-left flex items-center gap-2 px-3 py-2 rounded-lg hover:bg-dark-700 text-gray-300 hover:text-white">
<i class="material-icons-round text-primary-400">inbox</i>
All Notes
</button>
</li>
<li>
<button class="w-full text-left flex items-center gap-2 px-3 py-2 rounded-lg hover:bg-dark-700 text-gray-300 hover:text-white">
<i class="material-icons-round text-yellow-400">star</i>
Starred
</button>
</li>
<li>
<button class="w-full text-left flex items-center gap-2 px-3 py-2 rounded-lg hover:bg-dark-700 text-gray-300 hover:text-white">
<i class="material-icons-round text-red-400">schedule</i>
Reminders
</button>
</li>
<li>
<button class="w-full text-left flex items-center gap-2 px-3 py-2 rounded-lg hover:bg-dark-700 text-gray-300 hover:text-white">
<i class="material-icons-round text-green-400">delete</i>
Trash
</button>
</li>
</ul>
</div>
<div class="p-4 border-t border-gray-800 flex-1">
<h3 class="text-sm uppercase text-gray-500 mb-2">Tags</h3>
<div class="space-y-1" id="tagsList">
<!-- Tags will be dynamically added here -->
</div>
<div class="mt-3">
<button id="addTagBtn" class="flex items-center gap-2 text-gray-400 hover:text-white text-sm">
<i class="material-icons-round text-sm">add</i>
Add Tag
</button>
</div>
</div>
<div class="p-4 border-t border-gray-800">
<div class="flex items-center gap-3">
<div class="w-8 h-8 rounded-full bg-primary-600 flex items-center justify-center">
<i class="material-icons-round text-sm">person</i>
</div>
<div class="flex-1">
<div class="text-sm font-medium" id="userEmail">Guest</div>
<button id="signOutBtn" class="text-xs text-gray-400 hover:text-primary-300">Sign Out</button>
</div>
</div>
</div>
</div>
<!-- Mobile Sidebar Toggle -->
<button id="mobileSidebarToggle" class="md:hidden fixed bottom-6 right-6 z-40 w-14 h-14 rounded-full bg-primary-600 shadow-lg flex items-center justify-center text-white btn-3d">
<i class="material-icons-round text-2xl">menu</i>
</button>
<!-- Mobile Sidebar -->
<div id="mobileSidebar" class="fixed inset-0 z-30 bg-dark-900 transform -translate-x-full md:hidden transition-transform duration-300 ease-in-out">
<div class="p-4 flex items-center justify-between border-b border-gray-800">
<h1 class="text-xl font-bold flex items-center gap-2">
<i class="material-icons-round text-primary-400">auto_awesome</i>
<span class="gradient-text">Nebula Notes</span>
</h1>
<button id="closeMobileSidebar" class="text-gray-400 hover:text-white p-1 rounded-full">
<i class="material-icons-round text-xl">close</i>
</button>
</div>
<div class="p-4 space-y-4 overflow-y-auto h-full">
<button id="mobileNewNoteBtn" class="w-full btn-3d bg-primary-600 hover:bg-primary-500 text-white py-3 px-4 rounded-lg flex items-center justify-center gap-2">
<i class="material-icons-round">add</i>
New Note
</button>
<div class="space-y-1">
<h3 class="text-sm uppercase text-gray-500 mb-2">Collections</h3>
<ul class="space-y-1">
<li>
<button class="w-full text-left flex items-center gap-2 px-3 py-2 rounded-lg hover:bg-dark-700 text-gray-300 hover:text-white">
<i class="material-icons-round text-primary-400">inbox</i>
All Notes
</button>
</li>
<li>
<button class="w-full text-left flex items-center gap-2 px-3 py-2 rounded-lg hover:bg-dark-700 text-gray-300 hover:text-white">
<i class="material-icons-round text-yellow-400">star</i>
Starred
</button>
</li>
<li>
<button class="w-full text-left flex items-center gap-2 px-3 py-2 rounded-lg hover:bg-dark-700 text-gray-300 hover:text-white">
<i class="material-icons-round text-red-400">schedule</i>
Reminders
</button>
</li>
<li>
<button class="w-full text-left flex items-center gap-2 px-3 py-2 rounded-lg hover:bg-dark-700 text-gray-300 hover:text-white">
<i class="material-icons-round text-green-400">delete</i>
Trash
</button>
</li>
</ul>
</div>
<div class="space-y-1">
<h3 class="text-sm uppercase text-gray-500 mb-2">Tags</h3>
<div class="space-y-1" id="mobileTagsList">
<!-- Tags will be dynamically added here -->
</div>
<div class="mt-3">
<button class="flex items-center gap-2 text-gray-400 hover:text-white text-sm">
<i class="material-icons-round text-sm">add</i>
Add Tag
</button>
</div>
</div>
<div class="pt-4 border-t border-gray-800">
<div class="flex items-center gap-3">
<div class="w-8 h-8 rounded-full bg-primary-600 flex items-center justify-center">
<i class="material-icons-round text-sm">person</i>
</div>
<div class="flex-1">
<div class="text-sm font-medium" id="mobileUserEmail">Guest</div>
<button id="mobileSignOutBtn" class="text-xs text-gray-400 hover:text-primary-300">Sign Out</button>
</div>
</div>
</div>
</div>
</div>
<!-- Main Content -->
<div class="flex-1 flex flex-col overflow-hidden">
<!-- Top Bar -->
<div class="bg-dark-800 border-b border-gray-800 p-4 flex items-center justify-between">
<div class="flex items-center gap-4">
<button id="sidebarToggle" class="text-gray-400 hover:text-white md:hidden">
<i class="material-icons-round">menu</i>
</button>
<h2 class="text-lg font-semibold" id="currentCollection">All Notes</h2>
</div>
<div class="flex items-center gap-3">
<button id="voiceNoteBtn" class="p-2 text-gray-400 hover:text-white rounded-full hover:bg-dark-700">
<i class="material-icons-round">keyboard_voice</i>
</button>
<button id="exportImportBtn" class="p-2 text-gray-400 hover:text-white rounded-full hover:bg-dark-700">
<i class="material-icons-round">import_export</i>
</button>
<div class="relative">
<input type="text" id="searchNotes" placeholder="Search notes..." class="bg-dark-700 border border-gray-700 rounded-lg px-4 py-2 pl-10 focus:outline-none focus:ring-2 focus:ring-primary-500 w-40 md:w-64 transition-all duration-300">
<i class="material-icons-round absolute left-3 top-2.5 text-gray-500">search</i>
</div>
</div>
</div>
<!-- Notes List and Editor -->
<div class="flex flex-1 overflow-hidden">
<!-- Notes List -->
<div class="w-full md:w-80 border-r border-gray-800 bg-dark-800 overflow-y-auto">
<div class="p-3">
<div class="grid grid-cols-2 gap-2 mb-3">
<button class="py-1 px-3 rounded-lg text-sm bg-dark-700 text-gray-300 hover:bg-dark-600">
All
</button>
<button class="py-1 px-3 rounded-lg text-sm bg-dark-700 text-gray-300 hover:bg-dark-600">
Recent
</button>
</div>
<div id="notesList" class="space-y-2">
<!-- Notes will be dynamically added here -->
<div class="text-center py-10 text-gray-500" id="emptyNotesMessage">
<i class="material-icons-round text-4xl mb-2">note_add</i>
<p>No notes yet. Create your first note!</p>
</div>
</div>
</div>
</div>
<!-- Note Editor -->
<div class="flex-1 flex flex-col overflow-hidden bg-dark-900">
<div id="noNoteSelected" class="flex-1 flex flex-col items-center justify-center text-gray-500 p-6 text-center">
<div class="max-w-md animate-float">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="w-24 h-24 mx-auto text-primary-400">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
<polyline points="14 2 14 8 20 8"></polyline>
<line x1="16" y1="13" x2="8" y2="13"></line>
<line x1="16" y1="17" x2="8" y2="17"></line>
<polyline points="10 9 9 9 8 9"></polyline>
</svg>
</div>
<h3 class="text-xl font-medium mt-6 mb-2">No note selected</h3>
<p class="text-gray-400 mb-6">Select a note from the list or create a new one to get started</p>
<button id="editorNewNoteBtn" class="btn-3d bg-primary-600 hover:bg-primary-500 text-white py-2 px-6 rounded-lg flex items-center gap-2">
<i class="material-icons-round">add</i>
New Note
</button>
</div>
<div id="noteEditor" class="hidden flex-1 flex flex-col">
<div class="p-4 border-b border-gray-800 flex justify-between items-center">
<input type="text" id="noteTitle" placeholder="Note Title" class="bg-transparent text-xl font-semibold w-full focus:outline-none focus:ring-0">
<div class="flex items-center gap-2">
<button id="saveNoteBtn" class="p-2 text-gray-400 hover:text-white rounded-full hover:bg-dark-700">
<i class="material-icons-round">save</i>
</button>
<button id="deleteNoteBtn" class="p-2 text-gray-400 hover:text-red-400 rounded-full hover:bg-dark-700">
<i class="material-icons-round">delete</i>
</button>
<button id="moreActionsBtn" class="p-2 text-gray-400 hover:text-white rounded-full hover:bg-dark-700">
<i class="material-icons-round">more_vert</i>
</button>
</div>
</div>
<div class="p-4 border-b border-gray-800 flex items-center gap-2 overflow-x-auto">
<button class="p-1 text-gray-400 hover:text-white rounded hover:bg-dark-700" data-command="bold">
<i class="material-icons-round">format_bold</i>
</button>
<button class="p-1 text-gray-400 hover:text-white rounded hover:bg-dark-700" data-command="italic">
<i class="material-icons-round">format_italic</i>
</button>
<button class="p-1 text-gray-400 hover:text-white rounded hover:bg-dark-700" data-command="insertUnorderedList">
<i class="material-icons-round">format_list_bulleted</i>
</button>
<button class="p-1 text-gray-400 hover:text-white rounded hover:bg-dark-700" data-command="insertOrderedList">
<i class="material-icons-round">format_list_numbered</i>
</button>
<button class="p-1 text-gray-400 hover:text-white rounded hover:bg-dark-700" data-command="createLink">
<i class="material-icons-round">link</i>
</button>
<button class="p-1 text-gray-400 hover:text-white rounded hover:bg-dark-700" data-command="insertImage">
<i class="material-icons-round">image</i>
</button>
<button class="p-1 text-gray-400 hover:text-white rounded hover:bg-dark-700" data-command="code">
<i class="material-icons-round">code</i>
</button>
<button class="p-1 text-gray-400 hover:text-white rounded hover:bg-dark-700" data-command="quote">
<i class="material-icons-round">format_quote</i>
</button>
<div class="border-l border-gray-700 h-6 mx-1"></div>
<button class="p-1 text-gray-400 hover:text-white rounded hover:bg-dark-700" data-command="undo">
<i class="material-icons-round">undo</i>
</button>
<button class="p-1 text-gray-400 hover:text-white rounded hover:bg-dark-700" data-command="redo">
<i class="material-icons-round">redo</i>
</button>
</div>
<div class="flex-1 overflow-auto">
<div id="noteContent" class="p-6 min-h-full markdown-content" contenteditable="true" data-placeholder="Start typing your note here..."></div>
</div>
<div class="p-4 border-t border-gray-800 flex items-center justify-between">
<div class="flex items-center gap-2">
<button id="addTagToNote" class="text-xs bg-dark-700 hover:bg-dark-600 text-gray-300 px-3 py-1 rounded-full flex items-center gap-1">
<i class="material-icons-round text-sm">local_offer</i>
Add Tag
</button>
<div id="noteTags" class="flex flex-wrap gap-1">
<!-- Tags will be dynamically added here -->
</div>
</div>
<div class="text-xs text-gray-500">
Last saved: <span id="lastSavedTime">Just now</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Toast Notifications -->
<div id="toastContainer" class="fixed bottom-4 right-4 space-y-2 z-50"></div>
<!-- App Script -->
<script>
// DOM Elements
const authModal = document.getElementById('authModal');
const closeAuthModal = document.getElementById('closeAuthModal');
const googleSignIn = document.getElementById('googleSignIn');
const signInBtn = document.getElementById('signInBtn');
const signUpBtn = document.getElementById('signUpBtn');
const signOutBtn = document.getElementById('signOutBtn');
const mobileSignOutBtn = document.getElementById('mobileSignOutBtn');
const userEmail = document.getElementById('userEmail');
const mobileUserEmail = document.getElementById('mobileUserEmail');
const voiceModal = document.getElementById('voiceModal');
const closeVoiceModal = document.getElementById('closeVoiceModal');
const voiceRecordBtn = document.getElementById('voiceRecordBtn');
const voiceStatus = document.getElementById('voiceStatus');
const voiceTimer = document.getElementById('voiceTimer');
const voiceResult = document.getElementById('voiceResult');
const cancelVoiceBtn = document.getElementById('cancelVoiceBtn');
const insertVoiceBtn = document.getElementById('insertVoiceBtn');
const voiceNoteBtn = document.getElementById('voiceNoteBtn');
const exportImportModal = document.getElementById('exportImportModal');
const closeExportImportModal = document.getElementById('closeExportImportModal');
const exportImportBtn = document.getElementById('exportImportBtn');
const exportNotesBtn = document.getElementById('exportNotesBtn');
const importNotesBtn = document.getElementById('importNotesBtn');
const importFileInput = document.getElementById('importFileInput');
const importFileName = document.getElementById('importFileName');
const sidebarToggle = document.getElementById('sidebarToggle');
const mobileSidebarToggle = document.getElementById('mobileSidebarToggle');
const mobileSidebar = document.getElementById('mobileSidebar');
const closeMobileSidebar = document.getElementById('closeMobileSidebar');
const toggleDarkMode = document.getElementById('toggleDarkMode');
const newNoteBtn = document.getElementById('newNoteBtn');
const mobileNewNoteBtn = document.getElementById('mobileNewNoteBtn');
const editorNewNoteBtn = document.getElementById('editorNewNoteBtn');
const notesList = document.getElementById('notesList');
const emptyNotesMessage = document.getElementById('emptyNotesMessage');
const noNoteSelected = document.getElementById('noNoteSelected');
const noteEditor = document.getElementById('noteEditor');
const noteTitle = document.getElementById('noteTitle');
const noteContent = document.getElementById('noteContent');
const saveNoteBtn = document.getElementById('saveNoteBtn');
const deleteNoteBtn = document.getElementById('deleteNoteBtn');
const moreActionsBtn = document.getElementById('moreActionsBtn');
const lastSavedTime = document.getElementById('lastSavedTime');
const addTagToNote = document.getElementById('addTagToNote');
const noteTags = document.getElementById('noteTags');
const searchNotes = document.getElementById('searchNotes');
const tagsList = document.getElementById('tagsList');
const mobileTagsList = document.getElementById('mobileTagsList');
const addTagBtn = document.getElementById('addTagBtn');
const toastContainer = document.getElementById('toastContainer');
// App State
let currentUser = null;
let notes = [];
let tags = [];
let currentNoteId = null;
let isRecording = false;
let recognition;
let recordingStartTime;
let recordingInterval;
// Initialize the app
function init() {
setupEventListeners();
checkAuthState();
initVoiceRecognition();
animateElements();
}
// Set up event listeners
function setupEventListeners() {
// Auth related
closeAuthModal.addEventListener('click', () => authModal.classList.add('hidden'));
googleSignIn.addEventListener('click', signInWithGoogle);
signInBtn.addEventListener('click', signInWithEmail);
signUpBtn.addEventListener('click', signUpWithEmail);
signOutBtn.addEventListener('click', signOut);
mobileSignOutBtn.addEventListener('click', signOut);
// Voice note
voiceNoteBtn.addEventListener('click', () => voiceModal.classList.remove('hidden'));
closeVoiceModal.addEventListener('click', () => voiceModal.classList.add('hidden'));
voiceRecordBtn.addEventListener('click', toggleVoiceRecording);
cancelVoiceBtn.addEventListener('click', () => voiceModal.classList.add('hidden'));
insertVoiceBtn.addEventListener('click', insertVoiceNote);
// Export/Import
exportImportBtn.addEventListener('click', () => exportImportModal.classList.remove('hidden'));
closeExportImportModal.addEventListener('click', () => exportImportModal.classList.add('hidden'));
exportNotesBtn.addEventListener('click', exportNotes);
importNotesBtn.addEventListener('click', () => importFileInput.click());
importFileInput.addEventListener('change', handleFileImport);
// UI interactions
sidebarToggle.addEventListener('click', () => mobileSidebar.classList.remove('-translate-x-full'));
mobileSidebarToggle.addEventListener('click', () => mobileSidebar.classList.remove('-translate-x-full'));
closeMobileSidebar.addEventListener('click', () => mobileSidebar.classList.add('-translate-x-full'));
toggleDarkMode.addEventListener('click', toggleDarkModeHandler);
// Notes
newNoteBtn.addEventListener('click', createNewNote);
mobileNewNoteBtn.addEventListener('click', createNewNote);
editorNewNoteBtn.addEventListener('click', createNewNote);
saveNoteBtn.addEventListener('click', saveCurrentNote);
deleteNoteBtn.addEventListener('click', deleteCurrentNote);
// Search
searchNotes.addEventListener('input', searchNotesHandler);
// Editor commands
document.querySelectorAll('[data-command]').forEach(button => {
button.addEventListener('click', (e) => {
const command = e.target.closest('button').getAttribute('data-command');
execCommand(command);
});
});
// Auto-save on content change
noteContent.addEventListener('input', debounce(() => {
if (currentNoteId) {
saveCurrentNote();
}
}, 1000));
// Set placeholder for contenteditable
noteContent.addEventListener('focus', () => {
if (noteContent.textContent === '') {
noteContent.dataset.placeholder = '';
}
});
noteContent.addEventListener('blur', () => {
if (noteContent.textContent === '') {
noteContent.dataset.placeholder = 'Start typing your note here...';
}
});
}
// Initialize voice recognition
function initVoiceRecognition() {
recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
recognition.continuous = true;
recognition.interimResults = true;
recognition.onresult = (event) => {
let interimTranscript = '';
let finalTranscript = '';
for (let i = event.resultIndex; i < event.results.length; i++) {
const transcript = event.results[i][0].transcript;
if (event.results[i].isFinal) {
finalTranscript += transcript;
} else {
interimTranscript += transcript;
}
}
voiceResult.value = finalTranscript || interimTranscript;
};
recognition.onerror = (event) => {
console.error('Speech recognition error', event.error);
showToast('Voice recognition error: ' + event.error, 'error');
stopVoiceRecording();
};
}
// Toggle voice recording
function toggleVoiceRecording() {
if (isRecording) {
stopVoiceRecording();
} else {
startVoiceRecording();
}
}
// Start voice recording
function startVoiceRecording() {
try {
recognition.start();
isRecording = true;
voiceRecordBtn.innerHTML = '<i class="material-icons-round text-4xl">stop</i>';
voiceRecordBtn.classList.remove('bg-primary-600');
voiceRecordBtn.classList.add('bg-red-500');
voiceStatus.textContent = 'Listening...';
recordingStartTime = Date.now();
updateVoiceTimer();
recordingInterval = setInterval(updateVoiceTimer, 1000);
showToast('Voice recording started', 'success');
} catch (error) {
console.error('Error starting voice recognition:', error);
showToast('Error starting voice recording', 'error');
}
}
// Stop voice recording
function stopVoiceRecording() {
recognition.stop();
isRecording = false;
voiceRecordBtn.innerHTML = '<i class="material-icons-round text-4xl">mic</i>';
voiceRecordBtn.classList.remove('bg-red-500');
voiceRecordBtn.classList.add('bg-primary-600');
voiceStatus.textContent = 'Click the microphone to start recording';
clearInterval(recordingInterval);
voiceTimer.textContent = '00:00';
showToast('Voice recording stopped', 'info');
}
// Update voice timer
function updateVoiceTimer() {
const elapsed = Math.floor((Date.now() - recordingStartTime) / 1000);
const minutes = Math.floor(elapsed / 60).toString().padStart(2, '0');
const seconds = (elapsed % 60).toString().padStart(2, '0');
voiceTimer.textContent = `${minutes}:${seconds}`;
}
// Insert voice note into editor
function insertVoiceNote() {
if (voiceResult.value.trim()) {
if (!currentNoteId) {
createNewNote();
}
const selection = window.getSelection();
const range = selection.getRangeAt(0);
// Insert the transcribed text at the cursor position
const textNode = document.createTextNode(voiceResult.value);
range.insertNode(textNode);
// Move the cursor to the end of the inserted text
range.setStartAfter(textNode);
range.setEndAfter(textNode);
selection.removeAllRanges();
selection.addRange(range);
// Save the note with the new content
saveCurrentNote();
voiceModal.classList.add('hidden');
voiceResult.value = '';
showToast('Voice note inserted', 'success');
} else {
showToast('No voice content to insert', 'warning');
}
}
// Check auth state
function checkAuthState() {
auth.onAuthStateChanged(user => {
if (user) {
currentUser = user;
userEmail.textContent = user.email;
mobileUserEmail.textContent = user.email;
authModal.classList.add('hidden');
loadNotes();
loadTags();
} else {
currentUser = null;
userEmail.textContent = 'Guest';
mobileUserEmail.textContent = 'Guest';
authModal.classList.remove('hidden');
notes = [];
tags = [];
renderNotesList();
renderTags();
}
});
}
// Sign in with Google
function signInWithGoogle() {
const provider = new firebase.auth.GoogleAuthProvider();
auth.signInWithPopup(provider)
.then(() => {
showToast('Signed in with Google', 'success');
})
.catch(error => {
console.error('Google sign in error:', error);
showToast('Error signing in with Google', 'error');
});
}
// Sign in with email/password
function signInWithEmail() {
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
auth.signInWithEmailAndPassword(email, password)
.then(() => {
showToast('Signed in successfully', 'success');
})
.catch(error => {
console.error('Sign in error:', error);
showToast('Error signing in: ' + error.message, 'error');
});
}
// Sign up with email/password
function signUpWithEmail() {
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
auth.createUserWithEmailAndPassword(email, password)
.then(() => {
showToast('Account created successfully', 'success');
})
.catch(error => {
console.error('Sign up error:', error);
showToast('Error creating account: ' + error.message, 'error');
});
}
// Sign out
function signOut() {
auth.signOut()
.then(() => {
showToast('Signed out successfully', 'info');
})
.catch(error => {
console.error('Sign out error:', error);
showToast('Error signing out', 'error');
});
}
// Toggle dark mode
function toggleDarkModeHandler() {
const html = document.documentElement;
if (html.classList.contains('dark')) {
html.classList.remove('dark');
localStorage.setItem('theme', 'light');
showToast('Light mode activated', 'info');
} else {
html.classList.add('dark');
localStorage.setItem('theme', 'dark');
showToast('Dark mode activated', 'info');
}
}
// Load notes from Firestore
function loadNotes() {
if (!currentUser) return;
db.collection('notes')
.where('userId', '==', currentUser.uid)
.orderBy('updatedAt', 'desc')
.onSnapshot(snapshot => {
notes = [];
snapshot.forEach(doc => {
notes.push({
id: doc.id,
...doc.data()
});
});
renderNotesList();
if (notes.length === 0) {
emptyNotesMessage.classList.remove('hidden');
} else {
emptyNotesMessage.classList.add('hidden');
}
}, error => {
console.error('Error loading notes:', error);
showToast('Error loading notes', 'error');
});
}
// Load tags from Firestore
function loadTags() {
if (!currentUser) return;
db.collection('tags')
.where('userId', '==', currentUser.uid)
.onSnapshot(snapshot => {
tags = [];
snapshot.forEach(doc => {
tags.push({
id: doc.id,