28 lines
732 B
JavaScript
28 lines
732 B
JavaScript
var app = {
|
|
init: function () {
|
|
console.log("Init App");
|
|
app_state.init();
|
|
ui.init();
|
|
api.init(app_state.api_endpoint);
|
|
this.refresh();
|
|
},
|
|
refresh: function () {
|
|
console.log("refresh " + Date.now());
|
|
api.load_status();
|
|
this.poll_timer = setInterval(this.refresh, 5000);
|
|
},
|
|
poll_toggle: function () {
|
|
console.log("POLL TIMER = " + this.poll_timer);
|
|
if (this.poll_timer == null) {
|
|
console.log("poll_toggle triggered " + Date.now());
|
|
this.poll_timer = setInterval(this.refresh, 5000);
|
|
app_state.should_poll = true;
|
|
} else {
|
|
console.log("disabling timer");
|
|
this.poll_timer = null;
|
|
app_state.should_poll = false;
|
|
}
|
|
},
|
|
poll_timer: null,
|
|
};
|