-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdinosoft-student-data-maker.html
385 lines (352 loc) · 18.7 KB
/
dinosoft-student-data-maker.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="icon" type="image/x-icon" href="DINOSOFT-LOGO.jpg">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Data Maker | Dinosoft</title>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-sm-12">
<!-- Student Information Section -->
<h3 class="card-header bg-dark text-white mt-4">Enter Student(s) Information</h3>
<form id="studentForm">
<br>
<br>
<!-- Student Number Field -->
<div class="form-group">
<label for="studentNum">Student Number</label>
<input type="text" name="num" id="studentNum" placeholder="0000-" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm" pattern="[0-9]*">
</div>
<!-- Other Student Information Fields -->
<div class="form-group">
<label for="fName">First Name</label>
<input type="text" name="firstName" class="form-control" id="fName" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm">
</div>
<div class="form-group">
<label for="lName">Last Name</label>
<input type="text" name="lastName" class="form-control" id="lName" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm">
</div>
<!-- Gender Selection -->
<div class="form-group mt-4">
<label for="gender">Gender</label>
<select class="form-control" id="gender" onchange="changeProfileImage()">
<option value="male">Male</option>
<option value="female">Female</option>
<option value="other">Other</option>
</select>
</div>
<div class="form-group">
<label for="grade">Grade</label>
<select class="form-control" id="grade">
<option value="epk">EPK</option>
<option value="kindergarten">Kindergarten</option>
<option value="grade1">Grade 1</option>
<option value="grade2">Grade 2</option>
<option value="grade3">Grade 3</option>
<option value="grade4">Grade 4</option>
<option value="grade5">Grade 5</option>
<option value="grade6">Grade 6</option>
<option value="grade7">Grade 7</option>
<option value="grade8">Grade 8</option>
<option value="grade9">Grade 9</option>
<option value="grade10">Grade 10</option>
<option value="grade11">Grade 11</option>
<option value="grade12">Grade 12</option>
</select>
</div>
<div class="form-group">
<label for="sID">Student ID</label>
<input type="text" name="idstudent" class="form-control" maxlength="12" id="sID" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm">
</div>
<div class="form-group">
<label for="comments">Comments</label>
<textarea class="form-control" id="comments" rows="3"></textarea>
</div>
<button type="submit" class="btn btn-primary">Add Student</button>
<button type="button" class="btn btn-secondary" id="saveData" disabled>Save</button> <!-- Added Save button -->
</form>
</div>
</div>
<div class="row mt-4">
<div class="col-sm-12">
<div class="card">
<h5 class="card-header bg-dark text-white">Student Datas</h5>
<table class="table table-hover table-dark studentData">
<thead>
<tr>
<th scope="col">Profile</th>
<th scope="col">Student #</th>
<th scope="col">First Name</th>
<th scope="col">Last Name</th>
<th scope="col">Grade</th>
<th scope="col">Student ID</th>
<th scope="col">Comments</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<!-- Table body will be dynamically updated with user input -->
</tbody>
</table>
</div>
</div>
</div>
<div class="row mt-4">
<div class="col-sm-12">
<center>
<button class="btn btn-primary" id="sendEmail">Compose an Email</button>
</center>
<br>
<br>
</div>
</div>
</div>
<!-- Bootstrap JS and jQuery -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<!-- Modal for editing student information -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="editModalLabel">Edit Student Information</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="editForm">
<div class="form-group">
<label for="editStudentNum">Student Number</label>
<input type="text" name="num" id="editStudentNum" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm" pattern="[0-9]*">
</div>
<div class="form-group">
<label for="editFName">First Name</label>
<input type="text" name="firstName" class="form-control" id="editFName" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm">
</div>
<div class="form-group">
<label for="editLName">Last Name</label>
<input type="text" name="lastName" class="form-control" id="editLName" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm">
</div>
<div class="form-group mt-4">
<label for="editGender">Gender</label>
<select class="form-control" id="editGender">
<option value="male">Male</option>
<option value="female">Female</option>
<option value="other">Other</option>
</select>
</div>
<div class="form-group">
<label for="editGrade">Grade</label>
<select class="form-control" id="editGrade">
<option value="epk">EPK</option>
<option value="kindergarten">Kindergarten</option>
<option value="grade1">Grade 1</option>
<option value="grade2">Grade 2</option>
<option value="grade3">Grade 3</option>
<option value="grade4">Grade 4</option>
<option value="grade5">Grade 5</option>
<option value="grade6">Grade 6</option>
<option value="grade7">Grade 7</option>
<option value="grade8">Grade 8</option>
<option value="grade9">Grade 9</option>
<option value="grade10">Grade 10</option>
<option value="grade11">Grade 11</option>
<option value="grade12">Grade 12</option>
</select>
</div>
<div class="form-group">
<label for="editSID">Student ID</label>
<input type="text" name="idstudent" class="form-control" maxlength="12" id="editSID" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm">
</div>
<div class="form-group">
<label for="editComments">Comments</label>
<textarea class="form-control" id="editComments" rows="3"></textarea>
</div>
<input type="hidden" id="editRowIndex">
<button type="submit" class="btn btn-primary">Save Changes</button>
</form>
</div>
</div>
</div>
</div>
<script>
// Function to change profile image based on selected gender
function changeProfileImage() {
var selectedGender = document.getElementById("gender").value;
var profileImage = document.getElementById("profileImage");
if (selectedGender === "male") {
profileImage.src = "https://i.ibb.co/CKNsK0C/OIP-34-removebg-preview.png";
} else if (selectedGender === "female") {
profileImage.src = "https://i.ibb.co/KWmBX8T/OIP-35-removebg-preview.png";
} else {
profileImage.src = "https://i.ibb.co/k5Kxxk6/cropped-OIP-36.jpg";
}
}
$(document).ready(function() {
// Function to update table with user input
function updateTable() {
var studentNum = $("#studentNum").val();
var firstName = $("#fName").val();
var lastName = $("#lName").val();
var grade = $("#grade").val();
var studentID = $("#sID").val();
var comments = $("#comments").val();
var gender = $("#gender").val();
var profileImageURL = '';
if (gender === "male") {
profileImageURL = "https://i.ibb.co/CKNsK0C/OIP-34-removebg-preview.png";
} else if (gender === "female") {
profileImageURL = "https://i.ibb.co/KWmBX8T/OIP-35-removebg-preview.png";
} else {
profileImageURL = "https://i.ibb.co/4FSYxVX/cropped-OIP-36-modified.png";
}
// Append a new row to the table body
$(".studentData tbody").append(`
<tr>
<td><img src="${profileImageURL}" alt="Profile Image" width="30" height="30"></td>
<td>${studentNum}</td>
<td>${firstName}</td>
<td>${lastName}</td>
<td>${grade}</td>
<td>${studentID}</td>
<td>${comments}</td>
<td>
<button class="btn btn-danger btn-sm delete-row">Delete</button>
<button class="btn btn-primary btn-sm edit-row">Edit</button>
</td>
</tr>
`);
// Clear input fields after updating table
$("#studentNum").val("");
$("#fName").val("");
$("#lName").val("");
$("#grade").val("epk");
$("#sID").val("");
$("#comments").val("");
// Enable the save button
$("#saveData").prop("disabled", false);
}
// Event listener for form submission
$("#studentForm").submit(function(event) {
event.preventDefault();
updateTable();
});
// Event listener for delete button click
$(".studentData").on("click", ".delete-row", function() {
$(this).closest("tr").remove();
updateLocalStorage(); // Update local storage after deletion
});
// Event listener for edit button click
$(".studentData").on("click", ".edit-row", function() {
var row = $(this).closest("tr");
var rowIndex = row.index();
var studentNum = row.find("td:eq(1)").text();
var firstName = row.find("td:eq(2)").text();
var lastName = row.find("td:eq(3)").text();
var grade = row.find("td:eq(4)").text();
var studentID = row.find("td:eq(5)").text();
var comments = row.find("td:eq(6)").text();
var gender = row.find("td:eq(7)").text().trim();
var profileImageURL = row.find("td:eq(0) img").attr("src");
// Populate the modal with existing data
$("#editStudentNum").val(studentNum);
$("#editFName").val(firstName);
$("#editLName").val(lastName);
$("#editGrade").val(grade);
$("#editSID").val(studentID);
$("#editComments").val(comments);
$("#editGender").val(gender);
$("#editProfileImage").val(profileImageURL);
// Store the row index in a hidden field for later use
$("#editRowIndex").val(rowIndex);
// Show the modal
$("#editModal").modal("show");
});
// Event listener for form submission in edit modal
$("#editForm").submit(function(event) {
event.preventDefault();
var rowIndex = $("#editRowIndex").val();
var studentNum = $("#editStudentNum").val();
var firstName = $("#editFName").val();
var lastName = $("#editLName").val();
var grade = $("#editGrade").val();
var studentID = $("#editSID").val();
var comments = $("#editComments").val();
var gender = $("#editGender").val();
var profileImageURL = $("#editProfileImage").val();
// Update the corresponding row in the table
$(".studentData tbody tr").eq(rowIndex).find("td:eq(0) img").attr("src", profileImageURL);
$(".studentData tbody tr").eq(rowIndex).find("td:eq(1)").text(studentNum);
$(".studentData tbody tr").eq(rowIndex).find("td:eq(2)").text(firstName);
$(".studentData tbody tr").eq(rowIndex).find("td:eq(3)").text(lastName);
$(".studentData tbody tr").eq(rowIndex).find("td:eq(4)").text(grade);
$(".studentData tbody tr").eq(rowIndex).find("td:eq(5)").text(studentID);
$(".studentData tbody tr").eq(rowIndex).find("td:eq(6)").text(comments);
$(".studentData tbody tr").eq(rowIndex).find("td:eq(7)").text(gender);
// Hide the modal
$("#editModal").modal("hide");
// Update local storage
updateLocalStorage();
});
// Function to update local storage
function updateLocalStorage() {
// Get all student data from table and update local storage
var studentData = [];
$(".studentData tbody tr").each(function() {
var rowData = {
"profileImageURL": $(this).find("td:eq(0) img").attr("src"),
"studentNum": $(this).find("td:eq(1)").text(),
"firstName": $(this).find("td:eq(2)").text(),
"lastName": $(this).find("td:eq(3)").text(),
"grade": $(this).find("td:eq(4)").text(),
"studentID": $(this).find("td:eq(5)").text(),
"comments": $(this).find("td:eq(6)").text(),
"gender": $(this).find("td:eq(7)").text().trim()
};
studentData.push(rowData);
});
localStorage.setItem("studentData", JSON.stringify(studentData));
}
// Check if there is any existing data in local storage
var storedData = localStorage.getItem("studentData");
if (storedData) {
var parsedData = JSON.parse(storedData);
parsedData.forEach(function(rowData) {
$(".studentData tbody").append(`
<tr>
<td><img src="${rowData.profileImageURL}" alt="Profile Image" width="30" height="30"></td>
<td>${rowData.studentNum}</td>
<td>${rowData.firstName}</td>
<td>${rowData.lastName}</td>
<td>${rowData.grade}</td>
<td>${rowData.studentID}</td>
<td>${rowData.comments}</td>
<td>
<button class="btn btn-danger btn-sm delete-row">Delete</button>
<button class="btn btn-primary btn-sm edit-row">Edit</button>
</td>
</tr>
`);
});
}
// Event listener for save button click to update local storage
$("#saveData").click(function() {
updateLocalStorage();
$(this).prop("disabled", true); // Disable the button after saving
});
// Event listener for send email button click
$("#sendEmail").click(function() {
var mailtoLink = "https://mail.google.com/";
window.open(mailtoLink, '_blank');
});
});
</script>
</body>
</html>