-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1321 lines (1093 loc) · 50.5 KB
/
Copy pathindex.html
File metadata and controls
1321 lines (1093 loc) · 50.5 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">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SpaceX Communication App</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"/>
<link rel="stylesheet" href="/styles.css">
</head>
<body>
<!-- Loading Screen -->
<div id="loading-screen" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; color: #4a90e2; background-color: #fff; z-index: 1000; display: none; justify-content: center; align-items: center;">
<div>Loading...</div>
</div>
<!-- Error Message -->
<div id="error-message" style="display: none; color: red;"></div>
<style>
</style>
<header class="dark-mode " >
<h1 class="dark-mode">Space<span>X</span></h1>
<!-- <ul>
<li><i class="fas fa-search"></i></li>
</ul> -->
<div class="search-container">
<div class="search-container-2">
<input type="text" id="searchInput" placeholder="Search for a section..." required/>
<div id="suggestions" class="suggestions dark-mode"></div>
<div id="searchMessage" class="searchMessage dark-mode">Heading not found. Please try again</div>
</div>
<button id="searchButton" class="dark-mode">Search</button>
<button id="clearButton" class="dark-mode" style="display: none;">Clear</button>
<nav class="dark-mode ">
<ul>
<li><a href="#" class="dark-mode" id="home-btn">Home</a></li>
<li><a href="#" class="dark-mode" id="logout-btn">Logout</a></li>
<li><a href="#" class="dark-mode" id="register-btn">Register</a></li>
<li>
<a id="profilemain" class="dark-mode ">Portfolio</a>
</li>
<li>
<button id="theme-toggle">
<span class="light-mode-icon">☀</span>
<span class="dark-mode-icon">☾</span>
</button>
</li>
</ul>
</nav>
<div class="menu-icon" id="menu-icon">☰</div>
</div>
</header>
<!-- Comfirmation Dialog -->
<div id="comfirmation-dialog" class="comfirmation-dialog dark-mode" style="display: none; position: fixed; left: 50%; transform: translate(-50%, 50%); border: 1px solid #717171; padding: 20px; z-index: 1000;">
<h4 class="dark-mode">Logout</h4>
<p>Are you sure you want to logout?</p>
<div id="yes-or-no">
<a href="/SignIn.html"><button id="yes-btn" class="dark-mode">Yes</button></a>
<a href=""><button id="no-btn" class="dark-mode">No</button></a>
</div>
</div>
<!-- Register Dialog -->
<div id="register-dialog" class="register-dialog dark-mode" style="display: none; position: fixed; left: 50%; transform: translate(-50%, 50%); border: 1px solid #717171; padding: 20px; z-index: 1000;">
<h4 class="dark-mode">Create Account</h4>
<p>Are you sure you want to create another account?</p>
<div id="yes-or-no">
<a href="/SignUp.html"><button id="yes-btn" class="dark-mode">Yes</button></a>
<a href=""><button id="no-btn" class="dark-mode">No</button></a>
</div>
</div>
<!-- Overlay -->
<div id="overlay" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); z-index: 999;"></div>
<div class="header dark-mode">
<h1 class="dark-mode">SpaceX Images <div id="word-container"></div> </h1>
<p class="dark-mode">SpaceX has always told its story through its images, a few of which have become icons of human history. </p>
</div>
<div class="curve"></div>
<!-- side div settings -->
<!-- <div id="Side-div-settings">
<li>
<button id="settings-toggle" class="dark-mode">
<i class="fas fa-cog"></i>
<span class="settings name dark-mode">
Settings
</span>
</button>
</li>
<li>
<button id="portfolio-toggle" class="dark-mode">
<i class="fas fa-briefcase"></i>
<span class="portfolio name dark-mode">
Portfolio
</span>
</button>
</li>
<li>
<button id="account-toggle" class="dark-mode">
<i class="fas fa-user"></i>
<span class="account name dark-mode">
Me
</span>
</button>
</li>
</div> -->
<aside id="settings-sidebar" class="dark-mode" style="display: none;">
<h2 class="dark-mode">Settings</h2>
<form id="settings-form">
<label for="theme">Theme:</label>
<select name="theme" id="theme">
<option value="light" id="light" class="dark-mode">Light</option>
<option value="dark" id="dark" class="dark-mode">Dark</option>
</select>
<label for="language">Language:</label>
<select name="language" id="language">
<option value="english" class="dark-mode">English</option>
<option value="french" class="dark-mode">French</option>
<option value="spanish" class="dark-mode">Spanish</option>
</select>
<label for="font-family">Fonts:</label>
<select name="font-family" id="font-family">
<option value="Lucida Sans" class="dark-mode">Lucida Sans</option>
<option value='cursive' class="dark-mode">cursive</option>
<option value="sans-serif" class="dark-mode">sans-serif</option>
<option value="Verdana" class="dark-mode">Verdana</option>
<option value="Space Mono, PT Sans" class="dark-mode">Space Mono PT Sans</option>
</select>
<label for="notifications">Notifications:</label>
<input type="checkbox" name="notifications" id="notifications">
</form>
</aside>
<main id="mainIndex">
<section id="sos" class="container b dark-mode ">
<h2 class="dark-mode">SOS Message</h2>
<p class="dark-mode ">Use this form to send an SOS message in emergencies. Your message will be transmitted to the relevant authorities immediately.</p>
<form id="sos-form" method="POST" action="/api/sos">
<label for="sos-message">Message:</label>
<input type="text" id="sos-message" placeholder="Enter message" required>
<button type="submit" id="send-sos" class="dark-mode ">Send SOS
<span class="sos name dark-mode">
Emergency Message
</span>
</button>
</form>
</section>
<section id="live-coverage" class="container b dark-mode ">
<h2 class="dark-mode ">Live Coverage</h2>
<p class="dark-mode ">Stay updated on real-time information about space missions and events. This section provides the latest coverage directly from mission control.</p>
<ul id="live-coverage-list" class="dark-mode "></ul>
</section>
<section id="space-news" class="container b dark-mode ">
<h2 class="dark-mode ">Space News</h2>
<p class="dark-mode ">Space News keeps users informed with the latest articles, discoveries, and updates about space exploration.</p>
<ul id="space-news-list" class="dark-mode ">
</ul>
</section>
<section id="nasa-mission" class="container b dark-mode ">
<h2 class="dark-mode ">Nasa Mission</h2>
<p class="dark-mode ">This section provides an overview of NASA's latest missions. It is updated in real-time with mission details, schedules, and highlights, making it an essential resource for space enthusiasts.
</p>
<ul id="nasa-mission-list" class="dark-mode ">
</ul>
</section>
<section id="spaceX-launch" class="container b dark-mode ">
<h2 class="dark-mode ">SpaceX Launch</h2>
<p class="dark-mode ">Focused on SpaceX's missions and launches, this section brings the latest updates about SpaceX's endeavors in space exploration. It connects users to the timeline and progress of SpaceX missions.
</p>
<ul id="spaceX-launch-list" class="dark-mode ">
</ul>
</section>
<section id="ai-identifier" class="container b dark-mode ">
<h2 class="dark-mode">AI Identifier</h2>
<p class="dark-mode ">Explore the latest AI technologies utilized in space exploration. This section highlights advancements in AI that help analyze complex data from space missions.</p>
<input type="file" name="image" id="image" accept="image/*">
<button id="ai-ientifier-btn" class="dark-mode ">Analyze Image</button>
<div id="ai-identifier-result"></div>
</section>
<section id="photos-mars" class="container b dark-mode">
<h2 class="dark-mode">Photos of Mars</h2>
<p class="dark-mode">
This section showcases images of Mars captured by space rovers or satellites.
</p>
<div id="photos-mars-result"></div>
<div class="lessAndMore">
<button id="more-button" class="more-button dark-mode" onclick="loadMoreImages()">>>
<span class="more name dark-mode">
More Photos
</span>
</button>
<button id="less-button" class="less-button dark-mode" onclick="loadLessImages()"><<
<span class="less name dark-mode">
Less Photos
</span>
</button>
</div>
</section>
<section id="AstronomyPictureOfTheDay" class="container b dark-mode">
<h2 class="dark-mode ">Astronomy Picture Of The Day</h2>
<p class="dark-mode ">Powered by NASA's APOD (Astronomy Picture of the Day) API, this section highlights a new, awe-inspiring image daily. It includes an explanation, high-definition image links, and copyrights to educate and captivate users.
</p>
<div id="Astronomy-Picture-Of-The-Day-info"><h2 class="dark-mode"></h2><img src="" alt=""><p class="dark-mode"></p></div>
</section>
<section id="space-guide" class="container b dark-mode ">
<h2 class="dark-mode ">Space Guide</h2>
<p class="dark-mode ">The Space Guide acts as an educational resource, providing detailed insights into space missions, exploration techniques, and astronomical phenomena. It fetches and displays content dynamically, including images and descriptions, for user engagement.
</p>
<div id="space-guide-info"><h2 class="dark-mode"></h2><img src="" alt=""><p class="dark-mode"></p></div>
</section>
<section id="space-craft" class="container b dark-mode">
<h2 class="dark-mode">Space Craft</h2>
<p class="dark-mode">
The Space Guide acts as an educational resource, providing detailed insights into space missions, exploration techniques, and astronomical phenomena. It fetches and displays content dynamically, including spacecraft names and descriptions, for user engagement.
</p>
<ul id="space-craft-list" class="dark-mode"></ul>
</section>
</main>
<!-- profile main -->
<main id="mainProfile" style="display: none;" class="dark-mode">
<section id="about">
<h2 class="dark-mode">About Us</h2>
<p class="dark-mode">We are dedicated to advancing communications in space exploration.</p>
</section>
<section id="services">
<h2 class="dark-mode">Our Services</h2>
<p class="dark-mode">We offer a range of services to meet your needs, including Live Coverage, Space News, and Space Guide etc.</p>
</section>
<section id="contact">
<h2 class="dark-mode">Contact Us</h2>
<form class="form-container">
<input type="text" placeholder="Name" required>
<input type="email" placeholder="Email" required>
<textarea placeholder="Your Message" rows="5" required></textarea>
<button type="submit" class="dark-mode">Send Message
<span class="message name dark-mode">
Any Complains, Suggestions or Improvements to SpaceX.
</span>
</button>
</form>
</section>
</main>
<!-- Main Account -->
<main id="mainAccount" class="dark-mode" style="display: none;">
<h1 class="dark-mode">Account Overview</h1>
<div class="profile-container">
<div class="profile-image-wrapper">
<div id="profileImage" class="default-icon dark-mode">
<i class="fas fa-user"></i>
</div>
<span id="editText" class="edit-text">Edit</span>
</div>
<input type="file" name="file" id="fileInput" accept="image/*" style="display: none;">
</div>
<div id="account-info">
<h2 class="dark-mode">Username: <span id="username"></span></h2>
<h2 class="dark-mode">Email: <span id="email"></span></h2>
<h2 class="dark-mode">Profile Picture: <img id="profile-picture" src="" alt="Profile Picture"></h2>
</div>
<button id="change-profile-picture" class="dark-mode">Edit Profile Picture</button>
<button id="change-password" class="dark-mode">Change Password</button>
<button id="edit-profile" class="dark-mode">Edit Profile</button>
</main>
<!-- footer -->
<footer class="dark-mode " >
<div class="container">
<div class="w-full lg:w-1/2">
<h1 class="dark-mode">SpaceX<div id="word-container"></div> </h1>
<p class="dark-mode">We explore earth in all aspect like Space Craft, Space Guide, Astronomy Picture Of The Day, and Live Coverage etc. </p>
</div>
<div class="Icons w-full">
<h3 class="text -lg font-bold dark-mode ">Quick Links</h3>
<!-- side div settings -->
<li>
<button id="settings-toggle" class="dark-mode">
<i class="fas fa-cog"></i>
<span class="settings name dark-mode">
Settings
</span>
</button>
</li>
<li>
<button id="portfolio-toggle" class="dark-mode">
<i class="fas fa-briefcase"></i>
<span class="portfolio name dark-mode">
Portfolio
</span>
</button>
</li>
<li>
<button id="account-toggle" class="dark-mode">
<i class="fas fa-user"></i>
<span class="account name dark-mode">
Me
</span>
</button>
</li>
<li>
<button id="portfolio-toggle" class="dark-mode">
<i class="fas fa-sign-in-alt"></i>
<span class="portfolio name dark-mode">
Login
</span>
</button>
</li>
<li>
<button id="portfolio-toggle" class="dark-mode">
<i class="fas fa-sign-out-alt"></i>
<span class="portfolio name dark-mode">
Logout
</span>
</button>
</li>
</div>
<div class="w-full">
<h3 class="text-lg font-bold dark-mode">Contact Info</h3>
<!-- WhatsApp Icon -->
<div class="contact-item whatsapp">
<i class="fab fa-whatsapp"></i>
<li>+2349065692168</li>
</div>
<!-- Mail Icon -->
<div class="contact-item mail">
<i class="fas fa-envelope"></i>
<li>Mathewoloyede100@gmail.com</li>
</div>
</div>
<div class="flex flex-wrap justify-center">
<div class="w-full lg:w-1/2">
<h3 class="text -lg font-bold dark-mode ">About Us</h3>
<p class="text -sm dark-mode ">We are dedicated to advancing communications in space exploration.</p>
</div>
</div>
</div>
<div class="w-full p lg:w-1/2">
<p class="dark-mode">© 2024 Earth-Space Communication App</p>
<div class="w-full lg:w-1/2">
<ul class="flex justify-center space-x-4">
<!-- Twitter -->
<li>
<a href="https://twitter.com/mathew" target="_blank" rel="noopener noreferrer" class="icon-link">
<svg class="w-6 h-6 text-blue-500 hover:text-blue-400" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24">
<path d="M8.29 20c7.547 0 11.675-6.155 11.675-11.49 0-.175 0-.349-.012-.522A8.243 8.243 0 0022 5.92a8.34 8.34 0 01-2.357.627 4.077 4.077 0 001.824-2.242 8.27 8.27 0 01-2.605.977A4.118 4.118 0 0016.616 4c-2.273 0-4.113 1.818-4.113 4.057 0 .317.036.626.1.923a11.635 11.635 0 01-8.457-4.266 4.009 4.009 0 00-.556 2.039c0 1.408.721 2.65 1.816 3.377a4.074 4.074 0 01-1.866-.508v.05c0 1.964 1.41 3.604 3.28 3.976-.343.092-.704.14-1.078.14-.263 0-.519-.026-.769-.074.52 1.595 2.03 2.756 3.82 2.786a8.243 8.243 0 01-5.05 1.718c-.328 0-.654-.018-.975-.055A11.65 11.65 0 008.29 20z"></path>
</svg>
</a>
</li>
<!-- YouTube -->
<li>
<a href="https://youtube.com/c/Mathewoloyede" target="_blank" rel="noopener noreferrer" class="icon-link">
<svg class="w-6 h-6 text-red-500 hover:text-red-400" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24">
<path d="M23.498 6.186a3.004 3.004 0 00-2.11-2.11C19.338 3.998 12 3.998 12 3.998s-7.338 0-9.388.078a3.004 3.004 0 00-2.11 2.11C0 8.237 0 12 0 12s0 3.763.502 5.814a3.004 3.004 0 002.11 2.11C4.662 20.002 12 20.002 12 20.002s7.338 0 9.388-.078a3.004 3.004 0 002.11-2.11C24 15.763 24 12 24 12s0-3.763-.502-5.814zm-13.998 8.578V9.236l6.716 3.264-6.716 3.264z"></path>
</svg>
</a>
</li>
<!-- LinkedIn -->
<li>
<a href="https://linkedin.com/in/mathewoloyede" target="_blank" rel="noopener noreferrer" class="icon-link">
<svg class="w-6 h-6 text-blue-700 hover:text-blue-600" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24">
<path d="M22.23 0H1.77C.79 0 0 .774 0 1.73v20.54C0 23.226.79 24 1.77 24h20.46c.98 0 1.77-.774 1.77-1.73V1.73C24 .774 23.21 0 22.23 0zM7.12 20.2H3.56V9h3.56v11.2zM5.34 7.69a2.072 2.072 0 01-2.07-2.07c0-1.14.93-2.07 2.07-2.07s2.07.93 2.07 2.07c0 1.14-.93 2.07-2.07 2.07zM20.2 20.2h-3.56v-5.33c0-3.56-4.28-3.28-4.28 0v5.33H8.8V9h3.37v1.53c1.46-2.68 7.03-2.89 7.03 2.56v7.11z"></path>
</svg>
</a>
</li>
<!-- Facebook -->
<li>
<a href="https://facebook.com/mathewoloyedepage" target="_blank" rel="noopener noreferrer" class="icon-link">
<svg class="w-6 h-6 text-blue-600 hover:text-blue-500" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24">
<path d="M22.675 0h-21.35C.592 0 0 .592 0 1.326v21.348C0 23.408.592 24 1.326 24h11.483v-9.294H9.693v-3.622h3.116V8.413c0-3.1 1.893-4.79 4.655-4.79 1.324 0 2.463.1 2.794.143v3.24l-1.919.001c-1.504 0-1.796.714-1.796 1.762v2.309h3.587l-.467 3.622h-3.12V24h6.116c.733 0 1.326-.592 1.326-1.326V1.326C24 .592 23.408 0 22.675 0z"></path>
</svg>
</a>
</li>
</ul>
</div>
</div>
</footer>
<script>
// Toggle Switch
const themeToggle = document.getElementById('theme-toggle');
themeToggle.addEventListener('click', () => {
document.body.classList.toggle('dark-mode');
// document.body.classList.toggle('light-mode');
document.querySelectorAll('header, footer').forEach((element) => {
element.classList.toggle('dark-mode');
// element.classList.toggle('light-mode');
});
document.querySelectorAll('.container.b, #mainProfile, #mainAccount').forEach((container) => {
container.classList.toggle('dark-mode');
// container.classList.toggle('light-mode');
});
document.querySelectorAll('button').forEach((button) => {
button.classList.toggle('dark-mode');
// button.classList.toggle('light-mode');
});
document.querySelectorAll('h2, p, h3, h4, h1, ul, li').forEach((element) => {
element.classList.toggle('dark-mode');
// element.classList.toggle('light-mode');
});
document.querySelectorAll('nav, .header, option, #settings-sidebar, .name, .default-icon, .searchMessage, .suggestions').forEach((element) => {
element.classList.toggle('dark-mode');
// element.classList.toggle('light-mode');
});
document.querySelector('div.comfirmation-dialog').classList.toggle('dark-mode');
document.querySelector('div.register-dialog').classList.toggle('dark-mode');
document.querySelectorAll('svg').forEach((svg) => {
svg.classList.toggle('dark-mode');
// svg.classList.toggle('light-mode');
});
localStorage.setItem('theme',
document.body.classList.contains('dark-mode') ? 'dark': 'dark'
);
});
document.querySelector('span.dark-mode-icon').addEventListener('click', () => {
document.querySelector('span.dark-mode-icon').style.display = 'none';
});
document.querySelector('span.light-mode-icon').addEventListener('click', () => {
document.querySelector('span.dark-mode-icon').style.display = 'flex';
});
// Set initial theme based on local storage
const initialTheme = localStorage.getItem('theme');
if (initialTheme === 'dark') {
document.body.classList.add('dark-mode');
} else {
document.body.classList.add('light-mode');
};
// settings toggle light and dark
document.getElementById('light').addEventListener('click', () => {
document.body.classList.remove('dark-mode');
// document.body.classList.toggle('light-mode');
document.querySelectorAll('header, footer').forEach((element) => {
element.classList.remove('dark-mode');
// element.classList.toggle('light-mode');
});
document.querySelectorAll('.container.b, #mainProfile, #mainAccount').forEach((container) => {
container.classList.remove('dark-mode');
// container.classList.toggle('light-mode');
});
document.querySelectorAll('button').forEach((button) => {
button.classList.remove('dark-mode');
// button.classList.toggle('light-mode');
});
document.querySelectorAll('h2, p, h3, h4, h1, ul, li').forEach((element) => {
element.classList.remove('dark-mode');
// element.classList.toggle('light-mode');
});
document.querySelectorAll('nav, .header, option').forEach((element) => {
element.classList.remove('dark-mode');
// element.classList.toggle('light-mode');
});
document.querySelectorAll('#settings-sidebar, .name, .default-icon, .searchMessage, .suggestions').forEach((element) => {
element.classList.remove('dark-mode');
});
document.querySelector('div.comfirmation-dialog').classList.remove('dark-mode');
document.querySelector('div.register-dialog').classList.remove('dark-mode');
document.querySelector('span.dark-mode-icon').style.display = 'none';
document.querySelectorAll('svg').forEach((svg) => {
svg.classList.remove('dark-mode');
// svg.classList.toggle('light-mode');
});
});
// settings toggle light and dark
document.getElementById('dark').addEventListener('click', () => {
document.body.classList.add('dark-mode');
// document.body.classList.toggle('light-mode');
document.querySelectorAll('header, footer').forEach((element) => {
element.classList.add('dark-mode');
// element.classList.toggle('light-mode');
});
document.querySelectorAll('.container.b, #mainProfile, #mainAccount').forEach((container) => {
container.classList.add('dark-mode');
// container.classList.toggle('light-mode');
});
document.querySelectorAll('button').forEach((button) => {
button.classList.add('dark-mode');
// button.classList.toggle('light-mode');
});
document.querySelectorAll('h2, p, h3, h4, h1, ul, li').forEach((element) => {
element.classList.add('dark-mode');
// element.classList.toggle('light-mode');
});
document.querySelectorAll('nav, .header, option').forEach((element) => {
element.classList.add('dark-mode');
// element.classList.toggle('light-mode');
});
document.querySelectorAll('#settings-sidebar, .name, .default-icon, .searchMessage, .suggestions').forEach((element) => {
element.classList.add('dark-mode');
});
document.querySelector('div.comfirmation-dialog').classList.add('dark-mode');
document.querySelector('div.register-dialog').classList.add('dark-mode');
document.querySelectorAll('svg').forEach((svg) => {
svg.classList.add('dark-mode');
// svg.classList.toggle('light-mode');
});
document.querySelector('span.dark-mode-icon').style.display = 'flex';
localStorage.setItem('theme',
document.body.classList.contains('dark-mode') ? 'dark': 'dark'
);
});
// Get the menu icon and the mobile nav element
const menuIcon = document.getElementById('menu-icon');
const mobileNav = document.querySelector('nav');
// Toggle the mobile nav when the menu icon is clicked
menuIcon.addEventListener('click', () => {
mobileNav.classList.toggle('show');
mobileNav.classList.toggle('mobile-nav');
mobileNav.classList.toggle('nav');
menuIcon.classList.toggle('menu-icon');
document.querySelector('span.dark-mode-icon').addEventListener('click', () => {
document.querySelector('span.dark-mode-icon').style.display = 'none';
});
document.querySelector('span.light-mode-icon').addEventListener('click', () => {
document.querySelector('span.dark-mode-icon').style.display = 'flex';
});
});
// FONT FAMILT TOGGLE
document.getElementById('font-family').addEventListener('change', () => {
document.body.style.fontFamily = document.getElementById('font-family').value;
});
// Logout Functionality
document.querySelector('a#logout-btn').addEventListener('click', () => {
document.getElementById('overlay').style.display = 'block';
document.getElementById('register-dialog').style.display = 'none';
document.getElementById('comfirmation-dialog').style.display = 'flex';
});
// register functionality
document.querySelector('a#register-btn').addEventListener('click', () => {
document.getElementById('comfirmation-dialog').style.display = 'none';
document.getElementById('register-dialog').style.display = 'flex';
document.getElementById('overlay').style.display = 'block';
});
// Show loading screen
document.getElementById('loading-screen').style.display = 'flex';
// Page load event
window.addEventListener('load', () => {
// Hide loading screen
document.getElementById('loading-screen').style.display = 'none';
// Show header, main, and footer
});
// toggle between home and profile
const MainIndex = document.getElementById('mainIndex');
const MainProfile = document.getElementById('mainProfile');
const profileMain = document.querySelector('a#profilemain');
profileMain.addEventListener('click', () => {
MainIndex.style.display = 'none';
MainProfile.style.display = 'block';
});
// t0ggle between home and Account
MainAccount = document.getElementById('mainAccount');;
document.getElementById('account-toggle').addEventListener('click', () => {
MainIndex.style.display = 'none';
MainProfile.style.display = 'none';
MainAccount.style.display = 'block';
});
// side portfolio show
document.getElementById('portfolio-toggle').addEventListener('click', () => {
MainIndex.style.display = 'none';
MainAccount.style.display = 'none';
MainProfile.style.display = 'block';
});
// Home toggle
document.getElementById('home-btn').addEventListener('click', () => {
MainProfile.style.display = 'none';
MainAccount.style.display = 'none';
MainIndex.style.display = 'flex';
});
// toggle SETTINGS
const SettingsToggle = document.querySelector('button#settings-toggle');
const SettingsSidebar = document.getElementById('settings-sidebar');
SettingsToggle.addEventListener('click', () => {
SettingsSidebar.style.display = 'block';
});
// Close Settings Sidebar on outside click
document.addEventListener('click', (event) => {
if (!SettingsSidebar.contains(event.target) && !SettingsToggle.contains(event.target)) {
SettingsSidebar.style.display = 'none';
}
});
// Get the username, email, and profile picture from local storage
const username = localStorage.getItem('username');
const email = localStorage.getItem('email');
const profilePicture = localStorage.getItem('profilePicture');
// Display the username, email, and profile Picture on the page
document.getElementById('username').innerHTML = username;
document.getElementById('email').innerHTML = email;
document.getElementById('profile-picture').src = profilePicture;
// Add event listeners to the change profile picture, change password, asnd edit profile buttons
document.getElementById('change-profile-picture').addEventListener('click', () => {
// Open a file input dialog
const fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.accept = 'image/*';
fileInput.addEventListener('change', () => {
// Get the selected file
const formData = new FormData();
formData.append('profilePicture', File);
fetch('/upload-profile-picture', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
// Update the profile picture on the page
document.getElementById('profile-picture').src = data.profilePicture;
// Save the new profile picture to locla storage
localStorage.setItem('profilePicture', data.profilePicture);
})
.catch(error => console.error(error));
});
fileInput.click();
} );
// Adding of image to the profile
document.getElementById('editText').addEventListener('click', function() {
document.getElementById('fileInput').click();
});
document.getElementById('fileInput').addEventListener('change', function(event) {
const file = event.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
const imageElement = document.getElementById('profileImage');
imageElement.style.backgroundImage = `url(${e.target.result})`;
imageElement.innerHTML = ''; // Remove the icon if an image is uploaded
}
reader.readAsDataURL(file);
}
});
// Scroll up and down style changes of #Side-div-settings
let lastScrollY = window.scrollY;
window.addEventListener('scroll', function () {
const currentScroll = window.scrollY;
const sideDiv = document.getElementById('Side-div-settings');
const searchMessage = document.getElementById('searchMessage');
const suggestions = document.getElementById('suggestions');
// Hide elements when scrolling up to 20px
if (currentScroll < 20) {
sideDiv.style.top = '52vh';
searchMessage.style.display = 'none';
suggestions.style.display = 'none';
} else {
// Dynamically adjust side-div-settings position based on scroll value
const offset = Math.max(0, 52 - (currentScroll / 10));
sideDiv.style.top = `${offset}vh`;
// Optional: Hide other elements based on scroll
if (currentScroll > 400) {
searchMessage.style.display = 'none';
suggestions.style.display = 'none';
}
}
// Update the lastScrollY variable
lastScrollY = currentScroll;
});
// name container renameing
// Declare the index variable once globally
const words = ['SpaceX', 'Xspace', 'Space X', 'X space'];
let currentWordIndex = 0; // Declare the index variable only once at the top
const wordContainer = document.getElementById('word-container'); // Container to show the typing effect
// Typing effect function
function typeWord(word, callback) {
let i = 0;
wordContainer.textContent = ''; // Clear the word container
function typing() {
if (i < word.length) {
wordContainer.textContent += word[i++]; // Add one character at a time
setTimeout(typing, 100); // Speed of typing
} else {
setTimeout(callback, 500); // Wait before starting to delete
}
}
typing();
};
// Deleting effect function
function deleteWord(callback) {
let text = wordContainer.textContent;
function deleting() {
if (text.length > 0) {
wordContainer.textContent = text.slice(0, -1); // Remove one character at a time
setTimeout(deleting, 50); // Speed of deleting
} else {
callback();
}
}
deleting();
};
// Change words in a loop function
function changeWord() {
const word = words[currentWordIndex];
typeWord(word, function () {
deleteWord(function () {
currentWordIndex = (currentWordIndex + 1) % words.length; // Cycle through words
changeWord(); // Repeat the process
});
});
}
// Start typing effect when the window loads
window.onload = function () {
changeWord(); // Initiates the typing effect
};
let debounceTimer;
// Adding debounced event listener to input
document.getElementById('searchInput').addEventListener('click', () => {
clearTimeout(debounceTimer);
debounceTimer = setTimeout(() => {
})
});
// functionality search button and input to the code
// const searchsection = [
// "Live Coverage",
// "AI Identifier",
// "Space Guide",
// "SpaceNews",
// "SOS Message",
// "Nasa Mission",
// "SpaceX Launch",
// "Photos of Mars",
// "Astronomy Picture Of The Day",
// "Space Craft"
// ]
let selectedSuggestionId = null; // To store the selected suggestion's ID
//Function to filter items based on search input
document.getElementById('searchButton').addEventListener('click', function() {
const searchInput = document.getElementById('searchInput').value.trim().toLowerCase();
const searchMessage = document.getElementById('searchMessage');
const suggestions = document.getElementById('suggestions');
// checking if input is settings or portfolio
if (searchInput === 'portfolio') {
MainIndex.style.display = 'none';
MainAccount.style.display = 'none';
MainProfile.style.display = 'block';
} else if (searchInput === 'settings') {
document.getElementById('settings-sidebar').style.display = 'block';
} else {
// Scroll to the selected suggestion or the search input if no suggestion was selected
if (selectedSuggestionId) {
scrollToElement(selectedSuggestionId);
selectedSuggestionId = null; // Reset after use
} else {
const matchingElement = document.getElementById(searchInput);
if (matchingElement) {
scrollToElement(searchInput);
} else {
console.log('Element is not visible, scrolling');
searchMessage.style.display = 'block';
document.getElementById('searchButton').style.display = 'none';
document.getElementById('clearButton').style.display = 'block';
}
}
}
});
// input better
document.getElementById('searchInput').addEventListener('input', function() {
const searchInput = document.getElementById('searchInput').value.trim().toLowerCase();
const suggestions = document.getElementById('suggestions');
suggestions.innerHTML = '';
if (debounceTimer) clearTimeout(debounceTimer);
if (searchInput.length > 0) {
// Apply a debounce of 300ms before showing suggestions
debounceTimer = setTimeout(function() {
const headings = [
"Live Coverage",
"AI Identifier",
"Space Guide",
"SpaceNews",
"SOS Message",
"Nasa Mission",
"SpaceX Launch",
"Photos of Mars",
"Astronomy Picture Of The Day",
"Space Craft"
];
const ids = [
"live-coverage",
"ai-identifier",
"space-guide",
"space-news",
"sos",
"nasa-mission",
"spacex-launch",
"photos-mars",
"astronomy-picture-of-the-day",
"space-craft",
];
const filteredSUggestions = headings.filter(item => item.toLowerCase().includes(searchInput));
if (filteredSUggestions.length > 0) {
suggestions.style.display = 'block';
filteredSUggestions.forEach(suggestion => {
const suggestionItem = document.createElement('div');
suggestionItem.classList.add('suggestion-item');
suggestionItem.textContent = suggestion.charAt(0).toUpperCase() + suggestion.slice(1);
// Add click event to suggestions
suggestionItem.addEventListener('click', function() {
selectedSuggestionId = ids[index]; // Store the ID of the clicked suggestion
document.getElementById('searchInput').value = suggestionItem.textContent.toLowerCase();
document.getElementById('searchButton').click();
});
suggestions.appendChild(suggestionItem);
});
} else {
suggestions.style.display = "none";
}
}, 300); //Delay input
} else {
suggestions.style.display = "none";
}
});
const scrollToElement = (id) => {
const element = document.getElementById(id);
if (element) {
element.scrollIntoView({ behavior: 'smooth', block: 'start' });
} else {
const searchMessage = document.getElementById('searchMessage');
searchMessage.textContent = 'Element not found. Please try another search.';
searchMessage.style.display = 'block';
}
};
// Clear input field and reset UI
document.getElementById('clearButton').addEventListener('click', function() {
document.getElementById('searchInput').value = '';
document.getElementById('searchMessage').style.display = 'none';
document.getElementById('searchInput').focus(); // Focus the input for a smooth reset
document.getElementById('clearButton').style.display = 'none';
document.getElementById('searchButton').style.display = 'block';
});
// Accessibility improvement for the suggestion list
const suggestionElement = document.getElementById('suggestions');
suggestionElement.setAttribute('role', 'listbox'); // ARIA role for suggestions
suggestionElement.setAttribute('aria-live', 'assertive'); // Live region for suggestions
suggestionElement.setAttribute('aria-labelledby', 'searchInput'); // Associating input with suggestions
// Hide suggestions and message initially