From 839c1afe9d01141f1b30a3b02e0f0ef003202775 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Sat, 1 Nov 2014 05:04:57 +0200 Subject: [PATCH] Remove unused methods and optimise current event detection --- schedule.js | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/schedule.js b/schedule.js index e6af67e..3b8c54c 100644 --- a/schedule.js +++ b/schedule.js @@ -12,13 +12,6 @@ function Schedule(hallId) { }); } - this.addEvent = function(event) { - events.push(event); - events = _.sortBy(events, function(event) { - return event.startTime.unix() - }); - } - this.upcomingEvents = function() { return _.select(events, function(event) { return event.startTime.isAfter(moment()); @@ -31,8 +24,7 @@ function Schedule(hallId) { this.currentEvent = function() { var latestEvent = _.last(this.pastEvents()); - var nextEvent = this.nextEvent(); - if (typeof nextEvent != 'undefined' && moment(nextEvent.startTime).subtract('minutes', 10).isAfter(moment())) { + if (typeof(latestEvent) != 'undefined' && latestEvent.endTime.isAfter(moment())) { return latestEvent; } else { return undefined; @@ -52,12 +44,6 @@ function Schedule(hallId) { this.allEvents = function() { return events; } - - this.addDelay = function(time) { - _.each(this.upcomingEvents(), function(event, index, agenda) { - event.startTime.add(time); - }); - } } $.urlParam = function(name){