js/main-alarm.js
//Poll the heartbeat file and update the status image to show if the system is running or not
Poll the heartbeat file and update the status image to show if the system is running or not
Poll the heartbeat file and update the status image to show if the system is running or not
function poll()
{
	setTimeout( function() {
			$.ajax("/alarmHeartbeat.html").success( function(data) {
					console.log('HB:'+data);
					var milliseconds = Math.floor( Date.now() / 1000 );
					console.log('MS:'+milliseconds);
					var diff = milliseconds - data;
					console.log('DIFF:'+diff);
					if(diff < 20)
					{
						document.statusicon.src="images/on_sm.png";
						console.log("running");
					}else{
						document.statusicon.src="images/off_sm.png";
						console.log("stalled");
					}
					poll();
				});
			}, 2000);
}
function poll ( ) { setTimeout ( function ( ) { $ . ajax ( "/alarmHeartbeat.html" ) . success ( function ( data ) { console . log ( 'HB:' + data ) ; var milliseconds = Math . floor ( Date . now ( ) / 1000 ) ; console . log ( 'MS:' + milliseconds ) ; var diff = milliseconds - data ; console . log ( 'DIFF:' + diff ) ; if ( diff < 20 ) { document . statusicon . src = "images/on_sm.png" ; console . log ( "running" ) ; } else { document . statusicon . src = "images/off_sm.png" ; console . log ( "stalled" ) ; } poll ( ) ; } ) ; } , 2000 ) ; }
Poll the heartbeat file and update the status image to show if the system is running or not
Poll the heartbeat file and update the status image to show if the system is running or not