-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathapp.js
More file actions
46 lines (41 loc) · 1.48 KB
/
Copy pathapp.js
File metadata and controls
46 lines (41 loc) · 1.48 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
'use strict';
window.onload = function() {
console.log(window.geemails);
let tbl = document.getElementById('tbl');
let email = 0;
window.geemails.forEach(function(msg) {
loadEmail(msg)
});
function loadEmail(msg) {
// show number of messages
email++;
document.getElementById('inbox').innerHTML = `Inbox ${email}`;
// create row and cell for the email
let rows = tbl.insertRow(1);
let senderCell = rows.insertCell(0);
senderCell.innerHTML = msg.sender;
let subjectCell = rows.insertCell(1);
subjectCell.innerHTML = msg.subject;
let dateCell = rows.insertCell(2);
dateCell.innerHTML = msg.date;
let body = msg.body;
// print-content and message
rows.onclick = function() {
document.getElementById('message-content').innerHTML = `<b>Date:</b> ${msg.date}<br><br><b>From:</b> ${msg.sender}<br><br><b>Subject:</b> ${msg.subject}<br><br>${body}</strong>`;
}
// hide/show messages
let hideStuff = document.querySelector('#message-content');
rows.addEventListener('click', function() {
if(hideStuff.style.display == 'block'){
hideStuff.style.display = 'none'
}else{
hideStuff.style.display = 'block'
}
}
);
};
// render new random message
setInterval(function() {
loadEmail(getNewMessage());
}, 10000);
};