-
Notifications
You must be signed in to change notification settings - Fork 5
/
blackout.js
69 lines (63 loc) · 2.75 KB
/
blackout.js
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
function include(filename, onload) { //thanks http://stackoverflow.com/a/8139909/7314005
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.src = filename;
script.type = 'text/javascript';
script.onload = script.onreadystatechange = function() {
if (script.readyState) {
if (script.readyState === 'complete' || script.readyState === 'loaded') {
script.onreadystatechange = null;
onload();
}
}
else {
onload();
}
};
head.appendChild(script);
}
function typeOf (obj) { //thanks http://stackoverflow.com/a/28475765/7314005
return {}.toString.call(obj).split(' ')[1].slice(0, -1).toLowerCase();
}
// PRODUCTION PATHS
var breakStuffPath = "https://rawgit.com/panxzz/NN-blackout/master/lib/break-stuff.js";
var displayModalPath = "https://rawgit.com/panxzz/NN-blackout/master/lib/modal-display.js";
// DEVELOPMENT PATHS
//breakStuffPath = "/lib/break-stuff.js";
//displayModalPath = "/lib/modal-display.js";
include("https://code.jquery.com/jquery-3.2.1.min.js", function(){
$(document).ready(function() {
//check the date/time to see if the blackout is currently going on
$.getScript("http://novanetllc.org/datetime.php", function(data, textStatus, jqxhr){
if(jqxhr.status == 200 && textStatus == "success")
{
//current blackout set to 2017-07-12 (month is zero based)
var serverTime = new Date(parseInt(data));
//if it is blackout time then "break" the page
if(serverTime.getFullYear() == 2017 && serverTime.getMonth() == 6 && serverTime.getDate() == 12)
{
$.getScript(breakStuffPath, function(data, textStatus, jqxhr){
if(jqxhr.status == 200 && textStatus == "success")
{
breakStuff();
}
//after 10 seconds or any click on the page pop the modal
window.setTimeout(popModal, 10000);
});
}
else
{
//console.log("don't blackout!");
}
}
var popModal = function(){
$.getScript(displayModalPath, function(data, textStatus, jqxhr){
if(jqxhr.status == 200 && textStatus == "success")
{
displayMessage(); //function from modal-display.js that displays a popup with the NN message
}
});
}
});
});
});