@@ -225,21 +225,6 @@ <h1>Messages</h1>
225
225
226
226
< h3 > Messages< span id ="alerts " class ="badge "> Loading...</ span > </ h3 >
227
227
228
- < h4 > Higher Priority Alerts</ h4 >
229
- < center > < h3 id ="HPA "> Loading...</ h3 > </ center >
230
-
231
- < h4 > Normal Priority Alerts</ h4 >
232
- < center > < h3 id ="NPA "> Loading...</ h3 > </ center >
233
-
234
- < h4 > Lower Priority Alerts</ h4 >
235
- < center > < h3 id ="LPA "> Loading...</ h3 > </ center >
236
-
237
- < h4 > Lowest Priority Alerts < span class ="badge "> 1 Alert</ span > </ h4 >
238
- < div class ="alert ">
239
- < span class ="closebtn " onclick ="this.parentElement.style.display='none'; "> ×</ span >
240
- Welcome to Coding Hut! Try signing in, making orders, becoming staff and more! We are glad you joined us.
241
- </ div >
242
-
243
228
< script >
244
229
function toggleMenu ( ) {
245
230
var menu = document . querySelector ( '.menu' ) ;
@@ -256,12 +241,33 @@ <h4>Lowest Priority Alerts <span class="badge">1 Alert</span></h4>
256
241
setTimeout ( function ( ) { x . className = x . className . replace ( "show" , "" ) ; } , 3000 ) ;
257
242
window . location . href = / m e s s a g e _ p e r s o n .h t m l ;
258
243
}
259
- const messagesHPA = localstorage . getItem ( 'HPA' ) ;
260
- document . getElemantById ( 'HPA' ) = messagesHPA ;
261
- const messagesNPA = localstorage . getItem ( 'NPA' ) ;
262
- document . getElemantById ( 'HPA' ) = messagesNPA ;
263
- const messagesLPA = localstorage . getItem ( 'LPA' ) ;
264
- document . getElemantById ( 'LPA' ) = messagesLPA ;
244
+ window . onload = function {
245
+ getMessagesForRecipient ( ) ;
246
+ } ;
247
+ window . onload = function ( ) {
248
+ const message = localStorage . getItem ( 'username' ) || 'No message found.' ;
249
+ document . getElementById ( 'getRecipient' ) . textContent = message ;
250
+ } ;
251
+
252
+ function getMessagesForRecipient ( ) {
253
+ const recipient = document . getElementById ( 'getRecipient' ) . value ;
254
+ const userMessages = JSON . parse ( localStorage . getItem ( recipient ) ) || [ ] ;
255
+ const messagesDisplay = document . getElementById ( 'messagesDisplay' ) ;
256
+
257
+ messagesDisplay . innerHTML = '' ;
258
+
259
+ if ( userMessages . length > 0 ) {
260
+ userMessages . forEach ( message => {
261
+ const listItem = document . createElement ( 'li' ) ;
262
+ listItem . textContent = message ;
263
+ messagesDisplay . appendChild ( listItem ) ;
264
+ } ) ;
265
+ } else {
266
+ const noMessagesItem = document . createElement ( 'li' ) ;
267
+ noMessagesItem . textContent = `No messages found for ${ recipient } .` ;
268
+ messagesDisplay . appendChild ( noMessagesItem ) ;
269
+ }
270
+ }
265
271
</ script >
266
272
</ body >
267
273
</ html >
0 commit comments