-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.html
More file actions
328 lines (282 loc) · 11.2 KB
/
admin.html
File metadata and controls
328 lines (282 loc) · 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>QUAF-SD</title>
<style>
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
overflow-x: hidden;
background: linear-gradient(135deg, #1e3c72, #2a5298);
height: 100vh;
color: white;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
}
.navbar {
display: flex;
justify-content: space-around;
align-items: center;
padding: 20px;
background-color: rgba(255, 255, 255, 0.1);
z-index: 3;
position: fixed;
width: 100%;
top: 0;
backdrop-filter: blur(10px);
}
.navbar a {
color: white;
text-decoration: none;
padding: 10px 20px;
border-radius: 30px;
transition: background-color 0.3s, transform 0.3s;
}
.navbar a:hover {
background-color: rgba(255, 255, 255, 0.3);
transform: translateY(-2px);
}
.container {
z-index: 2;
text-align: center;
padding: 80px 20px;
margin-top: 60px;
}
h1 {
margin: 20px 0;
}
input[type="text"],
input[type="password"],
input[type="url"] {
padding: 15px;
width: 300px;
border: none;
border-radius: 30px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
font-size: 16px;
outline: none;
transition: 0.3s;
background-color: rgba(255, 255, 255, 0.1);
color: white;
margin-bottom: 15px;
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="url"]:focus {
width: 320px;
}
button {
padding: 15px 30px;
border: none;
border-radius: 30px;
background-color: #ff0055;
color: white;
font-size: 16px;
cursor: pointer;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
transition: background-color 0.3s, transform 0.3s;
margin-top: 10px;
}
button:hover {
background-color: #e6004d;
transform: translateY(-2px);
}
.error-message {
color: red;
margin-top: 10px;
}
.form-section {
display: none;
margin-top: 20px;
}
#results {
display: flex;
flex-wrap: wrap;
justify-content: center;
width: 100%;
margin-top: 20px;
}
.result-item {
background: rgba(255, 255, 255, 0.2);
border-radius: 15px;
padding: 20px;
margin: 15px;
width: 300px;
box-shadow: 0 0 20px rgba(0, 123, 255, 0.7);
transition: transform 0.3s, box-shadow 0.3s;
position: relative;
}
.result-item img {
width: 120px;
height: 120px;
border-radius: 50%;
border: 3px solid #007bff;
margin-bottom: 10px;
}
.download-icon {
margin-top: 10px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="navbar">
<a href="javascript:void(0);" id="homeLink">Home</a>
<a href="javascript:void(0);" id="adminLink">Admin</a>
</div>
<div class="container" id="studentSection">
<h1>Student Search</h1>
<input type="text" id="searchBox" placeholder="Enter student name...">
<button id="searchButton">Search</button>
<div id="results"></div>
</div>
<div class="container" id="adminSection" style="display: none;">
<h1 id="adminHeader">Admin Sign In</h1>
<div id="signInSection">
<input type="text" id="username" placeholder="Username">
<input type="password" id="password" placeholder="Password">
<button id="signInButton">Sign In</button>
<span id="error" class="error-message"></span>
</div>
<div id="formSection" class="form-section">
<h2>Add Student</h2>
<input type="url" id="photo" placeholder="Enter photo URL" required>
<input type="text" id="studentName" placeholder="Student Name" required>
<input type="text" id="studentDetails" placeholder="Student Details" required>
<button id="submitButton">Submit</button>
</div>
</div>
<script>
// Store students in an array or retrieve them from localStorage
let students = JSON.parse(localStorage.getItem('students')) || [];
// Function to display students
function displayStudents() {
const resultsDiv = document.getElementById('results');
resultsDiv.innerHTML = ''; // Clear previous results
if (students.length > 0) {
students.forEach(student => {
const div = document.createElement('div');
div.className = 'result-item';
div.innerHTML = `
<img src="${student.photo}" alt="${student.name}">
<div class="result-name">${student.name}</div>
<div class="result-details">${student.details}</div>
<button class="download-button" onclick="downloadCard('${student.photo}', '${student.name}', '${student.details}')">DOWNLOAD</button>
`;
resultsDiv.appendChild(div);
});
} else {
resultsDiv.innerHTML = 'No students found.';
}
}
// Call displayStudents on page load
window.onload = displayStudents;
// Function to switch sections
function showSection(sectionId) {
document.getElementById('studentSection').style.display = sectionId === 'studentSection' ? 'block' : 'none';
document.getElementById('adminSection').style.display = sectionId === 'adminSection' ? 'block' : 'none';
}
// Show student section by default
showSection('studentSection');
// Navigation buttons
document.getElementById('homeLink').addEventListener('click', () => {
showSection('studentSection');
});
document.getElementById('adminLink').addEventListener('click', () => {
showSection('adminSection');
});
// Sign-in logic
document.getElementById('signInButton').addEventListener('click', () => {
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
const error = document.getElementById('error');
// Check credentials
if (username === 'quaf-dhdc' && password === 'quafdhdc@2024') {
error.textContent = '';
document.getElementById('adminHeader').style.display = 'none';
document.getElementById('signInSection').style.display = 'none';
document.getElementById('formSection').style.display = 'block';
} else {
error.textContent = 'Rejected';
}
});
// Handle form submission with localStorage
document.getElementById('submitButton').addEventListener('click', () => {
const photo = document.getElementById('photo').value;
const name = document.getElementById('studentName').value;
const details = document.getElementById('studentDetails').value;
// Save student data to the array
students.push({ photo, name, details });
// Save to localStorage
localStorage.setItem('students', JSON.stringify(students));
// Clear the input fields
document.getElementById('photo').value = '';
document.getElementById('studentName').value = '';
document.getElementById('studentDetails').value = '';
// Display updated students
displayStudents();
alert('Student added successfully!');
});
// Search button event listener
document.getElementById('searchButton').addEventListener('click', () => {
const query = document.getElementById('searchBox').value.trim().toLowerCase();
const resultsDiv = document.getElementById('results');
resultsDiv.innerHTML = '';
// Filter students based on search input
const result = students.filter(student => student.name.toLowerCase() === query);
// Display results
if (result.length > 0) {
result.forEach(student => {
const div = document.createElement('div');
div.className = 'result-item';
div.innerHTML = `
<img src="${student.photo}" alt="${student.name}">
<div class="result-name">${student.name}</div>
<div class="result-details">${student.details}</div>
<button class="download-button" onclick="downloadCard('${student.photo}', '${student.name}', '${student.details}')">DOWNLOAD</button>
`;
resultsDiv.appendChild(div);
});
} else {
resultsDiv.innerHTML = 'No results matched.';
}
});
// Function to download the student card as an image
function downloadCard(photo, name, details) {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.width = 400; // Card width
canvas.height = 300; // Card height
// Draw the card background
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = '#007bff'; // Blue border
ctx.strokeRect(2, 2, canvas.width - 4, canvas.height - 4); // Border rectangle
// Draw the image
const img = new Image();
img.src = photo;
img.onload = () => {
ctx.drawImage(img, 20, 20, 120, 120); // Image position and sizing
// Set the font for name and details
ctx.fillStyle = 'black';
ctx.font = '20px Segoe UI';
ctx.fillText(name, 160, 70); // Name position
ctx.font = '16px Segoe UI';
ctx.fillText(details, 160, 110); // Details position
// Create a download link
const link = document.createElement('a');
link.href = canvas.toDataURL('image/png');
link.download = `${name}.png`; // Set filename as name.png
link.click(); // Trigger download
};
}
</script>
</body>
</html>