-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin-notices.html
227 lines (200 loc) · 6.27 KB
/
admin-notices.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Notice Board - Admin Portal</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<link rel="shortcut icon" href="logo.png" type="image/x-icon" />
<link rel="stylesheet" href="styles.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" />
<style>
.container {
display: grid;
grid-template-columns: 1fr 400px;
height: 100vh;
overflow: hidden;
}
.notice-list {
background: rgba(0, 0, 0, 0.2);
padding: 1rem;
overflow-y: auto;
}
.notice-form {
padding: 2rem;
background: rgba(0, 0, 0, 0.1);
}
.notice-item {
background: rgba(255, 255, 255, 0.05);
padding: 1rem;
border-radius: 8px;
margin-bottom: 1rem;
}
.notice-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.5rem;
}
.notice-targets {
display: flex;
gap: 0.5rem;
}
.notice-target {
background: rgba(255, 255, 255, 0.1);
padding: 0.2rem 0.5rem;
border-radius: 4px;
font-size: 0.8rem;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 2rem;
padding: 1rem;
background: rgba(0, 0, 0, 0.2);
}
.back-btn {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.5rem 1rem;
background: rgba(255, 51, 102, 0.9);
border-radius: 8px;
border: none;
color: white;
cursor: pointer;
transition: all 0.3s ease;
}
.back-btn:hover {
background: #ff4477;
transform: translateY(-2px);
}
textarea {
width: 100%;
min-height: 150px;
padding: 0.5rem;
border-radius: 4px;
border: 1px solid rgba(255, 255, 255, 0.2);
background: rgba(0, 0, 0, 0.2);
color: white;
margin-bottom: 1rem;
}
.target-options {
display: grid;
gap: 0.5rem;
margin-bottom: 1rem;
}
.submit-btn {
width: 100%;
padding: 0.8rem;
background: #33cc33;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
transition: all 0.3s ease;
}
.submit-btn:hover {
background: #2eb82e;
}
.delete-btn {
padding: 0.3rem 0.6rem;
background: #ff3366;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
.delete-btn:hover {
background: #ff1a1a;
}
</style>
</head>
<body>
<div class="header">
<h1>Notice Board Management</h1>
<button onclick="window.location.href='admin.html'" class="back-btn">
<i class="fas fa-arrow-left"></i>
Back to Dashboard
</button>
</div>
<div class="container">
<div class="notice-list">
<div id="notices"></div>
</div>
<div class="notice-form">
<h2>Create Notice</h2>
<form onsubmit="return addNotice(event)">
<textarea id="noticeText" placeholder="Enter notice text..." required></textarea>
<div class="target-options">
<label>
<input type="checkbox" id="facultyTarget"> Faculty
</label>
<label>
<input type="checkbox" id="studentTarget"> Students
</label>
<label>
<input type="checkbox" id="visitorTarget"> Visitors
</label>
</div>
<button type="submit" class="submit-btn">Post Notice</button>
</form>
</div>
</div>
<script>
function displayNotices() {
const database = JSON.parse(localStorage.getItem('database'));
const noticesDiv = document.getElementById('notices');
noticesDiv.innerHTML = database.notices.length > 0
? database.notices.map((notice, index) => `
<div class="notice-item">
<div class="notice-header">
<div class="notice-targets">
${notice.targets.map(t => `
<span class="notice-target">${t}</span>
`).join('')}
</div>
<button onclick="removeNotice(${index})" class="delete-btn">
<i class="fas fa-trash"></i>
</button>
</div>
<p>${notice.text}</p>
</div>
`).join('')
: '<p>No notices posted</p>';
}
function addNotice(event) {
event.preventDefault();
const text = document.getElementById('noticeText').value;
const facultyTarget = document.getElementById('facultyTarget').checked;
const studentTarget = document.getElementById('studentTarget').checked;
const visitorTarget = document.getElementById('visitorTarget').checked;
if (!facultyTarget && !studentTarget && !visitorTarget) {
alert('Please select at least one target audience');
return false;
}
const targets = [];
if (facultyTarget) targets.push('Faculty');
if (studentTarget) targets.push('Students');
if (visitorTarget) targets.push('Visitors');
const database = JSON.parse(localStorage.getItem('database'));
database.notices.push({ text, targets });
localStorage.setItem('database', JSON.stringify(database));
document.getElementById('noticeText').value = '';
document.getElementById('facultyTarget').checked = false;
document.getElementById('studentTarget').checked = false;
document.getElementById('visitorTarget').checked = false;
displayNotices();
return false;
}
function removeNotice(index) {
const database = JSON.parse(localStorage.getItem('database'));
database.notices.splice(index, 1);
localStorage.setItem('database', JSON.stringify(database));
displayNotices();
}
// Initialize
displayNotices();
</script>
</body>
</html>