2017-12-31 23:52:48 +00:00
|
|
|
var backgroundList = [
|
2017-12-31 23:59:43 +00:00
|
|
|
{address: "img/11-Mid-Night.png", dark: true},
|
|
|
|
{address: "img/12-Late-Night.png", dark: true},
|
|
|
|
{address: "img/01-Early-Morning.png", dark: true},
|
|
|
|
{address: "img/02-Mid-Morning.png", dark: false},
|
|
|
|
{address: "img/03-Late-Morning.png", dark: false},
|
|
|
|
{address: "img/04-Early-Afternoon.png", dark: false},
|
|
|
|
{address: "img/05-Mid-Afternoon.png", dark: false},
|
|
|
|
{address: "img/06-Late-Afternoon.png", dark: false},
|
|
|
|
{address: "img/07-Early-Evening.png", dark: false},
|
|
|
|
{address: "img/08-Mid-Evening.png", dark: true},
|
|
|
|
{address: "img/09-Late-Evening.png", dark: true},
|
2018-01-02 00:56:10 +00:00
|
|
|
{address: "img/10-Early-Night.png", dark: true},
|
|
|
|
{address: "img/10-Early-Night.png", dark: true} // for better timing
|
2017-12-31 23:52:48 +00:00
|
|
|
];
|
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
|
|
|
|
|
2018-01-01 00:01:03 +00:00
|
|
|
var index = Math.floor(total / period);
|
|
|
|
setBackground(index);
|
2017-12-24 00:40:42 +00:00
|
|
|
}
|
2017-11-08 04:00:42 +00:00
|
|
|
}
|
|
|
|
|
2017-12-31 23:59:28 +00:00
|
|
|
function setBackground(num) {
|
2017-12-14 03:50:55 +00:00
|
|
|
// dark is a boolean that indicates the brightness of the background
|
2017-12-31 23:59:28 +00:00
|
|
|
$("body").css("background-image", "url(" + backgroundList[num].address + ")");
|
2017-12-14 03:50:55 +00:00
|
|
|
|
2017-12-31 23:59:28 +00:00
|
|
|
if (backgroundList[num].dark) {
|
2017-12-10 19:36:09 +00:00
|
|
|
$(".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
|
|
|
}
|