-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
207 lines (174 loc) · 5.94 KB
/
index.html
File metadata and controls
207 lines (174 loc) · 5.94 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="author" content="Yankuan Zhang">
<meta name="description" content="snap">
<title>Most Recent Guy Using My Mac</title>
<style>
* {
position: relative;
padding: 0;
margin: 0 auto 0 auto;
}
#body_div {
font-family: Helvetica;
background-color: #f6f3ef;
display: table;
position: absolute;
height: 100%;
width: 100%;
}
#container {
display: table-cell;
vertical-align: middle;
}
#main {
box-shadow: 0px 2px 8px rgba(0, 0, 0, .3);
margin-top: 42px;
/* border: solid 1px #e6e3df;*/
/* border-radius: 8px;*/
margin-left: auto;
margin-right: auto;
width: 800px;
background: white;
padding-bottom: 1px;
margin-bottom: 30px;
}
#header {
font-size: 26px;
font-weight: 300;
width: 800px;
height: 72px;
padding-top: 2px;
padding-bottom: 1px;
}
table {
width: 700px;
margin-top: 18px;
}
th {
font-weight: 100px;
color: #777;
text-align: left;
}
td {
color: #999;
text-align: right;
}
#image {
background-image: url(latest.jpg);
width: 800px;
height: 800px;
background-position: center;
/* Make the background image cover the area of the <div>, and clip the excess */
background-size: cover;
margin: 0 0 0 0;
}
#ack {
text-align: center;
font-size: 20px;
color: #aaa;
padding: 15px auto;
margin: 15px auto;
}
name {
font-weight: 300px;
color: #888;
}
</style>
<script>
function popFileSelect(evt) {
var file;
var lastModified = file.lastModifiedDate;
//Able to get the last modified date of file.
//Here i need to get the file actual creation time.
}
function getlastmod() {
var http = new XMLHttpRequest()
http.open('HEAD', "latest.jpg", false)
http.send()
if (http.status == 200) timestamp = http.getResponseHeader('Last-modified')
document.getElementById("timestamp").innerHTML = timestamp
// http.getResponseHeader('Last-modified')
}
function convertMillisecToProperUnitTime(difference_ms) {
var one_min = 1000 * 60;
var one_hour = one_min * 60;
var one_day = one_hour * 24;
var one_week = one_day * 7;
if (difference_ms > one_week) {
var count = difference_ms / one_week;
if (count < 2) return "1 week ago";
else return Math.floor(count) + " weeks ago";
} else
if (difference_ms > one_day) {
var count = difference_ms / one_day;
if (count < 2) return "1 day ago";
else return Math.floor(count) + " days ago";
} else
if (difference_ms > one_hour) {
var count = difference_ms / one_hour;
if (count < 2) return "1 hour ago";
else return Math.floor(count) + " hours ago";
} else
if (difference_ms > one_min) {
var count = difference_ms / one_min;
if (count < 2) return "1 min ago";
else return Math.floor(count) + " mins ago";
} else {
return "Less than a min ago";
}
}
function converTimestampToXTimeAgo(timestamp) {
// var rightNow = Date();
// xMinsAgo = rightNow - timestamp;
// console.log(xMinsAgo);
var now = new Date();
var img = new Date(timestamp)
// Convert both dates to milliseconds
var now_ms = now.getTime();
var img_ms = img.getTime();
// Calculate the difference in milliseconds
var difference_ms = now_ms - img_ms;
// Convert back to days and return
return convertMillisecToProperUnitTime(difference_ms);
}
function getTimestamp() {
var address = "latest.jpg";
var client = new XMLHttpRequest();
client.onload = function() {
// in case of network errors this might not give reliable results
// returnStatus(this.status);
}
client.open("HEAD", address, false);
client.send();
if (client.status == 200) timestamp = client.getResponseHeader('Last-modified');
document.getElementById("timestamp").innerHTML = converTimestampToXTimeAgo(timestamp);
}
</script>
</head>
<body id="body_div" onload="getTimestamp()">
<div id="container">
<div id="main">
<div id="header">
<table>
<tr>
<th>
<span>Most Recent Guy Using My Mac</span>
</th>
<td>
<span id="timestamp"></span>
</td>
</tr>
</table>
</div>
<div id="image"></div>
<div id="ack">Special thanks to
<name>Tongjia Shi</name> for this project</div>
</div>
</div>
</body>
</html>
<NOSCRIPT>
real-time udpate, timestamp, clarifi api?