From 82390a96b2bbbf01287937f4ed0efbc7bf265257 Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Sun, 6 Aug 2017 01:33:19 +0100 Subject: [PATCH] update robot --- app/js/modules/train.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/js/modules/train.js b/app/js/modules/train.js index 14cd5d5..2651769 100644 --- a/app/js/modules/train.js +++ b/app/js/modules/train.js @@ -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);