Calculate end time from next event's start time

This commit is contained in:
Petko Bordjukov 2015-08-12 21:17:46 +03:00
parent baa7ec4b66
commit dc11a85f41
1 changed files with 12 additions and 2 deletions

View File

@ -4,11 +4,21 @@ function Schedule(hallId) {
this.update = function() { this.update = function() {
$.getJSON("http://varnaconf.com/schedules/2015.json", function(data) { $.getJSON("http://varnaconf.com/schedules/2015.json", function(data) {
var scheduleEvents = $.map(data[hallId], function(event) { var scheduleEvents = $.map(data[hallId], function(event) {
event['startTime'] = moment(event['startTime']).subtract(219910, 'seconds'); event['startTime'] = moment(event['startTime']);
event['endTime'] = moment(event['startTime']).add(40, 'minutes');
return event; 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; events = scheduleEvents;
console.log(events);
}); });
} }