2017-12-10 03:57:20 +00:00
|
|
|
// use this when making changes so that there is no need to parse the page
|
2017-12-31 23:52:48 +00:00
|
|
|
var backgroundList = [
|
|
|
|
{address: "img/1.png", dark: false},
|
|
|
|
{address: "img/2.png", dark: false},
|
|
|
|
{address: "img/3.png", dark: false},
|
|
|
|
{address: "img/4.png", dark: false},
|
|
|
|
{address: "img/5.png", dark: false},
|
|
|
|
{address: "img/6.png", dark: true},
|
|
|
|
{address: "img/7.png", dark: true},
|
|
|
|
{address: "img/8.png", dark: true}
|
|
|
|
];
|
2017-12-10 03:57:20 +00:00
|
|
|
|
2017-11-08 04:00:42 +00:00
|
|
|
$(document).ready(function () {
|
|
|
|
calcBackground();
|
2017-12-24 00:40:42 +00:00
|
|
|
setInterval(calcBackground, 60000); // run every minute
|
2017-11-08 04:00:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
function calcBackground() {
|
2017-12-24 00:40:42 +00:00
|
|
|
if (navigator.onLine) {
|
|
|
|
var now = new Date();
|
|
|
|
var hours = now.getHours();
|
|
|
|
var mins = now.getMinutes();
|
|
|
|
var total = (hours * 60) + mins;
|
2017-11-08 04:00:42 +00:00
|
|
|
|
2017-12-31 23:52:48 +00:00
|
|
|
var period = (24 / backgroundList.length) * 60; // in minutes
|
|
|
|
|
|
|
|
var background = backgroundList[Math.floor(total / period)];
|
|
|
|
setBackground(background.address, background.dark);
|
2017-12-24 00:40:42 +00:00
|
|
|
}
|
2017-11-08 04:00:42 +00:00
|
|
|
}
|
|
|
|
|
2017-12-31 23:52:48 +00:00
|
|
|
function setBackground(address, dark) {
|
2017-12-14 03:50:55 +00:00
|
|
|
// dark is a boolean that indicates the brightness of the background
|
2017-12-31 23:52:48 +00:00
|
|
|
$("body").css("background-image", "url(" + address + ")");
|
2017-12-14 03:50:55 +00:00
|
|
|
|
2017-12-10 19:36:09 +00:00
|
|
|
if (dark) {
|
|
|
|
$(".navbar").removeClass("navbar-dark").addClass("navbar-light");
|
2017-12-14 03:50:55 +00:00
|
|
|
$(".navbar-toggler").removeClass("toggler-bg-dark btn-dark").addClass("toggler-bg-light btn-light");
|
|
|
|
} else {
|
|
|
|
$(".navbar").removeClass("navbar-light").addClass("navbar-dark");
|
|
|
|
$(".navbar-toggler").removeClass("toggler-bg-light btn-light").addClass("toggler-bg-dark btn-dark");
|
2017-12-10 19:36:09 +00:00
|
|
|
}
|
2017-11-08 04:00:42 +00:00
|
|
|
}
|