2013-06-25 01:41:59 +02:00
|
|
|
|
'use strict';
|
|
|
|
|
define(
|
|
|
|
|
[
|
|
|
|
|
'backbone',
|
2013-07-17 08:23:44 +02:00
|
|
|
|
'moment',
|
2013-06-25 01:41:59 +02:00
|
|
|
|
'Series/EpisodeModel'
|
2013-07-17 08:23:44 +02:00
|
|
|
|
], function (Backbone, Moment, EpisodeModel) {
|
2013-06-25 01:41:59 +02:00
|
|
|
|
return Backbone.Collection.extend({
|
|
|
|
|
url : window.ApiRoot + '/calendar',
|
|
|
|
|
model: EpisodeModel,
|
2013-06-06 05:03:04 +02:00
|
|
|
|
|
2013-07-01 20:25:06 +02:00
|
|
|
|
comparator: function (model1, model2) {
|
2013-07-24 07:28:06 +02:00
|
|
|
|
var airDate1 = model1.get('airDateUtc');
|
2013-07-17 08:23:44 +02:00
|
|
|
|
var date1 = Moment(airDate1);
|
|
|
|
|
var time1 = date1.unix();
|
2013-07-01 20:25:06 +02:00
|
|
|
|
|
2013-07-24 07:28:06 +02:00
|
|
|
|
var airDate2 = model2.get('airDateUtc');
|
2013-07-17 08:23:44 +02:00
|
|
|
|
var date2 = Moment(airDate2);
|
|
|
|
|
var time2 = date2.unix();
|
2013-07-01 20:25:06 +02:00
|
|
|
|
|
|
|
|
|
if (time1 < time2){
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (time1 > time2){
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
2013-06-25 01:41:59 +02:00
|
|
|
|
}
|
|
|
|
|
});
|
2013-02-23 18:42:15 +01:00
|
|
|
|
});
|