Only update the background if connected to the Internet
This commit is contained in:
		
							parent
							
								
									76b00b2d43
								
							
						
					
					
						commit
						bd20c403b3
					
				| 
						 | 
					@ -6,10 +6,11 @@ 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() {
 | 
				
			||||||
 | 
						if (navigator.onLine) {
 | 
				
			||||||
		var now = new Date();
 | 
							var now = new Date();
 | 
				
			||||||
		var hours = now.getHours();
 | 
							var hours = now.getHours();
 | 
				
			||||||
		var mins = now.getMinutes();
 | 
							var mins = now.getMinutes();
 | 
				
			||||||
| 
						 | 
					@ -33,6 +34,7 @@ function calcBackground() {
 | 
				
			||||||
			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