-
Notifications
You must be signed in to change notification settings - Fork 1
/
rotation.js
executable file
·131 lines (121 loc) · 4.85 KB
/
rotation.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
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
$(document).ready(function(){
$('.rotation-group').slick({
infinite: true,
slidesToShow: 1,
autoplay: true,
autoplaySpeed: 5000,
speed: 0,
adaptiveHeight: true,
pauseOnHover: false,
useTransform: false,
});
$('.rotation-group').slick('slickFilter', '.rotation-include');
// Rotate between elements with class 'rotation-include'
});
var displayAlertsMinor = true;
var displayAlertsSevere = true;
var stylesheet = document.styleSheets[4]
var rotationUpdate = function rotationUpdate() {
var currentTime = new Date();
// FUTURE: Replace with config.js variables
weekdayPredict = currentTime.getHours() >= 0 && currentTime.getHours() < 24 && currentTime.getDay() > 0 && currentTime.getDay() <= 6
sundayPredict = currentTime.getHours() >= 8 && currentTime.getHours() < 24 && (currentTime.getDay() == 0 || currentTime.getDay() == 7)
weekdayHideMessage = currentTime.getHours() >= 9 && currentTime.getHours() < 10 && currentTime.getDay() > 0 && currentTime.getDay() < 6
displayAlertsMinor = currentTime.getHours() >= 5 && currentTime.getHours() < 20
overnightMode = currentTime.getHours() == 23 || currentTime.getHours() <= 6
if (overnightMode == false) {
stylesheet.deleteRule(2)
stylesheet.deleteRule(1)
stylesheet.insertRule('.normal-colors {color: black; background-color: white; border-color: black;}', 1);
stylesheet.insertRule('.inverse-colors {color: white; background-color: black; border-color: white;}', 2);
} else {
stylesheet.deleteRule(2)
stylesheet.deleteRule(1)
stylesheet.insertRule('.normal-colors {color: white; background-color: black; border-color: white;}', 1);
stylesheet.insertRule('.inverse-colors {color: black; background-color: white; border-color: black;}', 2);
}
var transitPredictionsDiv = document.getElementById('transit-predictions');
if (transitPredictionsDiv != null) {
if (transitPredictionsDiv.children.length > 0) {
if ((weekdayPredict || sundayPredict) && overnightMode == false) {
slickIndex = $('#transit-predictions').attr('data-slick-index');
console.log("Mode A")
console.log(transitPredictionsDiv)
console.log(slickIndex)
transitPredictionsDiv.style.display = 'inline';
if (slickIndex == null) {
$('.rotation-group').slick('slickAdd', '#transit-predictions');
}
} else {
slickIndex = $('#transit-predictions').attr('data-slick-index');
console.log("Mode B")
console.log(transitPredictionsDiv)
console.log(slickIndex)
transitPredictionsDiv.style.display = 'none';
if (slickIndex != null) {
console.log("")
console.log(" !!!!! REMOVING PREDICTIONS")
console.log(slickIndex)
console.log("")
$('.rotation-group').slick('slickRemove', slickIndex);
}
}
}
}
var sharedMobilityStatusDiv = document.getElementById('shared-mobility-status');
if (sharedMobilityStatusDiv != null) {
if (sharedMobilityStatusDiv.children.length > 0) {
if ((weekdayPredict || sundayPredict) && overnightMode == false) {
slickIndex = $('#shared-mobility-status').attr('data-slick-index');
console.log("Mode A - shared")
console.log(sharedMobilityStatusDiv)
console.log(slickIndex)
sharedMobilityStatusDiv.style.display = 'inline';
if (slickIndex == null) {
$('.rotation-group').slick('slickAdd', '#shared-mobility-status');
}
} else {
slickIndex = $('#shared-mobility-status').attr('data-slick-index');
console.log("Mode B - shared")
console.log(sharedMobilityStatusDiv)
console.log(slickIndex)
sharedMobilityStatusDiv.style.display = 'none';
if (slickIndex != null) {
console.log("")
console.log(" !!!!! REMOVING SHARED STATUS")
console.log(slickIndex)
console.log("")
$('.rotation-group').slick('slickRemove', slickIndex);
}
}
}
}
var messageStatusDiv = document.getElementById('message-status');
if (messageStatusDiv != null) {
if (messageStatusDiv.children.length > 0) {
if (!weekdayHideMessage && currentSevereImmediate == false && overnightMode == false) {
slickIndex = $('#message-status').attr('data-slick-index');
console.log("Mode T")
console.log(slickIndex)
messageStatusDiv.style.display = 'inline';
if (slickIndex == null) {
$('.rotation-group').slick('slickAdd', '#message-status');
}
} else {
slickIndex = $('#message-status').attr('data-slick-index');
console.log("Mode U")
console.log(slickIndex)
messageStatusDiv.style.display = 'none';
lastDisplayText = '';
if (slickIndex != null) {
console.log("")
console.log(" !!!!! REMOVING MESSAGE")
console.log(slickIndex)
console.log("")
$('.rotation-group').slick('slickRemove', slickIndex);
}
}
}
}
};
setInterval(rotationUpdate,15000);