Better management of background images

This commit is contained in:
Neil Brommer 2017-12-13 19:51:20 -08:00
parent 4a4befa2c5
commit faa720ddf1

View file

@ -1,6 +1,8 @@
// use this when making changes so that there is no need to parse the page // use this when making changes so that there is no need to parse the page
var bookmarkList; var bookmarkList;
var dbVersion; var dbVersion;
var backgroundList = ["img/1.png", "img/2.png", "img/3.png", "img/4.png",
"img/5.png", "img/6.png", "img/7.png", "img/8.png"];
$(document).ready(function () { $(document).ready(function () {
calcBackground(); calcBackground();
@ -16,26 +18,26 @@ function calcBackground() {
// 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(1, false); setBackground(0, false);
else if (total > 460 && total < 620) else if (total > 460 && total < 620)
setBackground(2, false); setBackground(1, false);
else if (total > 620 && total < 780) else if (total > 620 && total < 780)
setBackground(3, false); setBackground(2, false);
else if (total > 780 && total < 940) else if (total > 780 && total < 940)
setBackground(4, false); setBackground(3, false);
else if (total > 940 && total < 1100) else if (total > 940 && total < 1100)
setBackground(5, false); setBackground(4, false);
else if (total > 1100 && total < 1260) else if (total > 1100 && total < 1260)
setBackground(6, true); setBackground(5, true);
else if (total > 1260 && total < 1420) else if (total > 1260 && total < 1420)
setBackground(7, true); setBackground(6, true);
else else
setBackground(8, true); setBackground(7, true);
} }
function setBackground(num, dark) { function setBackground(num, dark) {
$("body").css("background-image", "url(img/" + num + ".png)");
// dark is a boolean that indicates the brightness of the background // dark is a boolean that indicates the brightness of the background
$("body").css("background-image", "url(" + backgroundList[num] + ")");
if (dark) { if (dark) {
$(".navbar").removeClass("navbar-dark").addClass("navbar-light"); $(".navbar").removeClass("navbar-dark").addClass("navbar-light");