2014-10-15 20:26:39 -07:00
|
|
|
|
(function ($, document) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-06-07 12:46:24 -07:00
|
|
|
|
function getUserViews(userId) {
|
|
|
|
|
|
|
|
|
|
var deferred = $.Deferred();
|
|
|
|
|
|
|
|
|
|
ApiClient.getUserViews(userId).done(function (result) {
|
|
|
|
|
|
|
|
|
|
var items = result.Items;
|
|
|
|
|
|
|
|
|
|
deferred.resolveWith(null, [items]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return deferred.promise();
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-06 22:12:13 -07:00
|
|
|
|
function getLibraryButtonsHtml(items) {
|
2014-06-24 14:45:21 -07:00
|
|
|
|
|
|
|
|
|
var html = "";
|
|
|
|
|
|
|
|
|
|
// "My Library" backgrounds
|
|
|
|
|
for (var i = 0, length = items.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var item = items[i];
|
|
|
|
|
|
2015-02-02 21:54:52 -07:00
|
|
|
|
var icon;
|
2015-05-06 21:14:35 -07:00
|
|
|
|
var backgroundColor = 'rgba(82, 181, 75, 0.7)';
|
2014-06-24 14:45:21 -07:00
|
|
|
|
|
|
|
|
|
switch (item.CollectionType) {
|
|
|
|
|
case "movies":
|
2015-02-02 21:54:52 -07:00
|
|
|
|
icon = "fa-film";
|
2015-05-06 21:14:35 -07:00
|
|
|
|
backgroundColor = 'rgba(176, 94, 81, 0.7)';
|
2014-06-24 14:45:21 -07:00
|
|
|
|
break;
|
|
|
|
|
case "music":
|
2015-02-02 21:54:52 -07:00
|
|
|
|
icon = "fa-music";
|
2015-05-06 21:14:35 -07:00
|
|
|
|
backgroundColor = 'rgba(217, 145, 67, 0.7)';
|
2014-06-24 14:45:21 -07:00
|
|
|
|
break;
|
|
|
|
|
case "photos":
|
2015-02-02 21:54:52 -07:00
|
|
|
|
icon = "fa-photo";
|
2015-05-06 21:14:35 -07:00
|
|
|
|
backgroundColor = 'rgba(127, 0, 0, 0.7)';
|
2014-06-24 14:45:21 -07:00
|
|
|
|
break;
|
|
|
|
|
case "livetv":
|
2015-05-06 21:14:35 -07:00
|
|
|
|
icon = "fa-video-camera";
|
|
|
|
|
backgroundColor = 'rgba(255, 233, 127, 0.7)';
|
|
|
|
|
break;
|
2014-06-24 14:45:21 -07:00
|
|
|
|
case "tvshows":
|
2015-02-02 21:54:52 -07:00
|
|
|
|
icon = "fa-video-camera";
|
2015-05-06 21:14:35 -07:00
|
|
|
|
backgroundColor = 'rgba(77, 88, 164, 0.7)';
|
2014-06-24 14:45:21 -07:00
|
|
|
|
break;
|
|
|
|
|
case "games":
|
2015-02-02 21:54:52 -07:00
|
|
|
|
icon = "fa-gamepad";
|
2015-05-06 21:14:35 -07:00
|
|
|
|
backgroundColor = 'rgba(183, 202, 72, 0.7)';
|
2014-06-24 14:45:21 -07:00
|
|
|
|
break;
|
|
|
|
|
case "trailers":
|
2015-02-02 21:54:52 -07:00
|
|
|
|
icon = "fa-film";
|
2015-05-06 21:14:35 -07:00
|
|
|
|
backgroundColor = 'rgba(176, 94, 81, 0.7)';
|
2014-06-24 14:45:21 -07:00
|
|
|
|
break;
|
|
|
|
|
case "homevideos":
|
2015-02-02 21:54:52 -07:00
|
|
|
|
icon = "fa-video-camera";
|
2015-05-06 21:14:35 -07:00
|
|
|
|
backgroundColor = 'rgba(110, 52, 32, 0.7)';
|
2014-06-24 14:45:21 -07:00
|
|
|
|
break;
|
|
|
|
|
case "musicvideos":
|
2015-02-02 21:54:52 -07:00
|
|
|
|
icon = "fa-video-camera";
|
2015-05-06 21:14:35 -07:00
|
|
|
|
backgroundColor = 'rgba(143, 54, 168, 0.7)';
|
2014-06-24 14:45:21 -07:00
|
|
|
|
break;
|
|
|
|
|
case "books":
|
2015-02-02 21:54:52 -07:00
|
|
|
|
icon = "fa-book";
|
2014-06-24 14:45:21 -07:00
|
|
|
|
break;
|
|
|
|
|
case "channels":
|
2015-02-03 14:06:56 -07:00
|
|
|
|
icon = "fa-globe";
|
2015-05-06 21:14:35 -07:00
|
|
|
|
backgroundColor = 'rgba(51, 136, 204, 0.7)';
|
2015-02-03 14:06:56 -07:00
|
|
|
|
break;
|
|
|
|
|
case "playlists":
|
|
|
|
|
icon = "fa-list";
|
2014-06-24 14:45:21 -07:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2015-02-02 21:54:52 -07:00
|
|
|
|
icon = "fa-folder-o";
|
2014-06-24 14:45:21 -07:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-06 21:14:35 -07:00
|
|
|
|
var cssClass = 'card smallBackdropCard buttonCard';
|
2014-06-24 14:45:21 -07:00
|
|
|
|
|
|
|
|
|
if (item.CollectionType) {
|
2015-05-06 21:14:35 -07:00
|
|
|
|
cssClass += ' ' + item.CollectionType + 'buttonCard';
|
2014-06-24 14:45:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-06 22:12:13 -07:00
|
|
|
|
var href = item.url || LibraryBrowser.getHref(item);
|
2014-06-24 14:45:21 -07:00
|
|
|
|
|
|
|
|
|
html += '<a data-itemid="' + item.Id + '" class="' + cssClass + '" href="' + href + '">';
|
2015-05-06 21:14:35 -07:00
|
|
|
|
html += '<div class="cardBox" style="background-color:' + backgroundColor + ';margin:4px;border-radius:4px;">';
|
2014-06-24 14:45:21 -07:00
|
|
|
|
|
2015-05-16 20:17:23 -07:00
|
|
|
|
html += "<div class='cardText' style='padding:8px 10px;color:#fff;font-size:14px;'>";
|
2015-02-02 21:54:52 -07:00
|
|
|
|
html += '<i class="fa ' + icon + '"></i>';
|
2015-05-06 21:14:35 -07:00
|
|
|
|
html += '<span style="margin-left:.7em;">' + item.Name + '</span>';
|
|
|
|
|
html += "</div>";
|
|
|
|
|
|
2014-06-24 14:45:21 -07:00
|
|
|
|
html += "</div>";
|
|
|
|
|
|
|
|
|
|
html += "</a>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadlibraryButtons(elem, userId, index) {
|
|
|
|
|
|
2015-04-12 09:46:29 -07:00
|
|
|
|
return getUserViews(userId).done(function (items) {
|
2014-06-24 14:45:21 -07:00
|
|
|
|
|
|
|
|
|
var html = '<br/>';
|
|
|
|
|
|
|
|
|
|
if (index) {
|
2015-04-10 07:01:16 -07:00
|
|
|
|
html += '<h1 class="listHeader">' + Globalize.translate('HeaderMyMedia') + '</h1>';
|
2014-06-24 14:45:21 -07:00
|
|
|
|
}
|
|
|
|
|
html += '<div>';
|
2015-05-06 22:12:13 -07:00
|
|
|
|
html += getLibraryButtonsHtml(items);
|
2014-06-24 14:45:21 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
$(elem).html(html);
|
|
|
|
|
|
|
|
|
|
handleLibraryLinkNavigations(elem);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-24 18:14:24 -07:00
|
|
|
|
function loadRecentlyAdded(elem, user, context) {
|
2014-05-20 17:56:24 -07:00
|
|
|
|
|
2015-05-07 15:27:01 -07:00
|
|
|
|
var limit = AppInfo.hasLowImageBandwidth ?
|
|
|
|
|
16 :
|
|
|
|
|
24;
|
|
|
|
|
|
2014-05-20 17:56:24 -07:00
|
|
|
|
var options = {
|
2014-05-13 17:46:45 -07:00
|
|
|
|
|
2015-05-07 15:27:01 -07:00
|
|
|
|
Limit: limit,
|
2014-12-10 23:20:28 -07:00
|
|
|
|
Fields: "PrimaryImageAspectRatio,SyncInfo",
|
2015-01-27 15:45:59 -07:00
|
|
|
|
ImageTypeLimit: 1,
|
|
|
|
|
EnableImageTypes: "Primary,Backdrop,Banner,Thumb"
|
2014-05-01 19:54:33 -07:00
|
|
|
|
};
|
2013-04-01 11:55:56 -07:00
|
|
|
|
|
2015-03-24 18:14:24 -07:00
|
|
|
|
return ApiClient.getJSON(ApiClient.getUrl('Users/' + user.Id + '/Items/Latest', options)).done(function (items) {
|
2013-04-01 11:55:56 -07:00
|
|
|
|
|
2014-05-21 12:33:46 -07:00
|
|
|
|
var html = '';
|
2013-11-20 14:08:12 -07:00
|
|
|
|
|
2015-05-12 21:55:19 -07:00
|
|
|
|
var cardLayout = AppInfo.hasLowImageBandwidth;
|
|
|
|
|
|
2014-07-04 22:21:13 -07:00
|
|
|
|
if (items.length) {
|
2014-10-30 21:57:24 -07:00
|
|
|
|
html += '<div>';
|
|
|
|
|
html += '<h1 style="display:inline-block; vertical-align:middle;" class="listHeader">' + Globalize.translate('HeaderLatestMedia') + '</h1>';
|
2015-03-24 18:14:24 -07:00
|
|
|
|
|
|
|
|
|
if (user.Policy.EnableUserPreferenceAccess) {
|
|
|
|
|
html += '<a href="mypreferencesdisplay.html" class="accentButton"><i class="fa fa-pencil"></i>' + Globalize.translate('ButtonEdit') + '</a>';
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-30 21:57:24 -07:00
|
|
|
|
html += '</div>';
|
2015-01-22 23:15:15 -07:00
|
|
|
|
html += '<div class="itemsContainer">';
|
2014-05-21 20:35:18 -07:00
|
|
|
|
html += LibraryBrowser.getPosterViewHtml({
|
2014-07-04 22:21:13 -07:00
|
|
|
|
items: items,
|
2014-05-21 20:35:18 -07:00
|
|
|
|
preferThumb: true,
|
2015-01-22 23:15:15 -07:00
|
|
|
|
shape: 'backdrop',
|
2014-09-29 21:47:30 -07:00
|
|
|
|
context: context || 'home',
|
2014-07-04 22:21:13 -07:00
|
|
|
|
showUnplayedIndicator: false,
|
|
|
|
|
showChildCountIndicator: true,
|
2014-09-29 21:47:30 -07:00
|
|
|
|
lazy: true,
|
2015-05-12 21:55:19 -07:00
|
|
|
|
cardLayout: cardLayout,
|
|
|
|
|
showTitle: cardLayout,
|
2015-05-14 19:16:57 -07:00
|
|
|
|
showYear: cardLayout,
|
|
|
|
|
showDetailsMenu: true
|
2014-05-21 20:35:18 -07:00
|
|
|
|
});
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-22 23:15:15 -07:00
|
|
|
|
$(elem).html(html).lazyChildren();
|
|
|
|
|
$(elem).createCardMenus();
|
2014-05-21 12:33:46 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-15 16:30:04 -07:00
|
|
|
|
function loadLatestChannelMedia(elem, userId) {
|
|
|
|
|
|
|
|
|
|
var screenWidth = $(window).width();
|
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
|
|
2014-07-17 15:21:35 -07:00
|
|
|
|
Limit: screenWidth >= 2400 ? 10 : (screenWidth >= 1600 ? 10 : (screenWidth >= 1440 ? 8 : (screenWidth >= 800 ? 7 : 6))),
|
2014-12-10 23:20:28 -07:00
|
|
|
|
Fields: "PrimaryImageAspectRatio,SyncInfo",
|
2014-06-15 16:30:04 -07:00
|
|
|
|
Filters: "IsUnplayed",
|
|
|
|
|
UserId: userId
|
|
|
|
|
};
|
|
|
|
|
|
2015-04-12 09:46:29 -07:00
|
|
|
|
return ApiClient.getJSON(ApiClient.getUrl("Channels/Items/Latest", options)).done(function (result) {
|
2014-06-15 16:30:04 -07:00
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
if (result.Items.length) {
|
|
|
|
|
html += '<h1 class="listHeader">' + Globalize.translate('HeaderLatestChannelMedia') + '</h1>';
|
2015-01-22 23:15:15 -07:00
|
|
|
|
html += '<div class="itemsContainer">';
|
2014-06-15 16:30:04 -07:00
|
|
|
|
html += LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
preferThumb: true,
|
2014-08-01 19:34:45 -07:00
|
|
|
|
shape: 'auto',
|
2014-06-15 16:30:04 -07:00
|
|
|
|
showTitle: true,
|
|
|
|
|
centerText: true,
|
2015-05-14 19:16:57 -07:00
|
|
|
|
lazy: true,
|
|
|
|
|
showDetailsMenu: true
|
2014-06-15 16:30:04 -07:00
|
|
|
|
});
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-22 23:15:15 -07:00
|
|
|
|
$(elem).html(html).lazyChildren();
|
|
|
|
|
$(elem).createCardMenus();
|
2014-06-15 16:30:04 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-24 18:14:24 -07:00
|
|
|
|
function loadLibraryTiles(elem, user, shape, index, autoHideOnMobile, showTitles) {
|
2014-05-21 12:33:46 -07:00
|
|
|
|
|
2015-04-12 09:46:29 -07:00
|
|
|
|
return getUserViews(user.Id).done(function (items) {
|
2014-05-21 12:33:46 -07:00
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
2015-05-06 22:12:13 -07:00
|
|
|
|
if (autoHideOnMobile) {
|
|
|
|
|
html += '<div class="hiddenSectionOnMobile">';
|
|
|
|
|
} else {
|
|
|
|
|
html += '<div>';
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-07 12:46:24 -07:00
|
|
|
|
if (items.length) {
|
2014-06-14 16:13:09 -07:00
|
|
|
|
|
2014-06-23 09:05:19 -07:00
|
|
|
|
var cssClass = index !== 0 ? 'listHeader' : 'listHeader firstListHeader';
|
2014-06-19 21:50:30 -07:00
|
|
|
|
|
2014-06-23 09:05:19 -07:00
|
|
|
|
html += '<div>';
|
2015-04-10 07:01:16 -07:00
|
|
|
|
html += '<h1 style="display:inline-block; vertical-align:middle;" class="' + cssClass + '">' + Globalize.translate('HeaderMyMedia') + '</h1>';
|
2015-03-24 18:14:24 -07:00
|
|
|
|
|
|
|
|
|
if (user.Policy.EnableUserPreferenceAccess) {
|
|
|
|
|
html += '<a href="mypreferencesdisplay.html" class="accentButton"><i class="fa fa-pencil"></i>' + Globalize.translate('ButtonEdit') + '</a>';
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-23 09:05:19 -07:00
|
|
|
|
html += '</div>';
|
2014-06-14 16:13:09 -07:00
|
|
|
|
|
2015-03-25 21:44:24 -07:00
|
|
|
|
html += '<div class="homeTopViews">';
|
2014-05-21 20:35:18 -07:00
|
|
|
|
html += LibraryBrowser.getPosterViewHtml({
|
2014-06-07 12:46:24 -07:00
|
|
|
|
items: items,
|
|
|
|
|
shape: shape,
|
2015-03-14 18:58:06 -07:00
|
|
|
|
showTitle: showTitles,
|
2014-05-29 21:16:31 -07:00
|
|
|
|
centerText: true,
|
2014-06-30 12:24:35 -07:00
|
|
|
|
lazy: true,
|
2015-04-19 08:54:20 -07:00
|
|
|
|
autoThumb: true
|
2014-05-21 20:35:18 -07:00
|
|
|
|
});
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-06 22:12:13 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
if (autoHideOnMobile) {
|
|
|
|
|
html += '<div class="hiddenSectionOnNonMobile" style="margin-top:1em;">';
|
|
|
|
|
html += getLibraryButtonsHtml(items);
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
2013-08-06 12:21:42 -07:00
|
|
|
|
|
2015-05-14 19:16:57 -07:00
|
|
|
|
$(elem).html(html).lazyChildren().createCardMenus({ showDetailsMenu: false });
|
2014-05-23 18:16:53 -07:00
|
|
|
|
|
|
|
|
|
handleLibraryLinkNavigations(elem);
|
2013-05-13 22:36:36 -07:00
|
|
|
|
});
|
2014-05-21 12:33:46 -07:00
|
|
|
|
}
|
2013-04-04 10:27:36 -07:00
|
|
|
|
|
2014-05-21 12:33:46 -07:00
|
|
|
|
function loadResume(elem, userId) {
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2014-05-21 12:33:46 -07:00
|
|
|
|
var screenWidth = $(window).width();
|
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
|
|
|
|
|
|
SortBy: "DatePlayed",
|
2014-05-01 19:54:33 -07:00
|
|
|
|
SortOrder: "Descending",
|
2014-05-21 12:33:46 -07:00
|
|
|
|
MediaTypes: "Video",
|
|
|
|
|
Filters: "IsResumable",
|
2014-08-11 07:15:53 -07:00
|
|
|
|
Limit: screenWidth >= 1920 ? 10 : (screenWidth >= 1600 ? 8 : (screenWidth >= 1200 ? 9 : 6)),
|
2014-05-01 19:54:33 -07:00
|
|
|
|
Recursive: true,
|
2014-12-10 23:20:28 -07:00
|
|
|
|
Fields: "PrimaryImageAspectRatio,SyncInfo",
|
2014-05-01 19:54:33 -07:00
|
|
|
|
CollapseBoxSetItems: false,
|
2015-01-27 15:45:59 -07:00
|
|
|
|
ExcludeLocationTypes: "Virtual",
|
|
|
|
|
ImageTypeLimit: 1,
|
|
|
|
|
EnableImageTypes: "Primary,Backdrop,Banner,Thumb"
|
2013-08-06 12:21:42 -07:00
|
|
|
|
};
|
|
|
|
|
|
2015-04-12 09:46:29 -07:00
|
|
|
|
return ApiClient.getItems(userId, options).done(function (result) {
|
2013-04-04 10:27:36 -07:00
|
|
|
|
|
2014-05-21 12:33:46 -07:00
|
|
|
|
var html = '';
|
2014-05-03 16:38:23 -07:00
|
|
|
|
|
2015-05-12 21:55:19 -07:00
|
|
|
|
var cardLayout = AppInfo.hasLowImageBandwidth;
|
|
|
|
|
|
2014-05-21 20:35:18 -07:00
|
|
|
|
if (result.Items.length) {
|
2014-06-07 12:46:24 -07:00
|
|
|
|
html += '<h1 class="listHeader">' + Globalize.translate('HeaderResume') + '</h1>';
|
2014-05-21 20:35:18 -07:00
|
|
|
|
html += '<div>';
|
|
|
|
|
html += LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
2015-02-25 11:11:49 -07:00
|
|
|
|
preferThumb: true,
|
2015-01-22 23:15:15 -07:00
|
|
|
|
shape: 'backdrop',
|
2015-05-12 21:55:19 -07:00
|
|
|
|
overlayText: screenWidth >= 800 && !cardLayout,
|
2014-05-21 20:35:18 -07:00
|
|
|
|
showTitle: true,
|
2014-05-29 12:34:20 -07:00
|
|
|
|
showParentTitle: true,
|
2014-05-29 21:16:31 -07:00
|
|
|
|
context: 'home',
|
2015-05-12 21:55:19 -07:00
|
|
|
|
lazy: true,
|
2015-05-14 19:16:57 -07:00
|
|
|
|
cardLayout: cardLayout,
|
|
|
|
|
showDetailsMenu: true
|
2014-05-21 20:35:18 -07:00
|
|
|
|
});
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
2013-04-04 10:27:36 -07:00
|
|
|
|
|
2015-01-22 23:15:15 -07:00
|
|
|
|
$(elem).html(html).lazyChildren();
|
2015-02-02 09:49:33 -07:00
|
|
|
|
$(elem).createCardMenus();
|
2013-04-04 10:27:36 -07:00
|
|
|
|
});
|
2014-05-21 12:33:46 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-23 09:05:19 -07:00
|
|
|
|
function handleLibraryLinkNavigations(elem) {
|
|
|
|
|
|
|
|
|
|
$('a.posterItem', elem).on('click', function () {
|
|
|
|
|
|
2015-02-03 11:14:53 -07:00
|
|
|
|
var textElem = $('.posterItemText span', this);
|
|
|
|
|
|
|
|
|
|
if (!textElem.length) {
|
|
|
|
|
textElem = $('.posterItemText', this);
|
|
|
|
|
}
|
|
|
|
|
var text = textElem.html();
|
2014-06-23 09:05:19 -07:00
|
|
|
|
|
|
|
|
|
LibraryMenu.setText(text);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadLatestChannelItems(elem, userId, options) {
|
|
|
|
|
|
|
|
|
|
options = $.extend(options || {}, {
|
|
|
|
|
|
|
|
|
|
UserId: userId,
|
|
|
|
|
SupportsLatestItems: true
|
|
|
|
|
});
|
|
|
|
|
|
2015-04-12 09:46:29 -07:00
|
|
|
|
return ApiClient.getJSON(ApiClient.getUrl("Channels", options)).done(function (result) {
|
2014-06-23 09:05:19 -07:00
|
|
|
|
|
|
|
|
|
var channels = result.Items;
|
|
|
|
|
|
|
|
|
|
var channelsHtml = channels.map(function (c) {
|
|
|
|
|
|
|
|
|
|
return '<div id="channel' + c.Id + '"></div>';
|
|
|
|
|
|
|
|
|
|
}).join('');
|
|
|
|
|
|
|
|
|
|
$(elem).html(channelsHtml);
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = channels.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var channel = channels[i];
|
|
|
|
|
|
|
|
|
|
loadLatestChannelItemsFromChannel(elem, channel, i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadLatestChannelItemsFromChannel(page, channel, index) {
|
|
|
|
|
|
|
|
|
|
var screenWidth = $(window).width();
|
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
|
|
2015-01-22 23:15:15 -07:00
|
|
|
|
Limit: screenWidth >= 1600 ? 10 : (screenWidth >= 1440 ? 5 : (screenWidth >= 800 ? 6 : 6)),
|
2014-12-10 23:20:28 -07:00
|
|
|
|
Fields: "PrimaryImageAspectRatio,SyncInfo",
|
2014-06-23 09:05:19 -07:00
|
|
|
|
Filters: "IsUnplayed",
|
|
|
|
|
UserId: Dashboard.getCurrentUserId(),
|
|
|
|
|
ChannelIds: channel.Id
|
|
|
|
|
};
|
|
|
|
|
|
2014-07-01 22:16:59 -07:00
|
|
|
|
ApiClient.getJSON(ApiClient.getUrl("Channels/Items/Latest", options)).done(function (result) {
|
2014-06-23 09:05:19 -07:00
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
if (result.Items.length) {
|
|
|
|
|
|
|
|
|
|
var cssClass = index !== 0 ? 'listHeader' : 'listHeader firstListHeader';
|
|
|
|
|
|
|
|
|
|
html += '<div>';
|
|
|
|
|
var text = Globalize.translate('HeaderLatestFromChannel').replace('{0}', channel.Name);
|
|
|
|
|
html += '<h1 style="display:inline-block; vertical-align:middle;" class="' + cssClass + '">' + text + '</h1>';
|
2015-01-22 23:15:15 -07:00
|
|
|
|
html += '<a href="channelitems.html?context=channels&id=' + channel.Id + '" data-role="button" data-icon="arrow-r" data-mini="true" data-inline="true" data-iconpos="notext" class="sectionHeaderButton"></a>';
|
2014-06-23 09:05:19 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
2015-01-22 23:15:15 -07:00
|
|
|
|
html += '<div class="itemsContainer">';
|
2014-06-23 09:05:19 -07:00
|
|
|
|
html += LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
2014-08-01 19:34:45 -07:00
|
|
|
|
shape: 'autohome',
|
2014-06-23 09:05:19 -07:00
|
|
|
|
defaultShape: 'square',
|
|
|
|
|
showTitle: true,
|
|
|
|
|
centerText: true,
|
|
|
|
|
context: 'channels',
|
2015-05-14 19:16:57 -07:00
|
|
|
|
lazy: true,
|
|
|
|
|
showDetailsMenu: true
|
2014-06-23 09:05:19 -07:00
|
|
|
|
});
|
2015-01-22 23:15:15 -07:00
|
|
|
|
html += '</div>';
|
2014-06-23 09:05:19 -07:00
|
|
|
|
|
2015-01-22 23:15:15 -07:00
|
|
|
|
var elem = $('#channel' + channel.Id + '', page).html(html).lazyChildren().trigger('create');
|
|
|
|
|
$(elem).createCardMenus();
|
2014-06-23 09:05:19 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadLatestLiveTvRecordings(elem, userId, index) {
|
|
|
|
|
|
2015-04-12 09:46:29 -07:00
|
|
|
|
return ApiClient.getLiveTvRecordings({
|
2014-06-23 09:05:19 -07:00
|
|
|
|
|
|
|
|
|
userId: userId,
|
2014-07-11 19:31:08 -07:00
|
|
|
|
limit: 5,
|
2014-06-23 09:05:19 -07:00
|
|
|
|
IsInProgress: false
|
|
|
|
|
|
|
|
|
|
}).done(function (result) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
if (result.Items.length) {
|
|
|
|
|
|
|
|
|
|
var cssClass = index !== 0 ? 'listHeader' : 'listHeader firstListHeader';
|
|
|
|
|
|
|
|
|
|
html += '<div>';
|
|
|
|
|
html += '<h1 style="display:inline-block; vertical-align:middle;" class="' + cssClass + '">' + Globalize.translate('HeaderLatestTvRecordings') + '</h1>';
|
2015-02-04 20:01:37 -07:00
|
|
|
|
html += '<a href="livetvrecordings.html?context=livetv" data-role="button" data-icon="arrow-r" data-mini="true" data-inline="true" data-iconpos="notext" class="sectionHeaderButton"></a>';
|
2014-06-23 09:05:19 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var screenWidth = $(window).width();
|
|
|
|
|
|
|
|
|
|
html += LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
2014-08-01 19:34:45 -07:00
|
|
|
|
shape: "autohome",
|
2014-06-23 09:05:19 -07:00
|
|
|
|
showTitle: true,
|
|
|
|
|
showParentTitle: true,
|
|
|
|
|
overlayText: screenWidth >= 600,
|
|
|
|
|
coverImage: true,
|
2015-05-14 19:16:57 -07:00
|
|
|
|
lazy: true,
|
|
|
|
|
showDetailsMenu: true
|
2014-06-23 09:05:19 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-02-04 20:01:37 -07:00
|
|
|
|
elem.html(html).lazyChildren().trigger('create');
|
2014-06-23 09:05:19 -07:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.Sections = {
|
|
|
|
|
loadRecentlyAdded: loadRecentlyAdded,
|
|
|
|
|
loadLatestChannelMedia: loadLatestChannelMedia,
|
|
|
|
|
loadLibraryTiles: loadLibraryTiles,
|
|
|
|
|
loadResume: loadResume,
|
|
|
|
|
loadLatestChannelItems: loadLatestChannelItems,
|
2014-06-24 14:45:21 -07:00
|
|
|
|
loadLatestLiveTvRecordings: loadLatestLiveTvRecordings,
|
|
|
|
|
loadlibraryButtons: loadlibraryButtons
|
2014-06-23 09:05:19 -07:00
|
|
|
|
};
|
|
|
|
|
|
2014-10-25 11:32:58 -07:00
|
|
|
|
})(jQuery, document);
|
2014-06-23 09:05:19 -07:00
|
|
|
|
|
2014-10-15 20:26:39 -07:00
|
|
|
|
(function ($, document) {
|
2014-06-23 09:05:19 -07:00
|
|
|
|
|
2015-04-14 20:41:29 -07:00
|
|
|
|
var defaultFirstSection = 'smalllibrarytiles-automobile';
|
|
|
|
|
|
2014-06-23 09:05:19 -07:00
|
|
|
|
function getDefaultSection(index) {
|
|
|
|
|
|
|
|
|
|
switch (index) {
|
|
|
|
|
|
|
|
|
|
case 0:
|
2015-04-14 20:41:29 -07:00
|
|
|
|
return defaultFirstSection;
|
2014-06-23 09:05:19 -07:00
|
|
|
|
case 1:
|
|
|
|
|
return 'resume';
|
|
|
|
|
case 2:
|
2014-07-11 19:31:08 -07:00
|
|
|
|
return 'latestmedia';
|
2014-06-23 09:05:19 -07:00
|
|
|
|
case 3:
|
|
|
|
|
return '';
|
|
|
|
|
default:
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-24 18:14:24 -07:00
|
|
|
|
function loadSection(page, user, displayPreferences, index) {
|
|
|
|
|
|
|
|
|
|
var userId = user.Id;
|
2014-05-21 12:33:46 -07:00
|
|
|
|
|
|
|
|
|
var section = displayPreferences.CustomPrefs['home' + index] || getDefaultSection(index);
|
|
|
|
|
|
2015-04-11 14:34:05 -07:00
|
|
|
|
if (section == 'folders') {
|
2015-04-14 20:41:29 -07:00
|
|
|
|
section = defaultFirstSection;
|
2015-04-11 14:34:05 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-14 18:58:06 -07:00
|
|
|
|
var showLibraryTileNames = displayPreferences.CustomPrefs.enableLibraryTileNames != '0';
|
|
|
|
|
|
2014-05-21 12:33:46 -07:00
|
|
|
|
var elem = $('.section' + index, page);
|
2014-06-19 21:50:30 -07:00
|
|
|
|
|
2014-05-21 12:33:46 -07:00
|
|
|
|
if (section == 'latestmedia') {
|
2015-04-12 09:46:29 -07:00
|
|
|
|
return Sections.loadRecentlyAdded(elem, user);
|
2014-05-21 12:33:46 -07:00
|
|
|
|
}
|
|
|
|
|
else if (section == 'librarytiles') {
|
2015-04-12 09:46:29 -07:00
|
|
|
|
return Sections.loadLibraryTiles(elem, user, 'backdrop', index, false, showLibraryTileNames);
|
2014-06-07 12:46:24 -07:00
|
|
|
|
}
|
2014-06-24 14:45:21 -07:00
|
|
|
|
else if (section == 'smalllibrarytiles') {
|
2015-04-12 09:46:29 -07:00
|
|
|
|
return Sections.loadLibraryTiles(elem, user, 'homePageSmallBackdrop', index, false, showLibraryTileNames);
|
2014-07-11 19:31:08 -07:00
|
|
|
|
}
|
|
|
|
|
else if (section == 'smalllibrarytiles-automobile') {
|
2015-04-12 09:46:29 -07:00
|
|
|
|
return Sections.loadLibraryTiles(elem, user, 'homePageSmallBackdrop', index, true, showLibraryTileNames);
|
2015-03-13 21:50:23 -07:00
|
|
|
|
}
|
|
|
|
|
else if (section == 'librarytiles-automobile') {
|
2015-04-12 09:46:29 -07:00
|
|
|
|
return Sections.loadLibraryTiles(elem, user, 'backdrop', index, true, showLibraryTileNames);
|
2014-05-21 12:33:46 -07:00
|
|
|
|
}
|
2014-06-24 14:45:21 -07:00
|
|
|
|
else if (section == 'librarybuttons') {
|
2015-04-12 09:46:29 -07:00
|
|
|
|
return Sections.loadlibraryButtons(elem, userId, index);
|
2014-06-24 14:45:21 -07:00
|
|
|
|
}
|
2014-05-21 12:33:46 -07:00
|
|
|
|
else if (section == 'resume') {
|
2015-04-12 09:46:29 -07:00
|
|
|
|
return Sections.loadResume(elem, userId);
|
2014-06-23 09:05:19 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (section == 'latesttvrecordings') {
|
2015-04-12 09:46:29 -07:00
|
|
|
|
return Sections.loadLatestLiveTvRecordings(elem, userId);
|
2014-05-21 12:33:46 -07:00
|
|
|
|
}
|
2015-04-11 14:34:05 -07:00
|
|
|
|
else if (section == 'latestchannelmedia') {
|
2015-04-12 09:46:29 -07:00
|
|
|
|
return Sections.loadLatestChannelMedia(elem, userId);
|
2014-06-15 16:30:04 -07:00
|
|
|
|
|
2014-05-21 20:35:18 -07:00
|
|
|
|
} else {
|
2014-05-23 18:16:53 -07:00
|
|
|
|
|
2014-05-21 20:35:18 -07:00
|
|
|
|
elem.empty();
|
2015-04-12 09:46:29 -07:00
|
|
|
|
|
|
|
|
|
var deferred = DeferredBuilder.Deferred();
|
|
|
|
|
deferred.resolve();
|
|
|
|
|
return deferred.promise();
|
2014-05-21 12:33:46 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-24 18:14:24 -07:00
|
|
|
|
function loadSections(page, user, displayPreferences) {
|
2014-05-21 12:33:46 -07:00
|
|
|
|
|
|
|
|
|
var i, length;
|
2014-06-15 16:30:04 -07:00
|
|
|
|
var sectionCount = 4;
|
2014-05-21 12:33:46 -07:00
|
|
|
|
|
2014-05-21 20:35:18 -07:00
|
|
|
|
var elem = $('.sections', page);
|
2014-05-23 18:16:53 -07:00
|
|
|
|
|
2014-05-21 20:35:18 -07:00
|
|
|
|
if (!elem.html().length) {
|
|
|
|
|
var html = '';
|
|
|
|
|
for (i = 0, length = sectionCount; i < length; i++) {
|
2014-05-21 12:33:46 -07:00
|
|
|
|
|
2014-05-21 20:35:18 -07:00
|
|
|
|
html += '<div class="homePageSection section' + i + '"></div>';
|
|
|
|
|
}
|
2014-05-21 12:33:46 -07:00
|
|
|
|
|
2014-05-21 20:35:18 -07:00
|
|
|
|
elem.html(html);
|
|
|
|
|
}
|
2014-05-21 12:33:46 -07:00
|
|
|
|
|
2015-04-12 09:46:29 -07:00
|
|
|
|
var promises = [];
|
|
|
|
|
|
2014-05-21 12:33:46 -07:00
|
|
|
|
for (i = 0, length = sectionCount; i < length; i++) {
|
|
|
|
|
|
2015-04-12 09:46:29 -07:00
|
|
|
|
promises.push(loadSection(page, user, displayPreferences, i));
|
2014-05-21 12:33:46 -07:00
|
|
|
|
}
|
2015-04-12 09:46:29 -07:00
|
|
|
|
|
|
|
|
|
return $.when(promises);
|
2014-05-21 12:33:46 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-20 11:04:02 -07:00
|
|
|
|
var homePageDismissValue = '14';
|
2014-09-25 20:47:46 -07:00
|
|
|
|
var homePageTourKey = 'homePageTour';
|
2014-06-07 12:46:24 -07:00
|
|
|
|
|
2014-05-30 14:06:57 -07:00
|
|
|
|
function dismissWelcome(page, userId) {
|
|
|
|
|
|
2015-05-12 21:55:19 -07:00
|
|
|
|
getDisplayPreferences('home', userId).done(function (result) {
|
2014-05-30 14:06:57 -07:00
|
|
|
|
|
2014-09-25 20:47:46 -07:00
|
|
|
|
result.CustomPrefs[homePageTourKey] = homePageDismissValue;
|
2015-05-12 21:55:19 -07:00
|
|
|
|
ApiClient.updateDisplayPreferences('home', result, userId, getDisplayPreferencesAppName());
|
2014-09-25 20:47:46 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
2014-06-07 12:46:24 -07:00
|
|
|
|
|
2015-01-11 11:36:26 -07:00
|
|
|
|
function showWelcomeIfNeeded(page, displayPreferences) {
|
|
|
|
|
|
|
|
|
|
if (displayPreferences.CustomPrefs[homePageTourKey] == homePageDismissValue) {
|
|
|
|
|
$('.welcomeMessage', page).hide();
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
var elem = $('.welcomeMessage', page).show();
|
|
|
|
|
|
|
|
|
|
if (displayPreferences.CustomPrefs[homePageTourKey]) {
|
|
|
|
|
|
|
|
|
|
$('.tourHeader', elem).html(Globalize.translate('HeaderWelcomeBack'));
|
|
|
|
|
$('.tourButtonText', elem).html(Globalize.translate('ButtonTakeTheTourToSeeWhatsNew'));
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
2015-03-21 11:12:12 -07:00
|
|
|
|
$('.tourHeader', elem).html(Globalize.translate('HeaderWelcomeToProjectWebClient'));
|
2015-01-11 11:36:26 -07:00
|
|
|
|
$('.tourButtonText', elem).html(Globalize.translate('ButtonTakeTheTour'));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-10-04 11:05:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-25 20:47:46 -07:00
|
|
|
|
function takeTour(page, userId) {
|
|
|
|
|
|
2015-05-08 20:48:43 -07:00
|
|
|
|
Dashboard.loadSwipebox().done(function () {
|
|
|
|
|
|
|
|
|
|
$.swipebox([
|
|
|
|
|
{ href: 'css/images/tour/web/tourcontent.jpg', title: Globalize.translate('WebClientTourContent') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourmovies.jpg', title: Globalize.translate('WebClientTourMovies') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourmouseover.jpg', title: Globalize.translate('WebClientTourMouseOver') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourtaphold.jpg', title: Globalize.translate('WebClientTourTapHold') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourmysync.png', title: Globalize.translate('WebClientTourMySync') },
|
|
|
|
|
{ href: 'css/images/tour/web/toureditor.png', title: Globalize.translate('WebClientTourMetadataManager') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourplaylist.png', title: Globalize.translate('WebClientTourPlaylists') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourcollections.jpg', title: Globalize.translate('WebClientTourCollections') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourusersettings1.png', title: Globalize.translate('WebClientTourUserPreferences1') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourusersettings2.png', title: Globalize.translate('WebClientTourUserPreferences2') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourusersettings3.png', title: Globalize.translate('WebClientTourUserPreferences3') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourusersettings4.png', title: Globalize.translate('WebClientTourUserPreferences4') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourmobile1.jpg', title: Globalize.translate('WebClientTourMobile1') },
|
|
|
|
|
{ href: 'css/images/tour/web/tourmobile2.png', title: Globalize.translate('WebClientTourMobile2') },
|
|
|
|
|
{ href: 'css/images/tour/enjoy.jpg', title: Globalize.translate('MessageEnjoyYourStay') }
|
|
|
|
|
], {
|
|
|
|
|
afterClose: function () {
|
|
|
|
|
dismissWelcome(page, userId);
|
|
|
|
|
$('.welcomeMessage', page).hide();
|
|
|
|
|
|
|
|
|
|
loadConfigureViewsWelcomeMessage(page, userId);
|
|
|
|
|
},
|
|
|
|
|
hideBarsDelay: 30000
|
|
|
|
|
});
|
2014-05-30 14:06:57 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-12 09:46:29 -07:00
|
|
|
|
function loadConfigureViewsWelcomeMessage(page, userId) {
|
|
|
|
|
|
2015-04-20 11:04:02 -07:00
|
|
|
|
Dashboard.getCurrentUser().done(function (user) {
|
2015-04-12 09:46:29 -07:00
|
|
|
|
|
2015-04-20 11:04:02 -07:00
|
|
|
|
if (user.Policy.EnableUserPreferenceAccess) {
|
|
|
|
|
$('.btnMyPreferences', page).attr('href', 'mypreferencesdisplay.html?userId=' + userId);
|
2015-04-12 09:46:29 -07:00
|
|
|
|
|
2015-04-20 11:04:02 -07:00
|
|
|
|
// Need the timeout because previous methods in the chain have popups that will be in the act of closing
|
|
|
|
|
setTimeout(function () {
|
2015-04-12 09:46:29 -07:00
|
|
|
|
|
2015-04-20 11:04:02 -07:00
|
|
|
|
$('.popupConfigureViews', page).popup('open');
|
|
|
|
|
|
|
|
|
|
}, 500);
|
|
|
|
|
}
|
|
|
|
|
});
|
2015-04-12 09:46:29 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-30 14:06:57 -07:00
|
|
|
|
$(document).on('pageinit', "#indexPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
var userId = Dashboard.getCurrentUserId();
|
|
|
|
|
|
2014-10-04 11:05:24 -07:00
|
|
|
|
$('.btnTakeTour', page).on('click', function () {
|
2014-09-25 20:47:46 -07:00
|
|
|
|
takeTour(page, userId);
|
2014-05-30 14:06:57 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}).on('pagebeforeshow', "#indexPage", function () {
|
2014-05-21 12:33:46 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
var userId = Dashboard.getCurrentUserId();
|
|
|
|
|
|
2015-05-12 21:55:19 -07:00
|
|
|
|
getDisplayPreferences('home', userId).done(function (result) {
|
2014-05-21 12:33:46 -07:00
|
|
|
|
|
2015-03-24 18:14:24 -07:00
|
|
|
|
Dashboard.getCurrentUser().done(function (user) {
|
|
|
|
|
|
2015-04-12 09:46:29 -07:00
|
|
|
|
loadSections(page, user, result).done(function () {
|
|
|
|
|
showWelcomeIfNeeded(page, result);
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-24 18:14:24 -07:00
|
|
|
|
});
|
2014-05-21 12:33:46 -07:00
|
|
|
|
});
|
|
|
|
|
|
2013-07-23 05:29:28 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-05-12 21:55:19 -07:00
|
|
|
|
function getDisplayPreferencesAppName() {
|
2015-05-14 19:16:57 -07:00
|
|
|
|
|
2015-05-12 21:55:19 -07:00
|
|
|
|
if (Dashboard.isRunningInCordova()) {
|
|
|
|
|
return 'Emby Mobile';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 'webclient';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getDisplayPreferences(key, userId) {
|
|
|
|
|
|
|
|
|
|
return ApiClient.getDisplayPreferences(key, userId, getDisplayPreferencesAppName()).done(function (result) {
|
2015-05-14 19:16:57 -07:00
|
|
|
|
|
2015-05-12 21:55:19 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-25 11:32:58 -07:00
|
|
|
|
})(jQuery, document);
|