JAYASWAROOP commited on
Commit
e38e840
·
verified ·
1 Parent(s): c485f2a

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +153 -18
index.html CHANGED
@@ -1,19 +1,154 @@
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>Attendance Tracking System</title>
7
+ <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
8
+ <link rel="stylesheet" href="style.css">
9
+ </head>
10
+ <body>
11
+ <div class="container mt-5">
12
+ <h1 class="text-center">Attendance Tracking System</h1>
13
+
14
+ <div id="studentSection">
15
+ <h2>Student Login</h2>
16
+ <form id="studentForm" class="mb-4">
17
+ <div class="form-group">
18
+ <label for="studentId">Student ID</label>
19
+ <input type="text" class="form-control" id="studentId" required>
20
+ </div>
21
+ <div class="form-group">
22
+ <label for="studentName">Student Name</label>
23
+ <input type="text" class="form-control" id="studentName" required>
24
+ </div>
25
+ <button type="submit" class="btn btn-primary">Submit Attendance</button>
26
+ </form>
27
+ </div>
28
+
29
+ <div id="teacherSection" class="mt-5">
30
+ <h2>Teacher/Admin Login</h2>
31
+ <form id="teacherForm" class="mb-4">
32
+ <div class="form-group">
33
+ <label for="teacherUsername">Username</label>
34
+ <input type="text" class="form-control" id="teacherUsername" required>
35
+ </div>
36
+ <div class="form-group">
37
+ <label for="teacherPassword">Password</label>
38
+ <input type="password" class="form-control" id="teacherPassword" required>
39
+ </div>
40
+ <button type="submit" class="btn btn-primary">View Attendance Report</button>
41
+ </form>
42
+ </div>
43
+
44
+ <div id="attendanceReport" class="mt-5" style="display: none;">
45
+ <h2>Attendance Report</h2>
46
+ <table class="table table-bordered">
47
+ <thead>
48
+ <tr>
49
+ <th>#</th>
50
+ <th>Student ID</th>
51
+ <th>Student Name</th>
52
+ <th>Date</th>
53
+ <th>Time</th>
54
+ </tr>
55
+ </thead>
56
+ <tbody id="attendanceTableBody">
57
+ <!-- Attendance records will be added here -->
58
+ </tbody>
59
+ </table>
60
+ </div>
61
+ </div>
62
+ <script src="script.js"></script>
63
+ <script>
64
+ document.getElementById('studentForm').addEventListener('submit', function(event) {
65
+ event.preventDefault();
66
+
67
+ const studentId = document.getElementById('studentId').value;
68
+ const studentName = document.getElementById('studentName').value;
69
+ const date = new Date().toLocaleDateString();
70
+ const time = new Date().toLocaleTimeString();
71
+
72
+ addAttendanceRecord(studentId, studentName, date, time);
73
+ document.getElementById('studentId').value = '';
74
+ document.getElementById('studentName').value = '';
75
+ });
76
+
77
+ document.getElementById('teacherForm').addEventListener('submit', function(event) {
78
+ event.preventDefault();
79
+
80
+ const username = document.getElementById('teacherUsername').value;
81
+ const password = document.getElementById('teacherPassword').value;
82
+
83
+ if (authenticateTeacher(username, password)) {
84
+ document.getElementById('attendanceReport').style.display = 'block';
85
+ } else {
86
+ alert('Invalid username or password.');
87
+ }
88
+ });
89
+
90
+ function addAttendanceRecord(studentId, studentName, date, time) {
91
+ const tableBody = document.getElementById('attendanceTableBody');
92
+ const rowCount = tableBody.rows.length;
93
+ const row = tableBody.insertRow(rowCount);
94
+
95
+ const cell1 = row.insertCell(0);
96
+ const cell2 = row.insertCell(1);
97
+ const cell3 = row.insertCell(2);
98
+ const cell4 = row.insertCell(3);
99
+ const cell5 = row.insertCell(4);
100
+
101
+ cell1.innerHTML = rowCount + 1;
102
+ cell2.innerHTML = studentId;
103
+ cell3.innerHTML = studentName;
104
+ cell4.innerHTML = date;
105
+ cell5.innerHTML = time;
106
+
107
+ saveAttendanceData();
108
+ }
109
+
110
+ function authenticateTeacher(username, password) {
111
+ // Simple authentication logic (replace with actual authentication logic)
112
+ return username === 'admin' && password === 'password';
113
+ }
114
+
115
+ function saveAttendanceData() {
116
+ const tableBody = document.getElementById('attendanceTableBody');
117
+ const rows = Array.from(tableBody.rows);
118
+ const attendanceData = rows.map(row => {
119
+ return {
120
+ id: row.cells[1].innerText,
121
+ name: row.cells[2].innerText,
122
+ date: row.cells[3].innerText,
123
+ time: row.cells[4].innerText
124
+ };
125
+ });
126
+ localStorage.setItem('attendanceData', JSON.stringify(attendanceData));
127
+ }
128
+
129
+ function loadAttendanceData() {
130
+ const attendanceData = JSON.parse(localStorage.getItem('attendanceData')) || [];
131
+ const tableBody = document.getElementById('attendanceTableBody');
132
+ attendanceData.forEach((record, index) => {
133
+ const row = tableBody.insertRow(index);
134
+
135
+ const cell1 = row.insertCell(0);
136
+ const cell2 = row.insertCell(1);
137
+ const cell3 = row.insertCell(2);
138
+ const cell4 = row.insertCell(3);
139
+ const cell5 = row.insertCell(4);
140
+
141
+ cell1.innerHTML = index + 1;
142
+ cell2.innerHTML = record.id;
143
+ cell3.innerHTML = record.name;
144
+ cell4.innerHTML = record.date;
145
+ cell5.innerHTML = record.time;
146
+ });
147
+ }
148
+
149
+ // Load attendance data on page load
150
+ window.onload = loadAttendanceData;
151
+
152
+ </script>
153
+ </body>
154
  </html>