update robot

This commit is contained in:
Martin Donnelly 2017-08-06 01:33:19 +01:00
parent d8c22d8d13
commit 82390a96b2

View File

@ -21,11 +21,18 @@ let TrainModel = Backbone.Model.extend({
this.update();
},
update: function () {
this.getTrain();
const now = new Date;
const mod = 60000 - (now.getTime() % 60000);
const hours = now.getHours();
if (hours >= 6) {
this.getTrain();
}
let trainUpdateFn = function () {
this.update();
};
setTimeout(trainUpdateFn.bind(this), mod + 10);