Only update the background if connected to the Internet
This commit is contained in:
parent
76b00b2d43
commit
bd20c403b3
48
js/main.js
48
js/main.js
|
@ -6,33 +6,35 @@ var backgroundList = ["img/1.png", "img/2.png", "img/3.png", "img/4.png",
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
calcBackground();
|
calcBackground();
|
||||||
setInterval(calcBackground, 60000);
|
setInterval(calcBackground, 60000); // run every minute
|
||||||
});
|
});
|
||||||
|
|
||||||
function calcBackground() {
|
function calcBackground() {
|
||||||
var now = new Date();
|
if (navigator.onLine) {
|
||||||
var hours = now.getHours();
|
var now = new Date();
|
||||||
var mins = now.getMinutes();
|
var hours = now.getHours();
|
||||||
var total = (hours * 60) + mins;
|
var mins = now.getMinutes();
|
||||||
|
var total = (hours * 60) + mins;
|
||||||
|
|
||||||
// 24*60 = 1440
|
// 24*60 = 1440
|
||||||
// 2:40 between each step
|
// 2:40 between each step
|
||||||
if (total > 300 && total < 460) // 5:00 - 7:40
|
if (total > 300 && total < 460) // 5:00 - 7:40
|
||||||
setBackground(0, false);
|
setBackground(0, false);
|
||||||
else if (total > 460 && total < 620)
|
else if (total > 460 && total < 620)
|
||||||
setBackground(1, false);
|
setBackground(1, false);
|
||||||
else if (total > 620 && total < 780)
|
else if (total > 620 && total < 780)
|
||||||
setBackground(2, false);
|
setBackground(2, false);
|
||||||
else if (total > 780 && total < 940)
|
else if (total > 780 && total < 940)
|
||||||
setBackground(3, false);
|
setBackground(3, false);
|
||||||
else if (total > 940 && total < 1100)
|
else if (total > 940 && total < 1100)
|
||||||
setBackground(4, false);
|
setBackground(4, false);
|
||||||
else if (total > 1100 && total < 1260)
|
else if (total > 1100 && total < 1260)
|
||||||
setBackground(5, true);
|
setBackground(5, true);
|
||||||
else if (total > 1260 && total < 1420)
|
else if (total > 1260 && total < 1420)
|
||||||
setBackground(6, true);
|
setBackground(6, true);
|
||||||
else
|
else
|
||||||
setBackground(7, true);
|
setBackground(7, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setBackground(num, dark) {
|
function setBackground(num, dark) {
|
||||||
|
|
Loading…
Reference in a new issue