Calculate end time from next event's start time
This commit is contained in:
parent
baa7ec4b66
commit
dc11a85f41
14
schedule.js
14
schedule.js
|
@ -4,11 +4,21 @@ function Schedule(hallId) {
|
|||
this.update = function() {
|
||||
$.getJSON("http://varnaconf.com/schedules/2015.json", function(data) {
|
||||
var scheduleEvents = $.map(data[hallId], function(event) {
|
||||
event['startTime'] = moment(event['startTime']).subtract(219910, 'seconds');
|
||||
event['endTime'] = moment(event['startTime']).add(40, 'minutes');
|
||||
event['startTime'] = moment(event['startTime']);
|
||||
return event;
|
||||
});
|
||||
|
||||
$.each(scheduleEvents, function(index, event) {
|
||||
var nextEvent = scheduleEvents[index + 1];
|
||||
if (typeof(nextEvent) != 'undefined') {
|
||||
event['endTime'] = moment(nextEvent['startTime']).subtract(10, 'minutes');
|
||||
} else {
|
||||
event['endTime'] = moment(event['startTime']).add(40, 'minutes');
|
||||
}
|
||||
});
|
||||
|
||||
events = scheduleEvents;
|
||||
console.log(events);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue