Spaces:
Running
Running
File size: 86,402 Bytes
ec136f4 | 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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nkoranza SHTs - E-Voting System</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: {
DEFAULT: '#1E40AF',
light: '#3B82F6',
},
secondary: '#10B981',
accent: '#F59E0B',
dark: '#1F2937',
},
fontFamily: {
sans: ['Inter', 'sans-serif'],
},
}
},
plugins: [],
}
</script>
<style>
/* Custom CSS for elements not covered by Tailwind */
.auth-container {
background: linear-gradient(135deg, #1E40AF 0%, #3B82F6 100%);
}
.vote-card:hover {
transform: translateY(-5px);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.pulse {
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes pulse {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
#loader {
border-top-color: #3B82F6;
-webkit-animation: spinner 1.5s linear infinite;
animation: spinner 1.5s linear infinite;
}
@-webkit-keyframes spinner {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes spinner {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body class="font-sans bg-gray-50 min-h-screen">
<!-- App Container -->
<div id="app" class="min-h-screen flex flex-col">
<!-- Header -->
<header class="bg-primary text-white shadow-md">
<div class="container mx-auto px-4 py-4 flex justify-between items-center">
<div class="flex items-center space-x-2">
<i class="fas fa-vote-yea text-2xl"></i>
<h1 class="text-xl font-bold">Nkoranza SHTs E-Voting</h1>
</div>
<nav>
<ul class="flex space-x-6">
<li><a href="#home" class="hover:text-accent transition" onclick="showSection('home')">Home</a></li>
<li><a href="#vote" class="hover:text-accent transition" onclick="showSection('vote')">Vote</a></li>
<li><a href="#results" class="hover:text-accent transition" onclick="showSection('results')">Results</a></li>
<li id="admin-nav" class="hidden"><a href="#admin" class="hover:text-accent transition" onclick="showSection('admin')">Admin</a></li>
<li id="login-nav"><a href="#login" class="hover:text-accent transition" onclick="showSection('login')">Login</a></li>
<li id="logout-nav" class="hidden"><a href="#" class="hover:text-accent transition" onclick="logout()">Logout</a></li>
</ul>
</nav>
</div>
</header>
<!-- Main Content -->
<main class="flex-grow container mx-auto px-4 py-8">
<!-- Loader -->
<div id="loader-section" class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50">
<div id="loader" class="w-16 h-16 border-4 border-white border-solid rounded-full animate-spin"></div>
</div>
<!-- Home Section -->
<section id="home-section" class="max-w-4xl mx-auto">
<div class="text-center mb-8">
<h2 class="text-3xl font-bold text-dark mb-4">Welcome to Nkoranza SHTs E-Voting System</h2>
<p class="text-gray-600 mb-6">Cast your vote securely and conveniently for your school elections</p>
<div class="flex justify-center space-x-4">
<button onclick="showSection('vote')" class="bg-primary hover:bg-primary-light text-white px-6 py-2 rounded-lg transition">Vote Now</button>
<button onclick="showSection('results')" class="bg-secondary hover:bg-green-500 text-white px-6 py-2 rounded-lg transition">View Results</button>
</div>
</div>
<div class="grid md:grid-cols-3 gap-6">
<div class="bg-white p-6 rounded-lg shadow-md">
<div class="text-accent mb-4 text-2xl">
<i class="fas fa-user-shield"></i>
</div>
<h3 class="font-bold text-lg mb-2">Secure Voting</h3>
<p class="text-gray-600">Our system uses advanced encryption to ensure your vote remains anonymous and secure.</p>
</div>
<div class="bg-white p-6 rounded-lg shadow-md">
<div class="text-accent mb-4 text-2xl">
<i class="fas fa-bolt"></i>
</div>
<h3 class="font-bold text-lg mb-2">Fast Results</h3>
<p class="text-gray-600">Get real-time election results as soon as voting ends, eliminating long waits.</p>
</div>
<div class="bg-white p-6 rounded-lg shadow-md">
<div class="text-accent mb-4 text-2xl">
<i class="fas fa-mobile-alt"></i>
</div>
<h3 class="font-bold text-lg mb-2">Mobile Friendly</h3>
<p class="text-gray-600">Vote from any device, whether you're using a computer, tablet, or smartphone.</p>
</div>
</div>
<div class="mt-12 bg-white p-6 rounded-lg shadow-md">
<h3 class="font-bold text-xl mb-4 text-center">Upcoming Elections</h3>
<div class="overflow-x-auto">
<table class="min-w-full bg-white">
<thead class="bg-gray-100">
<tr>
<th class="py-2 px-4 border-b">Position</th>
<th class="py-2 px-4 border-b">Start Date</th>
<th class="py-2 px-4 border-b">End Date</th>
<th class="py-2 px-4 border-b">Status</th>
</tr>
</thead>
<tbody>
<tr>
<td class="py-2 px-4 border-b text-center">SRC President</td>
<td class="py-2 px-4 border-b text-center">2023-06-01</td>
<td class="py-2 px-4 border-b text-center">2023-06-05</td>
<td class="py-2 px-4 border-b text-center"><span class="bg-green-100 text-green-800 px-2 py-1 rounded-full text-xs">Active</span></td>
</tr>
<tr>
<td class="py-2 px-4 border-b text-center">Academic Committee</td>
<td class="py-2 px-4 border-b text-center">2023-06-10</td>
<td class="py-2 px-4 border-b text-center">2023-06-12</td>
<td class="py-2 px-4 border-b text-center"><span class="bg-yellow-100 text-yellow-800 px-2 py-1 rounded-full text-xs">Upcoming</span></td>
</tr>
<tr>
<td class="py-2 px-4 border-b text-center">Sports Committee</td>
<td class="py-2 px-4 border-b text-center">2023-05-20</td>
<td class="py-2 px-4 border-b text-center">2023-05-22</td>
<td class="py-2 px-4 border-b text-center"><span class="bg-red-100 text-red-800 px-2 py-1 rounded-full text-xs">Ended</span></td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<!-- Login Section -->
<section id="login-section" class="hidden max-w-md mx-auto">
<div class="auth-container p-8 rounded-lg shadow-xl text-white">
<div class="text-center mb-8">
<i class="fas fa-user-lock text-4xl mb-4"></i>
<h2 class="text-2xl font-bold">Voter Login</h2>
<p class="opacity-80">Enter your credentials to access the voting system</p>
</div>
<form id="loginForm" class="space-y-6">
<div>
<label for="studentId" class="block mb-1">Student ID</label>
<input type="text" id="studentId" class="w-full px-4 py-2 rounded bg-primary-light bg-opacity-20 border border-white border-opacity-30 focus:outline-none focus:ring-2 focus:ring-accent focus:border-transparent" placeholder="NKSHT20230XX" required>
</div>
<div>
<label for="password" class="block mb-1">Password</label>
<input type="password" id="password" class="w-full px-4 py-2 rounded bg-primary-light bg-opacity-20 border border-white border-opacity-30 focus:outline-none focus:ring-2 focus:ring-accent focus:border-transparent" placeholder="••••••••" required>
</div>
<div>
<button type="button" onclick="authenticateUser()" class="w-full bg-accent hover:bg-yellow-600 text-white font-bold py-2 px-4 rounded transition duration-300">
Login
</button>
</div>
<p class="text-center text-sm opacity-80">
Forgot your password? Contact the electoral committee
</p>
<div id="login-error" class="hidden bg-red-100 border-l-4 border-red-500 text-red-700 p-3">
<p>Invalid credentials. Please try again.</p>
</div>
</form>
</div>
</section>
<!-- Voting Section -->
<section id="vote-section" class="hidden">
<div class="text-center mb-8">
<h2 class="text-3xl font-bold text-dark mb-2">Cast Your Vote</h2>
<p class="text-gray-600">Current Election: SRC President 2023/2024</p>
<div class="mt-4">
<span id="time-left" class="bg-primary text-white px-3 py-1 rounded-full text-sm">Time left: 2 days 4 hours</span>
</div>
</div>
<div class="max-w-4xl mx-auto">
<div class="bg-white rounded-lg shadow-md p-6 mb-8">
<h3 class="text-xl font-bold mb-4">Instructions</h3>
<ol class="list-decimal list-inside space-y-2 text-gray-700">
<li>Select your preferred candidate for each position</li>
<li>Review your selections before submission</li>
<li>Click "Submit Votes" to cast your ballot</li>
<li>Note: You cannot change your vote after submission</li>
</ol>
</div>
<div class="grid md:grid-cols-2 gap-6 mb-8">
<!-- Position 1 -->
<div class="bg-white rounded-lg shadow-md p-6">
<h3 class="text-xl font-bold mb-4 border-b pb-2">SRC President</h3>
<div class="space-y-4">
<div class="vote-card bg-gray-50 p-4 rounded-lg border border-gray-200 hover:border-primary transition duration-300 cursor-pointer" onclick="selectCandidate('president', 'candidate1')">
<div class="flex items-center space-x-4">
<div class="h-12 w-12 rounded-full bg-primary-light flex items-center justify-center text-white font-bold">AK</div>
<div>
<h4 class="font-semibold">Andrew Kwarteng</h4>
<p class="text-sm text-gray-600">Computer Science</p>
</div>
<div class="ml-auto">
<div class="h-5 w-5 border-2 border-gray-400 rounded-full flex items-center justify-center">
<div id="president-candidate1-check" class="h-3 w-3 bg-primary rounded-full hidden"></div>
</div>
</div>
</div>
<input type="radio" id="president-candidate1" name="president" class="hidden" value="Andrew Kwarteng">
</div>
<div class="vote-card bg-gray-50 p-4 rounded-lg border border-gray-200 hover:border-primary transition duration-300 cursor-pointer" onclick="selectCandidate('president', 'candidate2')">
<div class="flex items-center space-x-4">
<div class="h-12 w-12 rounded-full bg-secondary flex items-center justify-center text-white font-bold">EA</div>
<div>
<h4 class="font-semibold">Esi Amankwah</h4>
<p class="text-sm text-gray-600">Business Administration</p>
</div>
<div class="ml-auto">
<div class="h-5 w-5 border-2 border-gray-400 rounded-full flex items-center justify-center">
<div id="president-candidate2-check" class="h-3 w-3 bg-primary rounded-full hidden"></div>
</div>
</div>
</div>
<input type="radio" id="president-candidate2" name="president" class="hidden" value="Esi Amankwah">
</div>
<div class="vote-card bg-gray-50 p-4 rounded-lg border border-gray-200 hover:border-primary transition duration-300 cursor-pointer" onclick="selectCandidate('president', 'candidate3')">
<div class="flex items-center space-x-4">
<div class="h-12 w-12 rounded-full bg-accent flex items-center justify-center text-white font-bold">KB</div>
<div>
<h4 class="font-semibold">Kwame Boateng</h4>
<p class="text-sm text-gray-600">Electrical Engineering</p>
</div>
<div class="ml-auto">
<div class="h-5 w-5 border-2 border-gray-400 rounded-full flex items-center justify-center">
<div id="president-candidate3-check" class="h-3 w-3 bg-primary rounded-full hidden"></div>
</div>
</div>
</div>
<input type="radio" id="president-candidate3" name="president" class="hidden" value="Kwame Boateng">
</div>
</div>
</div>
<!-- Position 2 -->
<div class="bg-white rounded-lg shadow-md p-6">
<h3 class="text-xl font-bold mb-4 border-b pb-2">General Secretary</h3>
<div class="space-y-4">
<div class="vote-card bg-gray-50 p-4 rounded-lg border border-gray-200 hover:border-primary transition duration-300 cursor-pointer" onclick="selectCandidate('secretary', 'candidate1')">
<div class="flex items-center space-x-4">
<div class="h-12 w-12 rounded-full bg-primary-light flex items-center justify-center text-white font-bold">SA</div>
<div>
<h4 class="font-semibold">Sandra Addo</h4>
<p class="text-sm text-gray-600">Accounting</p>
</div>
<div class="ml-auto">
<div class="h-5 w-5 border-2 border-gray-400 rounded-full flex items-center justify-center">
<div id="secretary-candidate1-check" class="h-3 w-3 bg-primary rounded-full hidden"></div>
</div>
</div>
</div>
<input type="radio" id="secretary-candidate1" name="secretary" class="hidden" value="Sandra Addo">
</div>
<div class="vote-card bg-gray-50 p-4 rounded-lg border border-gray-200 hover:border-primary transition duration-300 cursor-pointer" onclick="selectCandidate('secretary', 'candidate2')">
<div class="flex items-center space-x-4">
<div class="h-12 w-12 rounded-full bg-secondary flex items-center justify-center text-white font-bold">DJ</div>
<div>
<h4 class="font-semibold">David Johnson</h4>
<p class="text-sm text-gray-600">Mechanical Engineering</p>
</div>
<div class="ml-auto">
<div class="h-5 w-5 border-2 border-gray-400 rounded-full flex items-center justify-center">
<div id="secretary-candidate2-check" class="h-3 w-3 bg-primary rounded-full hidden"></div>
</div>
</div>
</div>
<input type="radio" id="secretary-candidate2" name="secretary" class="hidden" value="David Johnson">
</div>
</div>
</div>
</div>
<div id="confirmation-modal" class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white rounded-lg shadow-xl p-6 w-full max-w-md">
<h3 class="text-xl font-bold mb-4">Confirm Your Votes</h3>
<div class="mb-6">
<p class="font-semibold">SRC President:</p>
<p id="confirm-president" class="text-gray-600">Not selected</p>
<p class="font-semibold mt-3">General Secretary:</p>
<p id="confirm-secretary" class="text-gray-600">Not selected</p>
</div>
<div class="flex justify-end space-x-4">
<button onclick="document.getElementById('confirmation-modal').classList.add('hidden')" class="px-4 py-2 border border-gray-300 rounded hover:bg-gray-100 transition">Cancel</button>
<button onclick="submitVotes()" class="bg-primary hover:bg-primary-light text-white px-4 py-2 rounded transition">Confirm & Submit</button>
</div>
</div>
</div>
<div class="text-center">
<button id="submit-votes-btn" onclick="confirmVotes()" disabled class="bg-primary hover:bg-primary-light text-white font-bold py-3 px-8 rounded-lg transition disabled:bg-gray-400 disabled:cursor-not-allowed">
Submit Votes
</button>
</div>
</div>
</section>
<!-- Results Section -->
<section id="results-section" class="hidden max-w-4xl mx-auto">
<div class="text-center mb-8">
<h2 class="text-3xl font-bold text-dark">Election Results</h2>
<p class="text-gray-600">SRC Elections 2023/2024 - Final Results</p>
</div>
<div class="bg-white rounded-lg shadow-md p-6 mb-8">
<div class="flex justify-between items-center mb-6">
<h3 class="text-xl font-bold">SRC President</h3>
<div class="text-sm text-gray-500">
<span>Total Votes: 1,245</span>
<span class="ml-4">Voter Turnout: 82%</span>
</div>
</div>
<div class="space-y-4">
<!-- Candidate 1 -->
<div class="border-l-4 border-primary pl-4">
<div class="flex justify-between items-center mb-1">
<div class="font-semibold">Andrew Kwarteng - Computer Science</div>
<div class="font-bold">56%</div>
</div>
<div class="w-full bg-gray-200 rounded-full h-4">
<div class="bg-primary h-4 rounded-full" style="width: 56%"></div>
</div>
<div class="text-sm text-gray-500 mt-1">698 votes</div>
</div>
<!-- Candidate 2 -->
<div class="border-l-4 border-secondary pl-4">
<div class="flex justify-between items-center mb-1">
<div class="font-semibold">Esi Amankwah - Business Administration</div>
<div class="font-bold">32%</div>
</div>
<div class="w-full bg-gray-200 rounded-full h-4">
<div class="bg-secondary h-4 rounded-full" style="width: 32%"></div>
</div>
<div class="text-sm text-gray-500 mt-1">398 votes</div>
</div>
<!-- Candidate 3 -->
<div class="border-l-4 border-accent pl-4">
<div class="flex justify-between items-center mb-1">
<div class="font-semibold">Kwame Boateng - Electrical Engineering</div>
<div class="font-bold">12%</div>
</div>
<div class="w-full bg-gray-200 rounded-full h-4">
<div class="bg-accent h-4 rounded-full" style="width: 12%"></div>
</div>
<div class="text-sm text-gray-500 mt-1">149 votes</div>
</div>
</div>
</div>
<div class="bg-white rounded-lg shadow-md p-6">
<div class="flex justify-between items-center mb-6">
<h3 class="text-xl font-bold">General Secretary</h3>
<div class="text-sm text-gray-500">
<span>Total Votes: 1,245</span>
<span class="ml-4">Voter Turnout: 82%</span>
</div>
</div>
<div class="space-y-4">
<!-- Candidate 1 -->
<div class="border-l-4 border-primary-light pl-4">
<div class="flex justify-between items-center mb-1">
<div class="font-semibold">Sandra Addo - Accounting</div>
<div class="font-bold">64%</div>
</div>
<div class="w-full bg-gray-200 rounded-full h-4">
<div class="bg-primary-light h-4 rounded-full" style="width: 64%"></div>
</div>
<div class="text-sm text-gray-500 mt-1">797 votes</div>
</div>
<!-- Candidate 2 -->
<div class="border-l-4 border-green-400 pl-4">
<div class="flex justify-between items-center mb-1">
<div class="font-semibold">David Johnson - Mechanical Engineering</div>
<div class="font-bold">36%</div>
</div>
<div class="w-full bg-gray-200 rounded-full h-4">
<div class="bg-green-400 h-4 rounded-full" style="width: 36%"></div>
</div>
<div class="text-sm text-gray-500 mt-1">448 votes</div>
</div>
</div>
</div>
<div class="mt-8 bg-white rounded-lg shadow-md p-6">
<h3 class="text-xl font-bold mb-4">Summary</h3>
<div class="grid md:grid-cols-3 gap-4">
<div class="text-center p-4 border rounded-lg">
<div class="text-3xl font-bold text-primary">1,245</div>
<div class="text-gray-600">Total Votes</div>
</div>
<div class="text-center p-4 border rounded-lg">
<div class="text-3xl font-bold text-secondary">82%</div>
<div class="text-gray-600">Voter Turnout</div>
</div>
<div class="text-center p-4 border rounded-lg">
<div class="text-3xl font-bold text-accent">5</div>
<div class="text-gray-600">Contested Positions</div>
</div>
</div>
</div>
</section>
<!-- Admin Dashboard Section -->
<section id="admin-section" class="hidden max-w-6xl mx-auto">
<div class="text-center mb-8">
<h2 class="text-3xl font-bold text-dark">Admin Dashboard</h2>
<p class="text-gray-600">Manage elections, candidates, and voter information</p>
</div>
<div class="grid md:grid-cols-3 gap-6 mb-8">
<div class="bg-white rounded-lg shadow-md p-6 cursor-pointer hover:shadow-lg transition" onclick="showAdminSection('elections')">
<div class="flex items-center space-x-4">
<div class="bg-primary-light bg-opacity-10 p-3 rounded-full">
<i class="fas fa-calendar-alt text-primary text-xl"></i>
</div>
<div>
<h3 class="font-bold text-lg">Elections</h3>
<p class="text-gray-600 text-sm">Manage active and upcoming elections</p>
</div>
</div>
</div>
<div class="bg-white rounded-lg shadow-md p-6 cursor-pointer hover:shadow-lg transition" onclick="showAdminSection('candidates')">
<div class="flex items-center space-x-4">
<div class="bg-secondary bg-opacity-10 p-3 rounded-full">
<i class="fas fa-users text-secondary text-xl"></i>
</div>
<div>
<h3 class="font-bold text-lg">Candidates</h3>
<p class="text-gray-600 text-sm">Add and manage candidates</p>
</div>
</div>
</div>
<div class="bg-white rounded-lg shadow-md p-6 cursor-pointer hover:shadow-lg transition" onclick="showAdminSection('voters')">
<div class="flex items-center space-x-4">
<div class="bg-accent bg-opacity-10 p-3 rounded-full">
<i class="fas fa-user-graduate text-accent text-xl"></i>
</div>
<div>
<h3 class="font-bold text-lg">Voters</h3>
<p class="text-gray-600 text-sm">Manage voter registration</p>
</div>
</div>
</div>
</div>
<!-- Admin Elections Subsection -->
<div id="admin-elections" class="bg-white rounded-lg shadow-md p-6">
<div class="flex justify-between items-center mb-6">
<h3 class="text-xl font-bold">Elections Management</h3>
<button onclick="showAddElectionModal()" class="bg-primary hover:bg-primary-light text-white px-4 py-2 rounded text-sm">
<i class="fas fa-plus mr-1"></i> Add Election
</button>
</div>
<div class="overflow-x-auto">
<table class="min-w-full">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Title</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Start Date</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">End Date</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<tr>
<td class="px-6 py-4 whitespace-nowrap">SRC President 2023/2024</td>
<td class="px-6 py-4 whitespace-nowrap">2023-06-01</td>
<td class="px-6 py-4 whitespace-nowrap">2023-06-05</td>
<td class="px-6 py-4 whitespace-nowrap"><span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">Active</span></td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<button class="text-primary hover:text-primary-light mr-3"><i class="fas fa-edit"></i></button>
<button class="text-red-500 hover:text-red-700"><i class="fas fa-trash"></i></button>
</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap">Academic Committee</td>
<td class="px-6 py-4 whitespace-nowrap">2023-06-10</td>
<td class="px-6 py-4 whitespace-nowrap">2023-06-12</td>
<td class="px-6 py-4 whitespace-nowrap"><span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-yellow-100 text-yellow-800">Upcoming</span></td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<button class="text-primary hover:text-primary-light mr-3"><i class="fas fa-edit"></i></button>
<button class="text-red-500 hover:text-red-700"><i class="fas fa-trash"></i></button>
</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap">Sports Committee</td>
<td class="px-6 py-4 whitespace-nowrap">2023-05-20</td>
<td class="px-6 py-4 whitespace-nowrap">2023-05-22</td>
<td class="px-6 py-4 whitespace-nowrap"><span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">Ended</span></td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<button class="text-primary hover:text-primary-light mr-3"><i class="fas fa-edit"></i></button>
<button class="text-red-500 hover:text-red-700"><i class="fas fa-trash"></i></button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- Admin Candidates Subsection (Hidden by default) -->
<div id="admin-candidates" class="hidden bg-white rounded-lg shadow-md p-6">
<div class="flex justify-between items-center mb-6">
<h3 class="text-xl font-bold">Candidates Management</h3>
<button onclick="showAddCandidateModal()" class="bg-primary hover:bg-primary-light text-white px-4 py-2 rounded text-sm">
<i class="fas fa-plus mr-1"></i> Add Candidate
</button>
</div>
<div class="overflow-x-auto">
<table class="min-w-full">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Position</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Department</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Election</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<tr>
<td class="px-6 py-4 whitespace-nowrap">Andrew Kwarteng</td>
<td class="px-6 py-4 whitespace-nowrap">SRC President</td>
<td class="px-6 py-4 whitespace-nowrap">Computer Science</td>
<td class="px-6 py-4 whitespace-nowrap">SRC President 2023/2024</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<button class="text-primary hover:text-primary-light mr-3"><i class="fas fa-edit"></i></button>
<button class="text-red-500 hover:text-red-700"><i class="fas fa-trash"></i></button>
</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap">Esi Amankwah</td>
<td class="px-6 py-4 whitespace-nowrap">SRC President</td>
<td class="px-6 py-4 whitespace-nowrap">Business Administration</td>
<td class="px-6 py-4 whitespace-nowrap">SRC President 2023/2024</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<button class="text-primary hover:text-primary-light mr-3"><i class="fas fa-edit"></i></button>
<button class="text-red-500 hover:text-red-700"><i class="fas fa-trash"></i></button>
</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap">Sandra Addo</td>
<td class="px-6 py-4 whitespace-nowrap">General Secretary</td>
<td class="px-6 py-4 whitespace-nowrap">Accounting</td>
<td class="px-6 py-4 whitespace-nowrap">SRC President 2023/2024</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<button class="text-primary hover:text-primary-light mr-3"><i class="fas fa-edit"></i></button>
<button class="text-red-500 hover:text-red-700"><i class="fas fa-trash"></i></button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- Admin Voters Subsection (Hidden by default) -->
<div id="admin-voters" class="hidden bg-white rounded-lg shadow-md p-6">
<div class="flex justify-between items-center mb-6">
<h3 class="text-xl font-bold">Voters Management</h3>
<div class="flex space-x-3">
<button onclick="showImportVotersModal()" class="bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded text-sm">
<i class="fas fa-file-import mr-1"></i> Import
</button>
<button onclick="showAddVoterModal()" class="bg-primary hover:bg-primary-light text-white px-4 py-2 rounded text-sm">
<i class="fas fa-plus mr-1"></i> Add Voter
</button>
</div>
</div>
<div class="mb-4 flex justify-between items-center">
<div class="relative max-w-xs">
<label for="voter-search" class="sr-only">Search</label>
<div class="relative">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<i class="fas fa-search text-gray-400"></i>
</div>
<input type="text" id="voter-search" class="block w-full pl-10 pr-3 py-2 border border-gray-300 rounded-md leading-5 bg-white placeholder-gray-500 focus:outline-none focus:ring-primary focus:border-primary sm:text-sm" placeholder="Search">
</div>
</div>
<div class="flex items-center space-x-2">
<span class="text-sm text-gray-600">Filter by:</span>
<select class="block w-full pl-3 pr-10 py-2 text-base border border-gray-300 focus:outline-none focus:ring-primary focus:border-primary sm:text-sm rounded-md">
<option>All</option>
<option>Students</option>
<option>Staff</option>
</select>
</div>
</div>
<div class="overflow-x-auto">
<table class="min-w-full">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Student ID</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Full Name</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Program</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Level</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Voted</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<tr>
<td class="px-6 py-4 whitespace-nowrap">NKSHT2023001</td>
<td class="px-6 py-4 whitespace-nowrap">John Mensah</td>
<td class="px-6 py-4 whitespace-nowrap">Computer Science</td>
<td class="px-6 py-4 whitespace-nowrap">200</td>
<td class="px-6 py-4 whitespace-nowrap"><span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">Yes</span></td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<button class="text-primary hover:text-primary-light mr-3"><i class="fas fa-edit"></i></button>
<button class="text-red-500 hover:text-red-700"><i class="fas fa-trash"></i></button>
</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap">NKSHT2023002</td>
<td class="px-6 py-4 whitespace-nowrap">Ama Asante</td>
<td class="px-6 py-4 whitespace-nowrap">Business Admin</td>
<td class="px-6 py-4 whitespace-nowrap">100</td>
<td class="px-6 py-4 whitespace-nowrap"><span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">Yes</span></td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<button class="text-primary hover:text-primary-light mr-3"><i class="fas fa-edit"></i></button>
<button class="text-red-500 hover:text-red-700"><i class="fas fa-trash"></i></button>
</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap">NKSHT2023003</td>
<td class="px-6 py-4 whitespace-nowrap">Kwaku Boateng</td>
<td class="px-6 py-4 whitespace-nowrap">Electrical Eng.</td>
<td class="px-6 py-4 whitespace-nowrap">300</td>
<td class="px-6 py-4 whitespace-nowrap"><span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">No</span></td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<button class="text-primary hover:text-primary-light mr-3"><i class="fas fa-edit"></i></button>
<button class="text-red-500 hover:text-red-700"><i class="fas fa-trash"></i></button>
</td>
</tr>
</tbody>
</table>
</div>
<div class="mt-4 flex justify-between items-center">
<div class="text-sm text-gray-500">
Showing <span class="font-medium">1</span> to <span class="font-medium">3</span> of <span class="font-medium">1,245</span> voters
</div>
<nav class="flex space-x-2">
<button class="px-3 py-1 border border-gray-300 rounded text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">
Previous
</button>
<button class="px-3 py-1 border border-gray-300 rounded text-sm font-medium bg-primary text-white">
1
</button>
<button class="px-3 py-1 border border-gray-300 rounded text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">
2
</button>
<button class="px-3 py-1 border border-gray-300 rounded text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">
3
</button>
<button class="px-3 py-1 border border-gray-300 rounded text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">
Next
</button>
</nav>
</div>
</div>
</section>
<!-- Success Modal -->
<div id="success-modal" class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white rounded-lg shadow-xl p-6 w-full max-w-md">
<div class="flex flex-col items-center">
<div class="w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mb-4">
<i class="fas fa-check text-green-600 text-2xl"></i>
</div>
<h3 class="text-xl font-bold mb-2 text-center">Vote Submitted Successfully!</h3>
<p class="text-gray-600 text-center mb-4">Thank you for participating in the Nkoranza SHTs elections.</p>
<button onclick="document.getElementById('success-modal').classList.add('hidden'); showSection('home')" class="bg-primary hover:bg-primary-light text-white px-4 py-2 rounded transition w-full">
Continue
</button>
</div>
</div>
</div>
<!-- Admin Modals -->
<!-- Add Election Modal -->
<div id="add-election-modal" class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white rounded-lg shadow-xl p-6 w-full max-w-lg">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-bold">Add New Election</h3>
<button onclick="document.getElementById('add-election-modal').classList.add('hidden')" class="text-gray-400 hover:text-gray-500">
<i class="fas fa-times"></i>
</button>
</div>
<form class="space-y-4">
<div>
<label for="election-title" class="block text-sm font-medium text-gray-700 mb-1">Election Title</label>
<input type="text" id="election-title" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="start-date" class="block text-sm font-medium text-gray-700 mb-1">Start Date</label>
<input type="datetime-local" id="start-date" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
</div>
<div>
<label for="end-date" class="block text-sm font-medium text-gray-700 mb-1">End Date</label>
<input type="datetime-local" id="end-date" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
</div>
</div>
<div>
<label for="election-description" class="block text-sm font-medium text-gray-700 mb-1">Description</label>
<textarea id="election-description" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary"></textarea>
</div>
<div class="flex justify-end space-x-3 pt-4">
<button type="button" onclick="document.getElementById('add-election-modal').classList.add('hidden')" class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary">
Cancel
</button>
<button type="button" onclick="addNewElection()" class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-primary hover:bg-primary-light focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary">
Save Election
</button>
</div>
</form>
</div>
</div>
<!-- Add Candidate Modal -->
<div id="add-candidate-modal" class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white rounded-lg shadow-xl p-6 w-full max-w-lg">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-bold">Add New Candidate</h3>
<button onclick="document.getElementById('add-candidate-modal').classList.add('hidden')" class="text-gray-400 hover:text-gray-500">
<i class="fas fa-times"></i>
</button>
</div>
<form class="space-y-4">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="candidate-firstname" class="block text-sm font-medium text-gray-700 mb-1">First Name</label>
<input type="text" id="candidate-firstname" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
</div>
<div>
<label for="candidate-lastname" class="block text-sm font-medium text-gray-700 mb-1">Last Name</label>
<input type="text" id="candidate-lastname" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
</div>
</div>
<div>
<label for="candidate-election" class="block text-sm font-medium text-gray-700 mb-1">Election</label>
<select id="candidate-election" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
<option>Select Election</option>
<option>SRC President 2023/2024</option>
<option>Academic Committee 2023/2024</option>
</select>
</div>
<div>
<label for="candidate-position" class="block text-sm font-medium text-gray-700 mb-1">Position</label>
<input type="text" id="candidate-position" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
</div>
<div>
<label for="candidate-department" class="block text-sm font-medium text-gray-700 mb-1">Department</label>
<select id="candidate-department" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
<option>Select Department</option>
<option>Computer Science</option>
<option>Business Administration</option>
<option>Electrical Engineering</option>
<option>Mechanical Engineering</option>
<option>Accounting</option>
</select>
</div>
<div>
<label for="candidate-manifesto" class="block text-sm font-medium text-gray-700 mb-1">Manifesto (Optional)</label>
<textarea id="candidate-manifesto" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary"></textarea>
</div>
<div>
<label for="candidate-photo" class="block text-sm font-medium text-gray-700 mb-1">Photo</label>
<div class="mt-1 flex items-center">
<span class="inline-block h-12 w-12 rounded-full overflow-hidden bg-gray-100">
<svg class="h-full w-full text-gray-300" fill="currentColor" viewBox="0 0 24 24">
<path d="M24 20.993V24H0v-2.996A14.977 14.977 0 0112.004 15c4.904 0 9.26 2.354 11.996 5.993zM16.002 8.999a4 4 0 11-8 0 4 4 0 018 0z" />
</svg>
</span>
<button type="button" class="ml-5 bg-white py-2 px-3 border border-gray-300 rounded-md shadow-sm text-sm leading-4 font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary">
Upload
</button>
</div>
</div>
<div class="flex justify-end space-x-3 pt-4">
<button type="button" onclick="document.getElementById('add-candidate-modal').classList.add('hidden')" class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary">
Cancel
</button>
<button type="button" onclick="addNewCandidate()" class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-primary hover:bg-primary-light focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary">
Save Candidate
</button>
</div>
</form>
</div>
</div>
<!-- Add Voter Modal -->
<div id="add-voter-modal" class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white rounded-lg shadow-xl p-6 w-full max-w-lg">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-bold">Add New Voter</h3>
<button onclick="document.getElementById('add-voter-modal').classList.add('hidden')" class="text-gray-400 hover:text-gray-500">
<i class="fas fa-times"></i>
</button>
</div>
<form class="space-y-4">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="voter-id" class="block text-sm font-medium text-gray-700 mb-1">Student ID</label>
<input type="text" id="voter-id" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
</div>
<div>
<label for="voter-password" class="block text-sm font-medium text-gray-700 mb-1">Password</label>
<input type="password" id="voter-password" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="voter-firstname" class="block text-sm font-medium text-gray-700 mb-1">First Name</label>
<input type="text" id="voter-firstname" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
</div>
<div>
<label for="voter-lastname" class="block text-sm font-medium text-gray-700 mb-1">Last Name</label>
<input type="text" id="voter-lastname" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="voter-department" class="block text-sm font-medium text-gray-700 mb-1">Department</label>
<select id="voter-department" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
<option>Select Department</option>
<option>Computer Science</option>
<option>Business Administration</option>
<option>Electrical Engineering</option>
<option>Mechanical Engineering</option>
<option>Accounting</option>
</select>
</div>
<div>
<label for="voter-level" class="block text-sm font-medium text-gray-700 mb-1">Level</label>
<select id="voter-level" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
<option>100</option>
<option>200</option>
<option>300</option>
<option>400</option>
</select>
</div>
</div>
<div>
<label for="voter-email" class="block text-sm font-medium text-gray-700 mb-1">Email</label>
<input type="email" id="voter-email" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
</div>
<div class="flex justify-end space-x-3 pt-4">
<button type="button" onclick="document.getElementById('add-voter-modal').classList.add('hidden')" class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary">
Cancel
</button>
<button type="button" onclick="addNewVoter()" class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-primary hover:bg-primary-light focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary">
Save Voter
</button>
</div>
</form>
</div>
</div>
<!-- Import Voters Modal -->
<div id="import-voters-modal" class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white rounded-lg shadow-xl p-6 w-full max-w-lg">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-bold">Import Voters</h3>
<button onclick="document.getElementById('import-voters-modal').classList.add('hidden')" class="text-gray-400 hover:text-gray-500">
<i class="fas fa-times"></i>
</button>
</div>
<div class="space-y-4">
<div>
<p class="text-sm text-gray-500 mb-4">Upload a CSV file containing voter information. The file should include the following columns in order: Student ID, Password, First Name, Last Name, Department, Level, Email.</p>
<div class="mt-1 flex justify-center px-6 pt-5 pb-6 border-2 border-gray-300 border-dashed rounded-md">
<div class="space-y-1 text-center">
<svg class="mx-auto h-12 w-12 text-gray-400" stroke="currentColor" fill="none" viewBox="0 0 48 48" aria-hidden="true">
<path d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
</svg>
<div class="flex text-sm text-gray-600">
<label for="voter-file" class="relative cursor-pointer bg-white rounded-md font-medium text-primary hover:text-primary-light focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-primary">
<span>Upload a file</span>
<input id="voter-file" type="file" class="sr-only">
</label>
<p class="pl-1">or drag and drop</p>
</div>
<p class="text-xs text-gray-500">
CSV file up to 10MB
</p>
</div>
</div>
</div>
<div class="flex justify-end space-x-3 pt-4">
<button type="button" onclick="document.getElementById('import-voters-modal').classList.add('hidden')" class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary">
Cancel
</button>
<button type="button" onclick="importVoters()" class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-primary hover:bg-primary-light focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary">
Import Voters
</button>
</div>
</div>
</div>
</div>
</main>
<!-- Footer -->
<footer class="bg-dark text-white py-8">
<div class="container mx-auto px-4">
<div class="grid md:grid-cols-3 gap-8">
<div>
<h3 class="text-xl font-bold mb-4">Nkoranza SHTs</h3>
<p class="text-gray-300">Empowering students through democratic processes and transparent elections.</p>
</div>
<div>
<h4 class="text-lg font-semibold mb-4">Quick Links</h4>
<ul class="space-y-2">
<li><a href="#" class="text-gray-300 hover:text-white transition">Home</a></li>
<li><a href="#" class="text-gray-300 hover:text-white transition">Vote</a></li>
<li><a href="#" class="text-gray-300 hover:text-white transition">Results</a></li>
<li><a href="#" class="text-gray-300 hover:text-white transition">Contact</a></li>
</ul>
</div>
<div>
<h4 class="text-lg font-semibold mb-4">Contact Us</h4>
<address class="text-gray-300 not-italic">
<p><i class="fas fa-map-marker-alt mr-2"></i> Nkoranza Technical Institute, Ghana</p>
<p><i class="fas fa-phone-alt mr-2"></i> +233 24 123 4567</p>
<p><i class="fas fa-envelope mr-2"></i> election@nkoranzashts.edu.gh</p>
</address>
</div>
</div>
<div class="border-t border-gray-700 mt-8 pt-6 text-center text-gray-400">
<p>© 2023 Nkoranza Senior High Technical School. All rights reserved.</p>
</div>
</div>
</footer>
</div>
<script>
// Backend API base URL
const API_BASE_URL = 'https://your-api-domain.com/api';
// JWT token storage
let authToken = localStorage.getItem('authToken') || null;
let currentUser = null;
let selectedCandidates = {
president: null,
secretary: null
};
// Helper function for API calls
async function apiCall(endpoint, method = 'GET', body = null) {
const headers = {
'Content-Type': 'application/json',
};
if (authToken) {
headers['Authorization'] = `Bearer ${authToken}`;
}
const options = {
method,
headers,
};
if (body) {
options.body = JSON.stringify(body);
}
try {
const response = await fetch(`${API_BASE_URL}${endpoint}`, options);
const data = await response.json();
if (!response.ok) {
throw new Error(data.message || 'API request failed');
}
return data;
} catch (error) {
console.error('API Error:', error);
throw error;
}
}
// Initialize app on page load
document.addEventListener('DOMContentLoaded', async function() {
try {
// Try to authenticate with stored token
if (authToken) {
showLoader();
const userData = await apiCall('/auth/verify');
currentUser = userData.user;
updateNavForAdmin();
}
} catch (error) {
localStorage.removeItem('authToken');
authToken = null;
} finally {
hideLoader();
showSection('home');
}
});
// Section navigation
function showSection(sectionId) {
// Hide all sections
document.getElementById('home-section').classList.add('hidden');
document.getElementById('login-section').classList.add('hidden');
document.getElementById('vote-section').classList.add('hidden');
document.getElementById('results-section').classList.add('hidden');
document.getElementById('admin-section').classList.add('hidden');
// Show selected section
document.getElementById(`${sectionId}-section`).classList.remove('hidden');
// Check authentication for protected sections
if ((sectionId === 'vote' || sectionId === 'admin') && !currentUser) {
showSection('login');
}
// Check if admin and show admin nav if true
updateNavForAdmin();
}
// Admin management sections
function showAdminSection(section) {
// Hide all admin subsections
document.getElementById('admin-elections').classList.add('hidden');
document.getElementById('admin-candidates').classList.add('hidden');
document.getElementById('admin-voters').classList.add('hidden');
// Show selected subsection
document.getElementById(`admin-${section}`).classList.remove('hidden');
}
// Update navigation based on user role
function updateNavForAdmin() {
const adminNav = document.getElementById('admin-nav');
const loginNav = document.getElementById('login-nav');
const logoutNav = document.getElementById('logout-nav');
if (currentUser && currentUser.isAdmin) {
adminNav.classList.remove('hidden');
loginNav.classList.add('hidden');
logoutNav.classList.remove('hidden');
} else if (currentUser) {
adminNav.classList.add('hidden');
loginNav.classList.add('hidden');
logoutNav.classList.remove('hidden');
} else {
adminNav.classList.add('hidden');
loginNav.classList.remove('hidden');
logoutNav.classList.add('hidden');
}
}
// User authentication
async function authenticateUser() {
const studentId = document.getElementById('studentId').value;
const password = document.getElementById('password').value;
showLoader();
try {
const response = await apiCall('/auth/login', 'POST', {
studentId,
password
});
authToken = response.token;
localStorage.setItem('authToken', authToken);
currentUser = response.user;
hideLoader();
updateNavForAdmin();
if (currentUser.isAdmin) {
showSection('admin');
} else {
showSection('home');
}
// Reset login form
document.getElementById('studentId').value = '';
document.getElementById('password').value = '';
document.getElementById('login-error').classList.add('hidden');
// Load elections data
await loadElectionsData();
} catch (error) {
hideLoader();
document.getElementById('login-error').querySelector('p').textContent =
error.message || 'Invalid credentials. Please try again.';
document.getElementById('login-error').classList.remove('hidden');
console.error('Login error:', error);
}
}
// Logout functionality
function logout() {
authToken = null;
currentUser = null;
localStorage.removeItem('authToken');
updateNavForAdmin();
showSection('home');
}
// Load elections data
async function loadElectionsData() {
try {
showLoader();
const elections = await apiCall('/elections/active');
// Update UI with elections data
// ... implementation depends on your API response structure
} catch (error) {
console.error('Failed to load elections:', error);
} finally {
hideLoader();
}
}
// Voting functionality
function selectCandidate(position, candidateId) {
// Reset all selections for this position
const allChecks = document.querySelectorAll(`[id^="${position}-"]`);
allChecks.forEach(check => {
if (check.id.endsWith('-check')) {
check.classList.add('hidden');
}
});
// Select the chosen candidate
document.getElementById(`${position}-${candidateId}`).checked = true;
document.getElementById(`${position}-${candidateId}-check`).classList.remove('hidden');
// Update our selected candidates object
const candidateName = document.getElementById(`${position}-${candidateId}`).value;
selectedCandidates[position] = candidateName;
// Enable submit button if all positions have a selection
const submitBtn = document.getElementById('submit-votes-btn');
const allPositionsFilled = Object.values(selectedCandidates).every(candidate => candidate !== null);
submitBtn.disabled = !allPositionsFilled;
}
// Confirm votes before submission
function confirmVotes() {
document.getElementById('confirm-president').textContent = selectedCandidates.president || 'Not selected';
document.getElementById('confirm-secretary').textContent = selectedCandidates.secretary || 'Not selected';
document.getElementById('confirmation-modal').classList.remove('hidden');
}
// Submit votes
async function submitVotes() {
showLoader();
try {
await apiCall('/votes/submit', 'POST', {
elections: selectedCandidates
});
hideLoader();
document.getElementById('confirmation-modal').classList.add('hidden');
document.getElementById('success-modal').classList.remove('hidden');
// Mark user as voted
if (currentUser) {
currentUser.hasVoted = true;
}
resetVoteSelections();
} catch (error) {
hideLoader();
alert(`Failed to submit votes: ${error.message}`);
console.error('Vote submission error:', error);
}
}
// Reset vote selections
function resetVoteSelections() {
selectedCandidates = {
president: null,
secretary: null
};
// Uncheck all radio buttons
document.querySelectorAll('input[type="radio"]').forEach(radio => {
radio.checked = false;
});
// Hide all checkmarks
document.querySelectorAll('[id$="-check"]').forEach(check => {
check.classList.add('hidden');
});
// Disable submit button
document.getElementById('submit-votes-btn').disabled = true;
}
// Admin modal functions
function showAddElectionModal() {
document.getElementById('add-election-modal').classList.remove('hidden');
}
function showAddCandidateModal() {
document.getElementById('add-candidate-modal').classList.remove('hidden');
}
function showAddVoterModal() {
document.getElementById('add-voter-modal').classList.remove('hidden');
}
function showImportVotersModal() {
document.getElementById('import-voters-modal').classList.remove('hidden');
}
// Admin CRUD functions
async function addNewElection() {
showLoader();
try {
const title = document.getElementById('election-title').value;
const startDate = document.getElementById('start-date').value;
const endDate = document.getElementById('end-date').value;
const description = document.getElementById('election-description').value;
await apiCall('/elections', 'POST', {
title,
startDate,
endDate,
description
});
hideLoader();
document.getElementById('add-election-modal').classList.add('hidden');
alert('Election added successfully!');
await showAdminSection('elections');
} catch (error) {
hideLoader();
alert(`Failed to add election: ${error.message}`);
}
}
async function addNewCandidate() {
showLoader();
try {
const firstName = document.getElementById('candidate-firstname').value;
const lastName = document.getElementById('candidate-lastname').value;
const electionId = document.getElementById('candidate-election').value;
const position = document.getElementById('candidate-position').value;
const department = document.getElementById('candidate-department').value;
const manifesto = document.getElementById('candidate-manifesto').value;
// File upload would need separate handling
await apiCall('/candidates', 'POST', {
firstName,
lastName,
electionId,
position,
department,
manifesto
});
hideLoader();
document.getElementById('add-candidate-modal').classList.add('hidden');
alert('Candidate added successfully!');
await showAdminSection('candidates');
} catch (error) {
hideLoader();
alert(`Failed to add candidate: ${error.message}`);
}
}
async function addNewVoter() {
showLoader();
try {
const studentId = document.getElementById('voter-id').value;
const password = document.getElementById('voter-password').value;
const firstName = document.getElementById('voter-firstname').value;
const lastName = document.getElementById('voter-lastname').value;
const department = document.getElementById('voter-department').value;
const level = document.getElementById('voter-level').value;
const email = document.getElementById('voter-email').value;
await apiCall('/voters', 'POST', {
studentId,
password,
firstName,
lastName,
department,
level,
email
});
hideLoader();
document.getElementById('add-voter-modal').classList.add('hidden');
alert('Voter added successfully!');
await showAdminSection('voters');
} catch (error) {
hideLoader();
alert(`Failed to add voter: ${error.message}`);
}
}
async function importVoters() {
showLoader();
try {
const fileInput = document.getElementById('voter-file');
if (!fileInput.files.length) {
throw new Error('Please select a file');
}
const formData = new FormData();
formData.append('file', fileInput.files[0]);
const response = await fetch(`${API_BASE_URL}/voters/import`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${authToken}`
},
body: formData
});
if (!response.ok) {
throw new Error(await response.text());
}
hideLoader();
document.getElementById('import-voters-modal').classList.add('hidden');
alert('Voters imported successfully!');
await showAdminSection('voters');
} catch (error) {
hideLoader();
alert(`Failed to import voters: ${error.message}`);
}
}
// Loader functions
function showLoader() {
document.getElementById('loader-section').classList.remove('hidden');
}
function hideLoader() {
document.getElementById('loader-section').classList.add('hidden');
}
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Truth-Bongo/e-voting-testing" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |