2013-10-24 10:49:24 -07:00
( function ( $ , document ) {
$ ( document ) . on ( 'pagebeforeshow' , "#tvUpcomingPage" , function ( ) {
var page = this ;
2013-11-19 10:17:14 -07:00
var query = {
2013-10-24 10:49:24 -07:00
2013-11-08 08:35:36 -07:00
SortBy : "PremiereDate,AirTime,SortName" ,
2013-10-24 10:49:24 -07:00
SortOrder : "Ascending" ,
IncludeItemTypes : "Episode" ,
2013-10-25 07:18:53 -07:00
Limit : 30 ,
2013-10-24 10:49:24 -07:00
Recursive : true ,
2013-11-19 10:17:14 -07:00
Fields : "SeriesInfo,UserData"
2013-10-24 10:49:24 -07:00
} ;
2013-11-19 10:17:14 -07:00
var missedItemsQuery = $ . extend ( {
2013-12-03 21:18:50 -07:00
IsUnaired : false
2013-11-19 10:17:14 -07:00
2013-12-03 21:18:50 -07:00
} , query ) ;
2013-11-19 10:17:14 -07:00
var yesterday = new Date ( ) ;
yesterday . setDate ( yesterday . getDate ( ) - 1 ) ;
yesterday . setHours ( 0 , 0 , 0 , 0 ) ;
2013-12-03 21:18:50 -07:00
2014-01-07 11:39:35 -07:00
missedItemsQuery . MinPremiereDate = yesterday . toISOString ( ) ;
2013-11-19 10:17:14 -07:00
var unairedQuery = $ . extend ( {
2013-10-24 10:49:24 -07:00
2013-11-19 10:17:14 -07:00
IsUnaired : true
} , query ) ;
var promise1 = ApiClient . getItems ( Dashboard . getCurrentUserId ( ) , missedItemsQuery ) ;
var promise2 = ApiClient . getItems ( Dashboard . getCurrentUserId ( ) , unairedQuery ) ;
$ . when ( promise1 , promise2 ) . done ( function ( response1 , response2 ) {
var missedItems = response1 [ 0 ] . Items ;
var unairedItems = response2 [ 0 ] . Items ;
for ( var i = 0 , length = unairedItems . length ; i < length ; i ++ ) {
missedItems . push ( unairedItems [ i ] ) ;
}
if ( ! missedItems . length ) {
2013-10-25 07:18:53 -07:00
$ ( '#upcomingItems' , page ) . html ( "<p>Nothing here. Please ensure <a href='metadata.html'>downloading of internet metadata</a> is enabled.</p>" ) . trigger ( 'create' ) ;
2013-10-24 10:49:24 -07:00
return ;
}
2013-11-19 10:17:14 -07:00
2013-10-24 10:49:24 -07:00
$ ( '#upcomingItems' , page ) . html ( LibraryBrowser . getPosterViewHtml ( {
2013-11-19 10:17:14 -07:00
items : missedItems ,
2013-10-24 10:49:24 -07:00
showLocationTypeIndicator : false ,
shape : "backdrop" ,
showTitle : true ,
showPremiereDate : true ,
showPremiereDateIndex : true ,
preferThumb : true
2014-01-14 22:01:58 -07:00
} ) ) . createPosterItemHoverMenu ( ) ;
2013-10-24 10:49:24 -07:00
} ) ;
} ) ;
} ) ( jQuery , document ) ;