-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdark mode.txt
More file actions
1044 lines (846 loc) · 31.9 KB
/
dark mode.txt
File metadata and controls
1044 lines (846 loc) · 31.9 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
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox">
<div class="slider round">
<i class="fas fa-sun"></i>
<i class="fas fa-moon"></i>
</div>
</label>
</div>
/* Default Light Theme
:root {
--primary-bg: #ffffff;
--secondary-bg: #393333;
--text-color: #ffffff;
--shadow: rgba(30, 30, 30, 0.422);
}
/* Dark Theme *
[data-theme="dark"] {
--primary-bg: #1c1c1c;
--secondary-bg: #252525;
--text-color: #ffffff;
--shadow: rgba(255, 255, 255, 0.1);
}
*/
/* Theme Switch Styles */
.theme-switch-wrapper {
position: fixed;
right: 40px;
bottom: 15px;
z-index: 1001;
}
.theme-switch {
display: inline-block;
height: 34px;
position: relative;
width: 60px;
}
.theme-switch input {
display: none;
}
.slider {
background-color: #ccc;
bottom: 0;
cursor: pointer;
left: 0;
position: absolute;
right: 0;
top: 0;
transition: .4s;
border-radius: 34px;
}
.slider:before {
background-color: #fff;
bottom: 4px;
content: "";
height: 26px;
left: 4px;
position: absolute;
transition: .4s;
width: 26px;
border-radius: 50%;
}
.slider i {
color: #ffffff;
position: absolute;
transform: translateY(-50%);
top: 50%;
transition: .4s;
}
.fa-sun {
right: 10px;
}
.fa-moon {
left: 10px;
}
input:checked + .slider {
background-color: #313231;
}
input:checked + .slider:before {
transform: translateX(26px);
}
// Dark Mode Toggle
document.addEventListener('DOMContentLoaded', () => {
const toggleSwitch = document.querySelector('#checkbox');
const currentTheme = localStorage.getItem('theme');
if (currentTheme) {
document.documentElement.setAttribute('data-theme', currentTheme);
if (currentTheme === 'dark') {
toggleSwitch.checked = true;
}
}
// Switch theme based on checkbox state
function switchTheme(e) {
if (e.target.checked) {
document.documentElement.setAttribute('data-theme', 'dark');
localStorage.setItem('theme', 'dark');
} else {
document.documentElement.setAttribute('data-theme', 'light');
localStorage.setItem('theme', 'light');
}
}
// Add event listener to the checkbox for theme switch
toggleSwitch.addEventListener('change', switchTheme);
});
Old Dashboard
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.1.2/dist/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<link rel="stylesheet" href="styles/dashboard.css">
</head>
<body class="bg-gray-100 text-gray-800">
<div class="container mx-auto p-6">
<!-- Title and Welcome Message -->
<div class="text-center mb-8">
<h2 class="text-3xl font-semibold text-blue-600">Dashboard</h2>
<p id="welcome-message" class="text-lg text-gray-600 mt-2"></p>
</div>
<!-- Admin Actions Section -->
<div id="admin-actions" class="space-y-6" style="display: none;">
<div class="bg-white p-6 rounded-lg shadow-lg">
<h3 class="text-2xl font-semibold text-gray-800 mb-4">Assign Task</h3>
<input type="text" id="task" class="w-full p-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Enter task">
<button onclick="assignTask()" class="mt-4 bg-blue-500 text-white p-3 rounded-md hover:bg-blue-600 transition duration-300">Assign Task</button>
</div>
<div class="bg-white p-6 rounded-lg shadow-lg">
<h3 class="text-2xl font-semibold text-gray-800 mb-4">Registered Users</h3>
<ul id="user-list" class="list-disc pl-6 text-gray-700"></ul>
</div>
</div>
<!-- User Tasks Section -->
<div id="user-tasks" class="space-y-6" style="display: none;">
<div class="bg-white p-6 rounded-lg shadow-lg">
<h3 class="text-2xl font-semibold text-gray-800 mb-4">Your Tasks</h3>
<ul id="task-list" class="list-disc pl-6 text-gray-700"></ul>
</div>
</div>
<!-- Logout Button -->
<div class="mt-8 flex justify-center">
<button onclick="handleLogout()" class="bg-red-500 text-white py-3 px-6 rounded-md hover:bg-red-600 transition duration-300">
Logout
</button>
</div>
</div>
<!-- Theme Switcher -->
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox">
<div class="slider round">
<i class="fas fa-sun"></i>
<i class="fas fa-moon"></i>
</div>
</label>
</div>
<script src="scripts/dashboard.js" defer></script>
</body>
</html>
CSS-
/* Default Light Theme */
:root {
--primary-bg: #f5f5ef;
--secondary-bg: #393333;
--text-color: #000000;
--shadow: rgba(30, 30, 30, 0.422);
}
/* Dark Theme */
[data-theme="dark"] {
--primary-bg: #091227;
--secondary-bg: #252525;
--text-color: #ffffff;
--shadow: rgba(255, 255, 255, 0.1);
}
/* Theme Switch Styles */
.theme-switch-wrapper {
position: fixed;
right: 40px;
bottom: 15px;
z-index: 1001;
}
.theme-switch {
display: inline-block;
height: 34px;
position: relative;
width: 60px;
}
.theme-switch input {
display: none;
}
.slider {
background-color: #ccc;
bottom: 0;
cursor: pointer;
left: 0;
position: absolute;
right: 0;
top: 0;
transition: .4s;
border-radius: 34px;
}
.slider:before {
background-color: #fff;
bottom: 4px;
content: "";
height: 26px;
left: 4px;
position: absolute;
transition: .4s;
width: 26px;
border-radius: 50%;
}
.slider i {
color: #ffffff;
position: absolute;
transform: translateY(-50%);
top: 50%;
transition: .4s;
}
.fa-sun {
right: 10px;
}
.fa-moon {
left: 10px;
}
input:checked + .slider {
background-color: #313231;
}
input:checked + .slider:before {
transform: translateX(26px);
}
Js-
window.onload = function() {
const users = JSON.parse(localStorage.getItem("users")) || [];
const currentUser = localStorage.getItem("userEmail");
const role = localStorage.getItem("role");
if (!currentUser) {
window.location.href = "login.html";
}
document.getElementById("welcome-message").innerText = `Welcome, ${currentUser}`;
if (role === "admin") {
document.getElementById("admin-actions").style.display = "block";
const userList = document.getElementById("user-list");
users.forEach(user => {
if (user.role !== "admin") {
let li = document.createElement("li");
li.innerText = user.email;
userList.appendChild(li);
}
});
} else {
document.getElementById("user-tasks").style.display = "block";
displayUserTasks(currentUser);
}
};
function assignTask() {
const taskText = document.getElementById("task").value;
const users = JSON.parse(localStorage.getItem("users")) || [];
if (!taskText) {
alert("Please enter a task.");
return;
}
const userEmail = prompt("Enter the user email to assign task:");
const userIndex = users.findIndex(user => user.email === userEmail);
if (userIndex === -1) {
alert("User not found!");
return;
}
users[userIndex].tasks.push(taskText);
localStorage.setItem("users", JSON.stringify(users));
alert(`Task assigned to ${userEmail}`);
}
function displayUserTasks(email) {
const users = JSON.parse(localStorage.getItem("users")) || [];
const user = users.find(user => user.email === email);
if (user && user.tasks.length > 0) {
const taskList = document.getElementById("task-list");
user.tasks.forEach(task => {
let li = document.createElement("li");
li.innerText = task;
taskList.appendChild(li);
});
} else {
document.getElementById("task-list").innerHTML = "<p>No tasks assigned yet.</p>";
}
}
function handleLogout() {
localStorage.removeItem("userEmail");
localStorage.removeItem("role");
window.location.href = "login.html";
}
function logout() {
alert("Logged out successfully!");
window.location.href = "index.html";
}
// Dark Mode Toggle
document.addEventListener('DOMContentLoaded', () => {
const toggleSwitch = document.querySelector('#checkbox');
const currentTheme = localStorage.getItem('theme');
if (currentTheme) {
document.documentElement.setAttribute('data-theme', currentTheme);
if (currentTheme === 'dark') {
toggleSwitch.checked = true;
}
}
// Switch theme based on checkbox state
function switchTheme(e) {
if (e.target.checked) {
document.documentElement.setAttribute('data-theme', 'dark');
localStorage.setItem('theme', 'dark');
} else {
document.documentElement.setAttribute('data-theme', 'light');
localStorage.setItem('theme', 'light');
}
}
// Add event listener to the checkbox for theme switch
toggleSwitch.addEventListener('change', switchTheme);
});
old code of register
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Register</title>
<script src="https://unpkg.com/@tailwindcss/browser@4"></script>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<link rel="stylesheet" href="styles/register.css">
</head>
<body class="bg-gray-100 text-gray-800">
<div class="flex flex-col lg:flex-row min-h-screen">
<!-- Left Section: Registration Form -->
<div class="flex-1 flex items-center justify-center bg-white p-8 LeftSection">
<div class="w-full max-w-sm">
<h2 class="text-4xl lg:text-6xl font-bold text-center mb-6 select-none">Sign Up</h2>
<!-- Registration Form -->
<form id="register-form" class="space-y-4" onsubmit="event.preventDefault(); handleRegister();">
<!-- Name Field -->
<div>
<input type="text" id="name" placeholder="Full Name" required
class="w-full p-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"/>
</div>
<!-- Email Field -->
<div>
<input type="email" id="email" placeholder="Email" required
class="w-full p-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"/>
</div>
<!-- Password Field -->
<div>
<input type="password" id="password" placeholder="Password" required
class="w-full p-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"/>
</div>
<!-- Role Selection -->
<div class="flex gap-6 justify-center mt-4">
<!-- Admin -->
<label class="flex items-center cursor-pointer">
<input type="radio" name="role" value="admin" required class="hidden" id="adminRadio">
<div id="adminIndicator" class="w-5 h-5 border-2 border-gray-400 rounded-full flex items-center justify-center transition-all">
<div class="w-2.5 h-2.5 bg-transparent rounded-full"></div>
</div>
<span id="adminText" class="ml-2 text-gray-700 font-medium">Admin</span>
</label>
<!-- User -->
<label class="flex items-center cursor-pointer">
<input type="radio" name="role" value="user" required class="hidden" id="userRadio">
<div id="userIndicator" class="w-5 h-5 border-2 border-gray-400 rounded-full flex items-center justify-center transition-all">
<div class="w-2.5 h-2.5 bg-transparent rounded-full"></div>
</div>
<span id="userText" class="ml-2 text-gray-700 font-medium">User</span>
</label>
</div>
<!-- Message -->
<p class="text-sm text-gray-600">Already have an account? <a href="login.html" class="text-blue-500 hover:underline">Login</a></p>
<!-- Submit Button -->
<div>
<input type="submit" value="Register"
class="w-full py-3 bg-blue-500 text-white font-semibold rounded-md cursor-pointer hover:bg-blue-600 transition duration-300"/>
</div>
</form>
</div>
</div>
<!-- Right Section: Image & Welcome -->
<div class="RightSection flex-1 relative bg-blue-500 text-white">
<!-- Welcome Text -->
<div class="absolute select-none top-12 left-1/2 transform -translate-x-1/2 -translate-y-1/2 mt-60 text-4xl lg:text-6xl font-semibold z-10">
Join Us!
</div>
<div class="absolute select-none top-20 left-1/2 transform -translate-x-1/2 -translate-y-1/2 mt-60 text-lg lg:text-xl font-medium z-10">
Your journey starts here!
</div>
<!-- Full Image Background -->
<img src="./img/bgSubscription.jpg" alt="Welcome Image" class="w-full h-full object-cover"/>
</div>
</div>
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox">
<div class="slider round">
<i class="fas fa-sun"></i>
<i class="fas fa-moon"></i>
</div>
</label>
</div>
<script src="scripts/register.js"></script>
</body>
</html>
/* Default Light Theme */
:root {
--primary-bg: #f5f5ef;
--secondary-bg: #393333;
--text-color: #000000;
--shadow: rgba(30, 30, 30, 0.422);
}
/* Dark Theme */
[data-theme="dark"] {
--primary-bg: #091227;
--secondary-bg: #252525;
--text-color: #ffffff;
--shadow: rgba(255, 255, 255, 0.1);
}
.LeftSection {
background-color: var(--primary-bg);
color: var(--text-color);
}
#message {
color: var(--text-color);
}
/* Theme Switch Styles */
.theme-switch-wrapper {
position: fixed;
right: 40px;
bottom: 15px;
z-index: 1001;
}
.theme-switch {
display: inline-block;
height: 34px;
position: relative;
width: 60px;
}
.theme-switch input {
display: none;
}
.slider {
background-color: #ccc;
bottom: 0;
cursor: pointer;
left: 0;
position: absolute;
right: 0;
top: 0;
transition: .4s;
border-radius: 34px;
}
.slider:before {
background-color: #fff;
bottom: 4px;
content: "";
height: 26px;
left: 4px;
position: absolute;
transition: .4s;
width: 26px;
border-radius: 50%;
}
.slider i {
color: #ffffff;
position: absolute;
transform: translateY(-50%);
top: 50%;
transition: .4s;
}
.fa-sun {
right: 10px;
}
.fa-moon {
left: 10px;
}
input:checked + .slider {
background-color: #313231;
}
input:checked + .slider:before {
transform: translateX(26px);
}
function handleRegister() {
let name = document.getElementById("name").value;
let email = document.getElementById("email").value;
let password = document.getElementById("password").value;
let role = document.querySelector('input[name="role"]:checked').value;
if (!name || !email || !password || !role) {
alert("Please fill in all fields!");
return;
}
let users = JSON.parse(localStorage.getItem("users")) || [];
// Check if email already exists
let userExists = users.some(user => user.email === email);
if (userExists) {
alert("User with this email already exists!");
return;
}
users.push({ name, email, password, role });
localStorage.setItem("users", JSON.stringify(users));
alert("Registration successful! You can now log in.");
window.location.href = "login.html"; // Redirect to login page
}
// Dark Mode Toggle
document.addEventListener('DOMContentLoaded', () => {
const toggleSwitch = document.querySelector('#checkbox');
const currentTheme = localStorage.getItem('theme');
if (currentTheme) {
document.documentElement.setAttribute('data-theme', currentTheme);
if (currentTheme === 'dark') {
toggleSwitch.checked = true;
}
}
function switchTheme(e) {
if (e.target.checked) {
document.documentElement.setAttribute('data-theme', 'dark');
localStorage.setItem('theme', 'dark');
} else {
document.documentElement.setAttribute('data-theme', 'light');
localStorage.setItem('theme', 'light');
}
}
toggleSwitch.addEventListener('change', switchTheme);
});
document.addEventListener("DOMContentLoaded", function () {
const adminRadio = document.getElementById("adminRadio");
const userRadio = document.getElementById("userRadio");
const adminIndicator = document.getElementById("adminIndicator");
const userIndicator = document.getElementById("userIndicator");
const adminText = document.getElementById("adminText");
const userText = document.getElementById("userText");
function updateRadioSelection() {
if (adminRadio.checked) {
adminIndicator.classList.add("border-blue-500", "ring-2", "ring-blue-300");
adminIndicator.firstElementChild.classList.add("bg-blue-500");
adminText.classList.add("text-blue-600");
userIndicator.classList.remove("border-green-500", "ring-2", "ring-green-300");
userIndicator.firstElementChild.classList.remove("bg-green-500");
userText.classList.remove("text-green-600");
} else if (userRadio.checked) {
userIndicator.classList.add("border-green-500", "ring-2", "ring-green-300");
userIndicator.firstElementChild.classList.add("bg-green-500");
userText.classList.add("text-green-600");
adminIndicator.classList.remove("border-blue-500", "ring-2", "ring-blue-300");
adminIndicator.firstElementChild.classList.remove("bg-blue-500");
adminText.classList.remove("text-blue-600");
}
}
adminRadio.addEventListener("change", updateRadioSelection);
userRadio.addEventListener("change", updateRadioSelection);
});
Login
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<link rel="stylesheet" href="styles/login.css">
</head>
<body class="bg-gray-100 text-gray-800">
<div class="flex min-h-screen">
<!-- Left Section: Login Form -->
<div class="LeftSection flex-1 flex items-center justify-center bg-white p-8">
<div class="Box w-full max-w-sm">
<h2 class="text-6xl font-bold text-center mb-6 select-none">Login</h2>
<!-- Login Form -->
<form id="login-form" class="space-y-4" onsubmit="event.preventDefault(); handleLogin();">
<!-- Email Field -->
<div>
<input type="text" id="email" placeholder="Email" required
class="text-black w-full p-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"/>
</div>
<!-- Password Field -->
<div>
<input type="password" id="password" placeholder="Password" required
class="text-black w-full p-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"/>
</div>
<!-- Role Selection (User/Admin) -->
<div class="flex gap-6 justify-center mt-4">
<label class="flex items-center">
<input type="radio" name="role" value="admin" required class="mr-2"> Admin
</label>
<label class="flex items-center">
<input type="radio" name="role" value="user" required class="mr-2"> User
</label>
</div>
<!-- Error Message -->
<p id="message" class="text-base text-red-800 stroke-cyan-500"></p>
<!-- Message -->
<p class="text-sm">Don't have an account? <a href="register.html" class="text-blue-500">Register</a></p>
<!-- Submit Button -->
<div>
<input type="submit" value="Login"
class="w-full py-3 bg-blue-500 text-white font-semibold rounded-md cursor-pointer hover:bg-blue-600 transition duration-300"/>
</div>
</form>
</div>
</div>
<!-- Right Section: Welcome Message + Image -->
<div class="RightSection flex-1 relative bg-blue-500 text-white">
<!-- Welcome Text -->
<div class="absolute select-none top-10 left-1/2 transform -translate-x-1/2 -translate-y-1/2 mt-60 text-6xl font-semibold z-10">
Welcome
</div>
<!-- Full Image Background -->
<img src="./img/bgSubscription.jpg" alt="Welcome Image" class="w-full h-full object-cover"/>
</div>
</div>
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox">
<div class="slider round">
<i class="fas fa-sun"></i>
<i class="fas fa-moon"></i>
</div>
</label>
</div>
<script src="scripts/login.js"></script>
</body>
</html>
/* Default Light Theme */
:root {
--primary-bg: #f5f5ef;
--secondary-bg: #393333;
--text-color: #000000;
--shadow: rgba(30, 30, 30, 0.422);
}
/* Dark Theme */
[data-theme="dark"] {
--primary-bg: #091227;
--secondary-bg: #252525;
--text-color: #ffffff;
--shadow: rgba(255, 255, 255, 0.1);
}
.LeftSection{
background-color: var(--primary-bg);
color: var(--text-color);
}
#message{
color: var(--text-color);
}
/* Theme Switch Styles */
.theme-switch-wrapper {
position: fixed;
right: 40px;
bottom: 15px;
z-index: 1001;
}
.theme-switch {
display: inline-block;
height: 34px;
position: relative;
width: 60px;
}
.theme-switch input {
display: none;
}
.slider {
background-color: #ccc;
bottom: 0;
cursor: pointer;
left: 0;
position: absolute;
right: 0;
top: 0;
transition: .4s;
border-radius: 34px;
}
.slider:before {
background-color: #fff;
bottom: 4px;
content: "";
height: 26px;
left: 4px;
position: absolute;
transition: .4s;
width: 26px;
border-radius: 50%;
}
.slider i {
color: #ffffff;
position: absolute;
transform: translateY(-50%);
top: 50%;
transition: .4s;
}
.fa-sun {
right: 10px;
}
.fa-moon {
left: 10px;
}
input:checked + .slider {
background-color: #313231;
}
input:checked + .slider:before {
transform: translateX(26px);
}
function handleLogin() {
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
const selectedRole = document.querySelector('input[name="role"]:checked'); // Get selected role
// Show error if no role is selected
if (!selectedRole) {
document.getElementById("message").innerText = "Please select a role (Admin/User).";
document.getElementById("message").style.color = "red";
return;
}
const role = selectedRole.value;
const users = JSON.parse(localStorage.getItem("users")) || [];
// Admin credentials (can be modified)
const adminEmail = "admin@example.com";
const adminPassword = "admin123";
// Check if role is admin
if (role === "admin") {
// Check if the admin credentials are correct
if (email === adminEmail && password === adminPassword) {
localStorage.setItem("userEmail", email);
localStorage.setItem("role", "admin");
window.location.href = "dashboard.html";
} else {
document.getElementById("message").innerText = "Invalid admin credentials!";
document.getElementById("message").style.color = "red";
}
return;
}
// Check for user login
const user = users.find(user => user.email === email && user.password === password);
if (user) {
localStorage.setItem("userEmail", user.email);
localStorage.setItem("role", "user");
window.location.href = "dashboard.html";
} else {
document.getElementById("message").innerText = "Invalid credentials!";
document.getElementById("message").style.color = "red";
}
}
// Dark Mode Toggle
document.addEventListener('DOMContentLoaded', () => {
const toggleSwitch = document.querySelector('#checkbox');
const currentTheme = localStorage.getItem('theme');
if (currentTheme) {
document.documentElement.setAttribute('data-theme', currentTheme);
if (currentTheme === 'dark') {
toggleSwitch.checked = true;
}
}
// Switch theme based on checkbox state
function switchTheme(e) {
if (e.target.checked) {
document.documentElement.setAttribute('data-theme', 'dark');
localStorage.setItem('theme', 'dark');
} else {
document.documentElement.setAttribute('data-theme', 'light');
localStorage.setItem('theme', 'light');
}
}
// Add event listener to the checkbox for theme switch
toggleSwitch.addEventListener('change', switchTheme);
});
working Admin js register
document.addEventListener("DOMContentLoaded", function() {
// Get the toggle buttons for Admin and User
const adminToggle = document.getElementById("admin-toggle");
const userToggle = document.getElementById("user-toggle");
// Get the forms for Admin and User
const adminForm = document.getElementById("admin-form");
const userForm = document.getElementById("user-form");
// Set initial visibility (both forms hidden initially)
adminForm.classList.add("hidden");
userForm.classList.add("hidden");
// Show Admin form when Admin button is clicked
adminToggle.addEventListener("click", function() {
adminForm.classList.remove("hidden");
userForm.classList.add("hidden");
});
// Show User form when User button is clicked
userToggle.addEventListener("click", function() {
userForm.classList.remove("hidden");
adminForm.classList.add("hidden");
});
// Handle Admin Registration
function handleAdminRegister(event) {
event.preventDefault(); // Prevent form submission
const adminName = document.getElementById("admin-name").value;
const adminEmail = document.getElementById("admin-email").value;
const adminPassword = document.getElementById("admin-password").value; // Ensure this exists in HTML
const adminWorkspaceId = generateWorkspaceId();
const newAdmin = {
name: adminName,
email: adminEmail,
password: adminPassword,
workspaceId: adminWorkspaceId,
approvedUsers: [] // No users initially
};
let admins = JSON.parse(localStorage.getItem("admins")) || []; // Fetch existing admins from localStorage
admins.push(newAdmin); // Add new admin to the array
// Store the updated admins list in Local Storage
localStorage.setItem("admins", JSON.stringify(admins));
alert("✅ Admin registered successfully. Workspace ID: " + adminWorkspaceId);
window.location.href = "login.html"; // Redirect to login page after registration
}
// Generate a random Workspace ID
function generateWorkspaceId() {
return 'WS' + Math.floor(Math.random() * 10000); // Example for generating workspace ID
}