Remove unused methods and optimise current event detection
This commit is contained in:
parent
60f068c20e
commit
839c1afe9d
16
schedule.js
16
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() {
|
this.upcomingEvents = function() {
|
||||||
return _.select(events, function(event) {
|
return _.select(events, function(event) {
|
||||||
return event.startTime.isAfter(moment());
|
return event.startTime.isAfter(moment());
|
||||||
|
@ -31,8 +24,7 @@ function Schedule(hallId) {
|
||||||
|
|
||||||
this.currentEvent = function() {
|
this.currentEvent = function() {
|
||||||
var latestEvent = _.last(this.pastEvents());
|
var latestEvent = _.last(this.pastEvents());
|
||||||
var nextEvent = this.nextEvent();
|
if (typeof(latestEvent) != 'undefined' && latestEvent.endTime.isAfter(moment())) {
|
||||||
if (typeof nextEvent != 'undefined' && moment(nextEvent.startTime).subtract('minutes', 10).isAfter(moment())) {
|
|
||||||
return latestEvent;
|
return latestEvent;
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -52,12 +44,6 @@ function Schedule(hallId) {
|
||||||
this.allEvents = function() {
|
this.allEvents = function() {
|
||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addDelay = function(time) {
|
|
||||||
_.each(this.upcomingEvents(), function(event, index, agenda) {
|
|
||||||
event.startTime.add(time);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$.urlParam = function(name){
|
$.urlParam = function(name){
|
||||||
|
|
Loading…
Reference in New Issue