forked from devleague/gee-mail
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
75 lines (69 loc) · 2.34 KB
/
index.html
File metadata and controls
75 lines (69 loc) · 2.34 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
<html>
<head>
<script src="js/mail-generator.js"></script>
<link href="css/style.css" rel="stylesheet" media="screen">
<script>
window.onload = function(){
// ALL OF YOUR JAVASCRIPT CODE SHOULD GO HERE.
// We have to use window.onload so your JavaScript doesn't execute until the page has loaded and all HTML has been downloaded to your browser
function buildInbox() {
var table = document.getElementById("inbox");
for (var i = 0; i < window.geemails.length; i ++) {
var row = table.insertRow(i + 1);
var date = row.insertCell(0);
var sender = row.insertCell(1);
var subject = row.insertCell(2);
date.innerHTML = window.geemails[i].date;
sender.innerHTML = window.geemails[i].sender;
subject.innerHTML = window.geemails[i].subject;
var body = window.geemails[i].body;
console.log(body);
row.onclick = function() {
alert(window.geemails[Math.floor(Math.random() * window.geemails.length)].body);
};
}
}
function myTimer() {
var message = getNewMessage();
window.geemails.push(message);
totalMessages ++;
document.getElementById("messageCount").innerHTML = "Inbox (" + totalMessages + ")";
addToInbox(message);
}
function addToInbox(message) {
var table = document.getElementById("inbox");
var row = table.insertRow(table.length);
var date = row.insertCell(0);
var sender = row.insertCell(1);
var subject = row.insertCell(2);
date.innerHTML = message.date;
sender.innerHTML = message.sender;
subject.innerHTML = message.subject;
var body = message.body;
row.onclick = function() {
alert(body);
}
}
buildInbox();
var totalMessages = window.geemails.length;
document.getElementById("messageCount").innerHTML = "Inbox (" + totalMessages + ")";
var interval = setInterval(myTimer, 5000);
};
</script>
</head>
<body>
<header>
<h1>Gee-mail</h1>
<h2 id="messageCount"></h2>
</header>
<div class="container" id="main">
<table id="inbox">
<tr>
<th>Date</th>
<th>Sender</th>
<th>Subject</th>
</tr>
</table>
</div>
</body>
</html>