2013-04-01 17:54:06 -07:00
( function ( $ , document , apiClient ) {
2013-02-20 18:33:05 -07:00
2013-07-23 05:29:28 -07:00
function reloadTips ( page ) {
var tips = [
'Did you know that editing the artist or album of a music video will allow it to appear on the artist page?' ,
'Did you know that editing the tmdb id, tvdb id, and/or games db id of an album will allow media browser to link it to a movie, series or game as a soundtrack?' ,
2013-07-25 12:18:02 -07:00
'Did you know that you can re-order your media collections by editing their sort names?' ,
'Did you know that series, seasons, games and boxsets can have local trailers?' ,
'Did you know that movies can have special features by placing them in a "specials" sub-folder underneath the movie folder?' ,
'Did you know that the trailer plugin can automatically download trailers for existing movies in your collection?'
2013-07-23 05:29:28 -07:00
] ;
var random = Math . floor ( ( Math . random ( ) * tips . length * 2 ) ) ;
var tip = tips [ random ] ;
if ( tip ) {
$ ( '#tip' , page ) . html ( tip ) . show ( ) ;
} else {
$ ( '#tip' , page ) . hide ( ) ;
}
}
2013-04-04 10:27:36 -07:00
function getViewHtml ( view ) {
var html = '' ;
2013-04-25 17:52:55 -07:00
html += '<a class="posterItem backdropPosterItem" href="' + view . url + '">' ;
html += '<div class="posterItemImage" style="background-color: ' + view . background + ';background-image:url(\'' + view . img + '\');"></div><div class="posterItemText posterItemTextCentered">' + view . name + '</div>' ;
2013-04-04 10:27:36 -07:00
html += '</a>' ;
return html ;
}
2013-04-06 11:57:38 -07:00
$ ( document ) . on ( 'pagebeforeshow' , "#indexPage" , function ( ) {
2013-02-20 18:33:05 -07:00
2013-04-01 08:59:56 -07:00
var page = this ;
2013-02-20 18:33:05 -07:00
2013-04-01 08:59:56 -07:00
var userId = Dashboard . getCurrentUserId ( ) ;
2013-04-01 11:55:56 -07:00
2013-02-20 18:33:05 -07:00
if ( ! userId ) {
return ;
}
var options = {
sortBy : "SortName"
} ;
2013-05-13 22:36:36 -07:00
apiClient . getItemCounts ( userId ) . done ( function ( counts ) {
2013-02-20 18:33:05 -07:00
2013-05-13 22:36:36 -07:00
var views = [ ] ;
2013-02-20 18:33:05 -07:00
2013-05-13 22:36:36 -07:00
if ( counts . MovieCount || counts . TrailerCount ) {
views . push ( { name : "Movies" , url : "moviesrecommended.html" , img : "css/images/items/list/chapter.png" , background : "#0094FF" } ) ;
}
2013-04-04 10:27:36 -07:00
2013-05-13 22:36:36 -07:00
if ( counts . EpisodeCount || counts . SeriesCount ) {
views . push ( { name : "TV Shows" , url : "tvrecommended.html" , img : "css/images/items/list/collection.png" , background : "#FF870F" } ) ;
}
2013-04-01 11:55:56 -07:00
2013-05-28 10:25:10 -07:00
if ( counts . SongCount || counts . MusicVideoCount ) {
2013-05-13 22:36:36 -07:00
views . push ( { name : "Music" , url : "musicrecommended.html" , img : "css/images/items/list/audiocollection.png" , background : "#6FBD45" } ) ;
}
2013-04-01 11:55:56 -07:00
2013-05-13 22:36:36 -07:00
if ( counts . GameCount ) {
views . push ( { name : "Games" , url : "gamesrecommended.html" , img : "css/images/items/list/gamecollection.png" , background : "#E12026" } ) ;
}
2013-04-01 11:55:56 -07:00
2013-05-13 22:36:36 -07:00
var html = '' ;
2013-04-01 11:55:56 -07:00
2013-05-13 22:36:36 -07:00
for ( var i = 0 , length = views . length ; i < length ; i ++ ) {
2013-04-04 10:27:36 -07:00
2013-05-13 22:36:36 -07:00
html += getViewHtml ( views [ i ] ) ;
}
2013-04-04 10:27:36 -07:00
2013-05-13 22:36:36 -07:00
$ ( '#views' , page ) . html ( html ) ;
} ) ;
2013-04-04 10:27:36 -07:00
2013-05-13 22:36:36 -07:00
apiClient . getItems ( userId , options ) . done ( function ( result ) {
2013-04-04 10:27:36 -07:00
2013-05-13 22:36:36 -07:00
$ ( '#divCollections' , page ) . html ( LibraryBrowser . getPosterViewHtml ( {
items : result . Items ,
showTitle : true ,
shape : "backdrop" ,
centerText : true
} ) ) ;
2013-04-04 10:27:36 -07:00
} ) ;
2013-04-01 08:59:56 -07:00
} ) ;
2013-02-20 18:33:05 -07:00
2013-07-23 05:29:28 -07:00
$ ( document ) . on ( 'pagebeforeshow' , "#indexPage" , function ( ) {
var page = this ;
reloadTips ( page ) ;
} ) ;
2013-04-01 17:54:06 -07:00
} ) ( jQuery , document , ApiClient ) ;