-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (32 loc) · 1.21 KB
/
index.js
File metadata and controls
38 lines (32 loc) · 1.21 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
/*
DO NOT EDIT THIS CODE!
This is helper code so that you can examine your site in a
new tab using Chrome Developer Tools. If you edit or remove
this code, you will not be able to do that. It is not part
of the project and you don't need to worry about how it works.
*/
if (localStorage.openedTab) {
// In case the browser or the tab crashes, this way the student will
// have to wait until the next day for localStorage to be cleared
var openedTab = JSON.parse(localStorage.getItem("openedTab"))
var now = new Date();
now.setHours(0);
now.setMinutes(0);
now.setSeconds(0);
now.setMilliseconds(0);
var then = new Date(openedTab.expiry);
if (now >= then) {
localStorage.removeItem("openedTab");
}
}
if (window.self != window.top && !localStorage.openedTab) {
var now = new Date();
var dts = now.getFullYear() + "/" + (now.getMonth() + 1) + "/" + (now.getDate() + 1);
openedTab = { opened: true, expiry: dts};
localStorage.setItem("openedTab", JSON.stringify(openedTab));
window.open(window.location.pathname,'_blank');
} else {
window.addEventListener("unload", function() {
localStorage.removeItem("openedTab");
});
}