Boody25 commited on
Commit
aeb5f7f
·
verified ·
1 Parent(s): 8837cc6

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +580 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Student Data
3
- emoji: 🦀
4
- colorFrom: green
5
- colorTo: pink
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: student-data
3
+ emoji: 🐳
4
+ colorFrom: blue
5
+ colorTo: blue
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,580 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Student Data Management</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ /* Custom scrollbar */
11
+ ::-webkit-scrollbar {
12
+ width: 8px;
13
+ }
14
+ ::-webkit-scrollbar-track {
15
+ background: #f1f1f1;
16
+ }
17
+ ::-webkit-scrollbar-thumb {
18
+ background: #888;
19
+ border-radius: 4px;
20
+ }
21
+ ::-webkit-scrollbar-thumb:hover {
22
+ background: #555;
23
+ }
24
+
25
+ /* Animation for alerts */
26
+ @keyframes fadeIn {
27
+ from { opacity: 0; transform: translateY(-20px); }
28
+ to { opacity: 1; transform: translateY(0); }
29
+ }
30
+
31
+ .fade-in {
32
+ animation: fadeIn 0.3s ease-out forwards;
33
+ }
34
+
35
+ /* Custom checkbox */
36
+ .custom-checkbox {
37
+ appearance: none;
38
+ -webkit-appearance: none;
39
+ width: 20px;
40
+ height: 20px;
41
+ border: 2px solid #4f46e5;
42
+ border-radius: 4px;
43
+ cursor: pointer;
44
+ display: flex;
45
+ align-items: center;
46
+ justify-content: center;
47
+ }
48
+
49
+ .custom-checkbox:checked::after {
50
+ content: "✓";
51
+ color: white;
52
+ background-color: #4f46e5;
53
+ width: 100%;
54
+ height: 100%;
55
+ display: flex;
56
+ align-items: center;
57
+ justify-content: center;
58
+ border-radius: 2px;
59
+ }
60
+ </style>
61
+ </head>
62
+ <body class="bg-gray-100 font-sans">
63
+ <div class="container mx-auto p-4 max-w-6xl">
64
+ <header class="bg-indigo-600 text-white p-6 rounded-lg shadow-lg mb-8">
65
+ <div class="flex justify-between items-center">
66
+ <div>
67
+ <h1 class="text-3xl font-bold"><i class="fas fa-graduation-cap mr-3"></i>Student Data Management</h1>
68
+ <p class="mt-2 opacity-90">Add, view, and manage student records</p>
69
+ </div>
70
+ <div class="bg-white text-indigo-600 p-3 rounded-full shadow-md">
71
+ <i class="fas fa-users text-2xl"></i>
72
+ </div>
73
+ </div>
74
+ </header>
75
+
76
+ <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
77
+ <!-- Form Section -->
78
+ <div class="lg:col-span-1 bg-white p-6 rounded-lg shadow-md">
79
+ <h2 class="text-xl font-semibold text-gray-800 mb-4 border-b pb-2 flex items-center">
80
+ <i class="fas fa-user-plus mr-2 text-indigo-600"></i> Add New Student
81
+ </h2>
82
+
83
+ <form id="studentForm" class="space-y-4">
84
+ <div>
85
+ <label for="fullName" class="block text-sm font-medium text-gray-700 mb-1">Full Name</label>
86
+ <div class="relative">
87
+ <input type="text" id="fullName" name="fullName" required
88
+ class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition"
89
+ placeholder="John Doe">
90
+ <div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none">
91
+ <i class="fas fa-user text-gray-400"></i>
92
+ </div>
93
+ </div>
94
+ </div>
95
+
96
+ <div>
97
+ <label for="studentId" class="block text-sm font-medium text-gray-700 mb-1">Student ID</label>
98
+ <div class="relative">
99
+ <input type="text" id="studentId" name="studentId" required
100
+ class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition"
101
+ placeholder="STD-001">
102
+ <div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none">
103
+ <i class="fas fa-id-card text-gray-400"></i>
104
+ </div>
105
+ </div>
106
+ </div>
107
+
108
+ <div>
109
+ <label for="email" class="block text-sm font-medium text-gray-700 mb-1">Email</label>
110
+ <div class="relative">
111
+ <input type="email" id="email" name="email" required
112
+ class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition"
113
+ placeholder="student@example.com">
114
+ <div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none">
115
+ <i class="fas fa-envelope text-gray-400"></i>
116
+ </div>
117
+ </div>
118
+ </div>
119
+
120
+ <div>
121
+ <label for="phone" class="block text-sm font-medium text-gray-700 mb-1">Phone Number</label>
122
+ <div class="relative">
123
+ <input type="tel" id="phone" name="phone"
124
+ class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition"
125
+ placeholder="+1234567890">
126
+ <div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none">
127
+ <i class="fas fa-phone text-gray-400"></i>
128
+ </div>
129
+ </div>
130
+ </div>
131
+
132
+ <div>
133
+ <label for="department" class="block text-sm font-medium text-gray-700 mb-1">Department</label>
134
+ <div class="relative">
135
+ <select id="department" name="department"
136
+ class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition appearance-none">
137
+ <option value="">Select Department</option>
138
+ <option value="Computer Science">Computer Science</option>
139
+ <option value="Electrical Engineering">Electrical Engineering</option>
140
+ <option value="Mechanical Engineering">Mechanical Engineering</option>
141
+ <option value="Business Administration">Business Administration</option>
142
+ <option value="Medicine">Medicine</option>
143
+ <option value="Law">Law</option>
144
+ </select>
145
+ <div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none">
146
+ <i class="fas fa-building text-gray-400"></i>
147
+ </div>
148
+ </div>
149
+ </div>
150
+
151
+ <div>
152
+ <label for="level" class="block text-sm font-medium text-gray-700 mb-1">Level</label>
153
+ <div class="relative">
154
+ <select id="level" name="level"
155
+ class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition appearance-none">
156
+ <option value="">Select Level</option>
157
+ <option value="100">100 Level</option>
158
+ <option value="200">200 Level</option>
159
+ <option value="300">300 Level</option>
160
+ <option value="400">400 Level</option>
161
+ <option value="500">500 Level</option>
162
+ </select>
163
+ <div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none">
164
+ <i class="fas fa-layer-group text-gray-400"></i>
165
+ </div>
166
+ </div>
167
+ </div>
168
+
169
+ <div class="flex items-center">
170
+ <input type="checkbox" id="active" name="active" class="custom-checkbox">
171
+ <label for="active" class="ml-2 text-sm font-medium text-gray-700 cursor-pointer">Active Student</label>
172
+ </div>
173
+
174
+ <div class="pt-2">
175
+ <button type="submit"
176
+ class="w-full bg-indigo-600 text-white py-2 px-4 rounded-md hover:bg-indigo-700 transition flex items-center justify-center">
177
+ <i class="fas fa-save mr-2"></i> Save Student
178
+ </button>
179
+ </div>
180
+ </form>
181
+
182
+ <div id="alert" class="hidden mt-4 fade-in"></div>
183
+ </div>
184
+
185
+ <!-- Data Display Section -->
186
+ <div class="lg:col-span-2 bg-white p-6 rounded-lg shadow-md">
187
+ <div class="flex justify-between items-center mb-4 border-b pb-2">
188
+ <h2 class="text-xl font-semibold text-gray-800 flex items-center">
189
+ <i class="fas fa-list-ul mr-2 text-indigo-600"></i> Student Records
190
+ </h2>
191
+ <div class="relative w-64">
192
+ <input type="text" id="searchInput" placeholder="Search students..."
193
+ class="w-full pl-10 pr-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition">
194
+ <div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
195
+ <i class="fas fa-search text-gray-400"></i>
196
+ </div>
197
+ </div>
198
+ </div>
199
+
200
+ <div class="overflow-x-auto">
201
+ <table class="min-w-full divide-y divide-gray-200">
202
+ <thead class="bg-gray-50">
203
+ <tr>
204
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th>
205
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
206
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Department</th>
207
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Level</th>
208
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
209
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
210
+ </tr>
211
+ </thead>
212
+ <tbody id="studentTableBody" class="bg-white divide-y divide-gray-200">
213
+ <!-- Student data will be inserted here by JavaScript -->
214
+ </tbody>
215
+ </table>
216
+ </div>
217
+
218
+ <div id="noRecords" class="text-center py-8 text-gray-500">
219
+ <i class="fas fa-database text-4xl mb-2"></i>
220
+ <p>No student records found. Add your first student!</p>
221
+ </div>
222
+
223
+ <div class="mt-4 flex justify-between items-center">
224
+ <div class="text-sm text-gray-500">
225
+ Showing <span id="showingCount">0</span> of <span id="totalCount">0</span> students
226
+ </div>
227
+ <div class="flex space-x-2">
228
+ <button id="prevBtn" class="px-3 py-1 border rounded-md text-gray-700 disabled:opacity-50" disabled>
229
+ <i class="fas fa-chevron-left"></i>
230
+ </button>
231
+ <button id="nextBtn" class="px-3 py-1 border rounded-md text-gray-700 disabled:opacity-50" disabled>
232
+ <i class="fas fa-chevron-right"></i>
233
+ </button>
234
+ </div>
235
+ </div>
236
+ </div>
237
+ </div>
238
+ </div>
239
+
240
+ <!-- Edit Student Modal -->
241
+ <div id="editModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
242
+ <div class="bg-white rounded-lg shadow-xl w-full max-w-md">
243
+ <div class="flex justify-between items-center border-b p-4">
244
+ <h3 class="text-lg font-semibold text-gray-800">Edit Student</h3>
245
+ <button id="closeModal" class="text-gray-500 hover:text-gray-700">
246
+ <i class="fas fa-times"></i>
247
+ </button>
248
+ </div>
249
+ <div class="p-6">
250
+ <form id="editForm">
251
+ <input type="hidden" id="editId">
252
+ <div class="space-y-4">
253
+ <div>
254
+ <label for="editFullName" class="block text-sm font-medium text-gray-700 mb-1">Full Name</label>
255
+ <input type="text" id="editFullName" name="editFullName" required
256
+ class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition">
257
+ </div>
258
+
259
+ <div>
260
+ <label for="editStudentId" class="block text-sm font-medium text-gray-700 mb-1">Student ID</label>
261
+ <input type="text" id="editStudentId" name="editStudentId" required
262
+ class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition">
263
+ </div>
264
+
265
+ <div>
266
+ <label for="editEmail" class="block text-sm font-medium text-gray-700 mb-1">Email</label>
267
+ <input type="email" id="editEmail" name="editEmail" required
268
+ class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition">
269
+ </div>
270
+
271
+ <div>
272
+ <label for="editPhone" class="block text-sm font-medium text-gray-700 mb-1">Phone Number</label>
273
+ <input type="tel" id="editPhone" name="editPhone"
274
+ class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition">
275
+ </div>
276
+
277
+ <div>
278
+ <label for="editDepartment" class="block text-sm font-medium text-gray-700 mb-1">Department</label>
279
+ <select id="editDepartment" name="editDepartment"
280
+ class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition">
281
+ <option value="">Select Department</option>
282
+ <option value="Computer Science">Computer Science</option>
283
+ <option value="Electrical Engineering">Electrical Engineering</option>
284
+ <option value="Mechanical Engineering">Mechanical Engineering</option>
285
+ <option value="Business Administration">Business Administration</option>
286
+ <option value="Medicine">Medicine</option>
287
+ <option value="Law">Law</option>
288
+ </select>
289
+ </div>
290
+
291
+ <div>
292
+ <label for="editLevel" class="block text-sm font-medium text-gray-700 mb-1">Level</label>
293
+ <select id="editLevel" name="editLevel"
294
+ class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition">
295
+ <option value="">Select Level</option>
296
+ <option value="100">100 Level</option>
297
+ <option value="200">200 Level</option>
298
+ <option value="300">300 Level</option>
299
+ <option value="400">400 Level</option>
300
+ <option value="500">500 Level</option>
301
+ </select>
302
+ </div>
303
+
304
+ <div class="flex items-center">
305
+ <input type="checkbox" id="editActive" name="editActive" class="custom-checkbox">
306
+ <label for="editActive" class="ml-2 text-sm font-medium text-gray-700 cursor-pointer">Active Student</label>
307
+ </div>
308
+ </div>
309
+
310
+ <div class="mt-6 flex justify-end space-x-3">
311
+ <button type="button" id="cancelEdit" class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50 transition">
312
+ Cancel
313
+ </button>
314
+ <button type="submit" class="px-4 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 transition">
315
+ Save Changes
316
+ </button>
317
+ </div>
318
+ </form>
319
+ </div>
320
+ </div>
321
+ </div>
322
+
323
+ <script>
324
+ // Student data array
325
+ let students = JSON.parse(localStorage.getItem('students')) || [];
326
+ let currentPage = 1;
327
+ const recordsPerPage = 5;
328
+ let filteredStudents = [];
329
+
330
+ // DOM elements
331
+ const studentForm = document.getElementById('studentForm');
332
+ const studentTableBody = document.getElementById('studentTableBody');
333
+ const noRecords = document.getElementById('noRecords');
334
+ const alertDiv = document.getElementById('alert');
335
+ const searchInput = document.getElementById('searchInput');
336
+ const prevBtn = document.getElementById('prevBtn');
337
+ const nextBtn = document.getElementById('nextBtn');
338
+ const showingCount = document.getElementById('showingCount');
339
+ const totalCount = document.getElementById('totalCount');
340
+ const editModal = document.getElementById('editModal');
341
+ const editForm = document.getElementById('editForm');
342
+ const closeModal = document.getElementById('closeModal');
343
+ const cancelEdit = document.getElementById('cancelEdit');
344
+
345
+ // Initialize the app
346
+ document.addEventListener('DOMContentLoaded', () => {
347
+ renderStudentTable();
348
+ updatePagination();
349
+
350
+ // Form submission
351
+ studentForm.addEventListener('submit', handleFormSubmit);
352
+
353
+ // Search functionality
354
+ searchInput.addEventListener('input', handleSearch);
355
+
356
+ // Pagination buttons
357
+ prevBtn.addEventListener('click', () => {
358
+ if (currentPage > 1) {
359
+ currentPage--;
360
+ renderStudentTable();
361
+ updatePagination();
362
+ }
363
+ });
364
+
365
+ nextBtn.addEventListener('click', () => {
366
+ if (currentPage * recordsPerPage < filteredStudents.length) {
367
+ currentPage++;
368
+ renderStudentTable();
369
+ updatePagination();
370
+ }
371
+ });
372
+
373
+ // Modal events
374
+ closeModal.addEventListener('click', () => editModal.classList.add('hidden'));
375
+ cancelEdit.addEventListener('click', () => editModal.classList.add('hidden'));
376
+
377
+ // Click outside modal to close
378
+ editModal.addEventListener('click', (e) => {
379
+ if (e.target === editModal) {
380
+ editModal.classList.add('hidden');
381
+ }
382
+ });
383
+
384
+ // Edit form submission
385
+ editForm.addEventListener('submit', handleEditSubmit);
386
+ });
387
+
388
+ // Handle form submission
389
+ function handleFormSubmit(e) {
390
+ e.preventDefault();
391
+
392
+ const formData = new FormData(studentForm);
393
+ const student = {
394
+ id: Date.now().toString(),
395
+ fullName: formData.get('fullName'),
396
+ studentId: formData.get('studentId'),
397
+ email: formData.get('email'),
398
+ phone: formData.get('phone'),
399
+ department: formData.get('department'),
400
+ level: formData.get('level'),
401
+ active: studentForm.elements['active'].checked,
402
+ createdAt: new Date().toISOString()
403
+ };
404
+
405
+ students.unshift(student); // Add to beginning of array
406
+ saveStudents();
407
+ studentForm.reset();
408
+
409
+ showAlert('Student added successfully!', 'success');
410
+ currentPage = 1;
411
+ handleSearch();
412
+ }
413
+
414
+ // Handle edit form submission
415
+ function handleEditSubmit(e) {
416
+ e.preventDefault();
417
+
418
+ const id = document.getElementById('editId').value;
419
+ const studentIndex = students.findIndex(s => s.id === id);
420
+
421
+ if (studentIndex !== -1) {
422
+ students[studentIndex] = {
423
+ ...students[studentIndex],
424
+ fullName: document.getElementById('editFullName').value,
425
+ studentId: document.getElementById('editStudentId').value,
426
+ email: document.getElementById('editEmail').value,
427
+ phone: document.getElementById('editPhone').value,
428
+ department: document.getElementById('editDepartment').value,
429
+ level: document.getElementById('editLevel').value,
430
+ active: document.getElementById('editActive').checked
431
+ };
432
+
433
+ saveStudents();
434
+ editModal.classList.add('hidden');
435
+ showAlert('Student updated successfully!', 'success');
436
+ handleSearch();
437
+ }
438
+ }
439
+
440
+ // Save students to localStorage
441
+ function saveStudents() {
442
+ localStorage.setItem('students', JSON.stringify(students));
443
+ renderStudentTable();
444
+ updatePagination();
445
+ }
446
+
447
+ // Render student table
448
+ function renderStudentTable() {
449
+ const startIndex = (currentPage - 1) * recordsPerPage;
450
+ const endIndex = startIndex + recordsPerPage;
451
+ const paginatedStudents = filteredStudents.slice(startIndex, endIndex);
452
+
453
+ if (paginatedStudents.length === 0) {
454
+ studentTableBody.innerHTML = '';
455
+ noRecords.classList.remove('hidden');
456
+ return;
457
+ }
458
+
459
+ noRecords.classList.add('hidden');
460
+
461
+ studentTableBody.innerHTML = paginatedStudents.map(student => `
462
+ <tr class="hover:bg-gray-50">
463
+ <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${student.studentId}</td>
464
+ <td class="px-6 py-4 whitespace-nowrap">
465
+ <div class="flex items-center">
466
+ <div class="flex-shrink-0 h-10 w-10 bg-indigo-100 rounded-full flex items-center justify-center">
467
+ <i class="fas fa-user text-indigo-600"></i>
468
+ </div>
469
+ <div class="ml-4">
470
+ <div class="text-sm font-medium text-gray-900">${student.fullName}</div>
471
+ <div class="text-sm text-gray-500">${student.email}</div>
472
+ </div>
473
+ </div>
474
+ </td>
475
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${student.department}</td>
476
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${student.level}</td>
477
+ <td class="px-6 py-4 whitespace-nowrap">
478
+ <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${student.active ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800'}">
479
+ ${student.active ? 'Active' : 'Inactive'}
480
+ </span>
481
+ </td>
482
+ <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
483
+ <button onclick="editStudent('${student.id}')" class="text-indigo-600 hover:text-indigo-900 mr-3">
484
+ <i class="fas fa-edit"></i>
485
+ </button>
486
+ <button onclick="deleteStudent('${student.id}')" class="text-red-600 hover:text-red-900">
487
+ <i class="fas fa-trash-alt"></i>
488
+ </button>
489
+ </td>
490
+ </tr>
491
+ `).join('');
492
+ }
493
+
494
+ // Handle search
495
+ function handleSearch() {
496
+ const searchTerm = searchInput.value.toLowerCase();
497
+
498
+ if (searchTerm === '') {
499
+ filteredStudents = [...students];
500
+ } else {
501
+ filteredStudents = students.filter(student =>
502
+ student.fullName.toLowerCase().includes(searchTerm) ||
503
+ student.studentId.toLowerCase().includes(searchTerm) ||
504
+ student.email.toLowerCase().includes(searchTerm) ||
505
+ student.department.toLowerCase().includes(searchTerm)
506
+ );
507
+ }
508
+
509
+ currentPage = 1;
510
+ renderStudentTable();
511
+ updatePagination();
512
+ }
513
+
514
+ // Update pagination controls
515
+ function updatePagination() {
516
+ const totalPages = Math.ceil(filteredStudents.length / recordsPerPage);
517
+
518
+ showingCount.textContent = Math.min(filteredStudents.length, currentPage * recordsPerPage);
519
+ totalCount.textContent = filteredStudents.length;
520
+
521
+ prevBtn.disabled = currentPage === 1;
522
+ nextBtn.disabled = currentPage === totalPages || totalPages === 0;
523
+ }
524
+
525
+ // Show alert message
526
+ function showAlert(message, type) {
527
+ alertDiv.innerHTML = `
528
+ <div class="p-4 rounded-md ${type === 'success' ? 'bg-green-50 text-green-800' : 'bg-red-50 text-red-800'}">
529
+ <div class="flex items-center">
530
+ <div class="flex-shrink-0">
531
+ <i class="fas ${type === 'success' ? 'fa-check-circle' : 'fa-exclamation-circle'} ${type === 'success' ? 'text-green-400' : 'text-red-400'}"></i>
532
+ </div>
533
+ <div class="ml-3">
534
+ <p class="text-sm font-medium">${message}</p>
535
+ </div>
536
+ <div class="ml-auto pl-3">
537
+ <button onclick="this.parentElement.parentElement.parentElement.classList.add('hidden')" class="-mx-1.5 -my-1.5 rounded-md p-1.5 ${type === 'success' ? 'hover:bg-green-100 text-green-500' : 'hover:bg-red-100 text-red-500'} focus:outline-none focus:ring-2 focus:ring-offset-2 ${type === 'success' ? 'focus:ring-green-600 focus:ring-offset-green-50' : 'focus:ring-red-600 focus:ring-offset-red-50'}">
538
+ <i class="fas fa-times"></i>
539
+ </button>
540
+ </div>
541
+ </div>
542
+ </div>
543
+ `;
544
+ alertDiv.classList.remove('hidden');
545
+
546
+ setTimeout(() => {
547
+ alertDiv.classList.add('hidden');
548
+ }, 5000);
549
+ }
550
+
551
+ // Edit student
552
+ function editStudent(id) {
553
+ const student = students.find(s => s.id === id);
554
+
555
+ if (student) {
556
+ document.getElementById('editId').value = student.id;
557
+ document.getElementById('editFullName').value = student.fullName;
558
+ document.getElementById('editStudentId').value = student.studentId;
559
+ document.getElementById('editEmail').value = student.email;
560
+ document.getElementById('editPhone').value = student.phone;
561
+ document.getElementById('editDepartment').value = student.department;
562
+ document.getElementById('editLevel').value = student.level;
563
+ document.getElementById('editActive').checked = student.active;
564
+
565
+ editModal.classList.remove('hidden');
566
+ }
567
+ }
568
+
569
+ // Delete student
570
+ function deleteStudent(id) {
571
+ if (confirm('Are you sure you want to delete this student?')) {
572
+ students = students.filter(student => student.id !== id);
573
+ saveStudents();
574
+ showAlert('Student deleted successfully!', 'success');
575
+ handleSearch();
576
+ }
577
+ }
578
+ </script>
579
+ <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=Boody25/student-data" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
580
+ </html>