2016-11-04 16:51:20 +02:00
|
|
|
function Schedule(hallId, date) {
|
2014-05-13 07:27:47 +03:00
|
|
|
var events = [];
|
|
|
|
|
2015-08-12 21:03:56 +03:00
|
|
|
this.update = function() {
|
2016-11-04 16:51:20 +02:00
|
|
|
$.getJSON('http://www.openfest.org/2016/wp-content/themes/initfest/schedule/interlude.php', function(data) {
|
2015-08-12 21:03:56 +03:00
|
|
|
var scheduleEvents = $.map(data[hallId], function(event) {
|
2016-11-04 16:51:20 +02:00
|
|
|
event['startTime'] = moment(event['starts_at'] * 1000);
|
|
|
|
event['endTime'] = moment(event['ends_at'] * 1000);
|
|
|
|
console.log(event['startTime'].date());
|
|
|
|
if (event['startTime'].date() !== date) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2015-08-12 21:03:56 +03:00
|
|
|
return event;
|
|
|
|
});
|
2015-08-12 21:17:46 +03:00
|
|
|
|
2015-08-12 21:03:56 +03:00
|
|
|
events = scheduleEvents;
|
2014-05-13 07:27:47 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
this.upcomingEvents = function() {
|
|
|
|
return _.select(events, function(event) {
|
|
|
|
return event.startTime.isAfter(moment());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
this.nextEvent = function() {
|
|
|
|
return _.first(this.upcomingEvents());
|
|
|
|
}
|
|
|
|
|
2014-06-21 05:08:15 +03:00
|
|
|
this.currentEvent = function() {
|
2014-06-21 10:55:38 +03:00
|
|
|
var latestEvent = _.last(this.pastEvents());
|
2015-08-12 21:03:56 +03:00
|
|
|
if (typeof(latestEvent) != 'undefined' && latestEvent.endTime.isAfter(moment())) {
|
2014-06-21 10:55:38 +03:00
|
|
|
return latestEvent;
|
|
|
|
} else {
|
|
|
|
return undefined;
|
|
|
|
}
|
2014-06-21 05:08:15 +03:00
|
|
|
}
|
|
|
|
|
2014-05-13 15:43:58 +03:00
|
|
|
this.futureEvents = function() {
|
|
|
|
return this.upcomingEvents().splice(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.pastEvents = function() {
|
|
|
|
return _.select(events, function(event) {
|
|
|
|
return event.startTime.isBefore(moment());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
this.allEvents = function() {
|
2014-05-13 07:27:47 +03:00
|
|
|
return events;
|
|
|
|
}
|
2015-08-12 21:03:56 +03:00
|
|
|
}
|
2014-05-13 07:27:47 +03:00
|
|
|
|
2015-08-12 21:03:56 +03:00
|
|
|
$.urlParam = function(name){
|
|
|
|
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
|
|
|
|
if (results==null){
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
return results[1] || 0;
|
2014-05-13 07:27:47 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-04 16:51:20 +02:00
|
|
|
var schedule = new Schedule(parseInt($.urlParam('roomId')), parseInt($.urlParam('date')));
|