diff --git a/dashboard-ui/boxset.html b/dashboard-ui/boxset.html index 755f822ea..9d5c623c1 100644 --- a/dashboard-ui/boxset.html +++ b/dashboard-ui/boxset.html @@ -1,11 +1,40 @@  - - + - - + +
+
+

+

+ +
+
+
+
+
+
+ +
+ +

+

+

+

+ +

+

+ +

+

+

+

+
+
+ +
+
- \ No newline at end of file + diff --git a/dashboard-ui/css/images/media/language.png b/dashboard-ui/css/images/media/language.png new file mode 100644 index 000000000..7a44d41ce Binary files /dev/null and b/dashboard-ui/css/images/media/language.png differ diff --git a/dashboard-ui/css/images/media/quality.png b/dashboard-ui/css/images/media/quality.png index b52641fcb..6312637ec 100644 Binary files a/dashboard-ui/css/images/media/quality.png and b/dashboard-ui/css/images/media/quality.png differ diff --git a/dashboard-ui/css/site.css b/dashboard-ui/css/site.css index 128d6930b..d6ec7afc3 100644 --- a/dashboard-ui/css/site.css +++ b/dashboard-ui/css/site.css @@ -832,8 +832,10 @@ progress { width: auto !important; } -.vjs-quality-button div { - background: red !important; +.vjs-default-skin .vjs-menu-button.vjs-quality-button div { + background: url("images/media/quality.png"); + height: 16px; + width: 16px; } .vjs-chapter-button div { @@ -867,7 +869,7 @@ progress { } .vjs-subtitle-button div { - background: green !important; + background-position: -25px -75px !important; } .vjs-subtitle-button.vjs-menu-button ul { @@ -883,8 +885,10 @@ progress { padding-right: 10px; } -.vjs-language-button div { - background: yellow !important; +.vjs-default-skin .vjs-menu-button.vjs-language-button div { + background: url("images/media/language.png") !important; + height: 16px; + width: 16px; } .vjs-language-button.vjs-menu-button ul { diff --git a/dashboard-ui/scripts/boxset.js b/dashboard-ui/scripts/boxset.js index 5f282702b..1bdf5c88a 100644 --- a/dashboard-ui/scripts/boxset.js +++ b/dashboard-ui/scripts/boxset.js @@ -1 +1,351 @@ - \ No newline at end of file +var BoxsetPage = { + + onPageShow: function () { + + BoxsetPage.reload(); + }, + + onPageHide: function () { + + BoxsetPage.item = null; + }, + + reload: function () { + var id = getParameterByName('id'); + + Dashboard.showLoadingMsg(); + + ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(BoxsetPage.renderItem); + }, + + renderItem: function (item) { + + BoxsetPage.item = item; + + var page = $.mobile.activePage; + + BoxsetPage.item = item; + + var name = item.Name; + + if (item.IndexNumber != null) { + name = item.IndexNumber + " - " + name; + } + if (item.ParentIndexNumber != null) { + name = item.ParentIndexNumber + "." + name; + } + + Dashboard.setPageTitle(name); + + BoxsetPage.renderImage(item); + BoxsetPage.renderOverviewBlock(item); + + $('#itemName', page).html(name); + + if (item.SeriesName || item.Album) { + var series_name = item.SeriesName || item.Album; + $('#seriesName', page).html(series_name).show(); + } + + BoxsetPage.renderFav(item); + + Dashboard.hideLoadingMsg(); + }, + + renderImage: function (item) { + + var page = $.mobile.activePage; + + var imageTags = item.ImageTags || {}; + + var html = ''; + + var url; + var useBackgroundColor; + + if (imageTags.Primary) { + + url = ApiClient.getImageUrl(item.Id, { + type: "Primary", + width: 800, + tag: item.ImageTags.Primary + }); + } + else if (item.BackdropImageTags && item.BackdropImageTags.length) { + + url = ApiClient.getImageUrl(item.Id, { + type: "Backdrop", + width: 800, + tag: item.BackdropImageTags[0] + }); + } + else if (imageTags.Thumb) { + + url = ApiClient.getImageUrl(item.Id, { + type: "Thumb", + width: 800, + tag: item.ImageTags.Thumb + }); + } + else if (imageTags.Disc) { + + url = ApiClient.getImageUrl(item.Id, { + type: "Disc", + width: 800, + tag: item.ImageTags.Disc + }); + } + else if (item.MediaType == "Audio") { + url = "css/images/items/detail/audio.png"; + useBackgroundColor = true; + } + else if (item.MediaType == "Game") { + url = "css/images/items/detail/game.png"; + useBackgroundColor = true; + } + else { + url = "css/images/items/detail/video.png"; + useBackgroundColor = true; + } + + if (url) { + + var style = useBackgroundColor ? "background-color:" + LibraryBrowser.getMetroColor(item.Id) + ";" : ""; + + html += ""; + } + + $('#itemImage', page).html(html); + }, + + renderOverviewBlock: function (item) { + + var page = $.mobile.activePage; + + if (item.Taglines && item.Taglines.length) { + $('#itemTagline', page).html(item.Taglines[0]).show(); + } else { + $('#itemTagline', page).hide(); + } + + if (item.Overview || item.OverviewHtml) { + var overview = item.OverviewHtml || item.Overview; + + $('#itemOverview', page).html(overview).show(); + $('#itemOverview a').each(function () { + $(this).attr("target", "_blank"); + }); + } else { + $('#itemOverview', page).hide(); + } + + if (item.CommunityRating) { + $('#itemCommunityRating', page).html(BoxsetPage.getStarRating(item)).show().attr('title', item.CommunityRating); + } else { + $('#itemCommunityRating', page).hide(); + } + + var miscInfo = []; + + if (item.ProductionYear) { + miscInfo.push(item.ProductionYear); + } + + if (item.OfficialRating) { + miscInfo.push(item.OfficialRating); + } + + if (item.RunTimeTicks) { + + var minutes = item.RunTimeTicks / 600000000; + + minutes = minutes || 1; + + miscInfo.push(parseInt(minutes) + "min"); + } + + if (item.DisplayMediaType) { + miscInfo.push(item.DisplayMediaType); + } + + if (item.VideoFormat && item.VideoFormat !== 'Standard') { + miscInfo.push(item.VideoFormat); + } + + $('#itemMiscInfo', page).html(miscInfo.join('     ')); + + BoxsetPage.renderGenres(item); + BoxsetPage.renderStudios(item); + }, + + renderGenres: function (item) { + + var page = $.mobile.activePage; + + if (item.Genres && item.Genres.length) { + var elem = $('#itemGenres', page).show(); + + var html = 'Genres:  '; + + for (var i = 0, length = item.Genres.length; i < length; i++) { + + if (i > 0) { + html += '  /  '; + } + + html += '' + item.Genres[i] + ''; + } + + elem.html(html).trigger('create'); + + + } else { + $('#itemGenres', page).hide(); + } + }, + + renderStudios: function (item) { + + var page = $.mobile.activePage; + + if (item.Studios && item.Studios.length) { + var elem = $('#itemStudios', page).show(); + + var html = 'Studios:  '; + + for (var i = 0, length = item.Studios.length; i < length; i++) { + + if (i > 0) { + html += '  /  '; + } + + html += '' + item.Studios[i] + ''; + } + + elem.html(html).trigger('create'); + + + } else { + $('#itemStudios', page).hide(); + } + }, + + getStarRating: function (item) { + var rating = item.CommunityRating; + + var html = ""; + for (var i = 1; i <= 10; i++) { + if (rating < i - 1) { + html += "
"; + } + else if (rating < i) { + html += "
"; + } + else { + html += "
"; + } + } + + return html; + }, + + renderFav: function (item) { + var html = ''; + var page = $.mobile.activePage; + + var userData = item.UserData || {}; + + if (typeof userData.Likes == "undefined") { + html += '
Dislike
'; + html += '
Like
'; + } else if (userData.Likes) { + html += '
Dislike
'; + html += '
Liked
'; + } else { + html += '
Dislike
'; + html += '
Like
'; + } + + if (userData.IsFavorite) { + html += '
Favorite
'; + } else { + html += '
Favorite
'; + } + + //played/unplayed + if (userData.Played) { + html += '
Played
'; + } else { + html += '
Unplayed
'; + } + + $('#itemRatings', page).html(html); + }, + + setFavorite: function () { + var item = BoxsetPage.item; + + item.UserData = item.UserData || {}; + + var setting = !item.UserData.IsFavorite; + item.UserData.IsFavorite = setting; + + ApiClient.updateFavoriteStatus(Dashboard.getCurrentUserId(), item.Id, setting); + + BoxsetPage.renderFav(item); + }, + + setLike: function () { + + var item = BoxsetPage.item; + + item.UserData = item.UserData || {}; + + item.UserData.Likes = true; + + ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), item.Id, true); + + BoxsetPage.renderFav(item); + }, + + clearLike: function () { + + var item = BoxsetPage.item; + + item.UserData = item.UserData || {}; + + item.UserData.Likes = undefined; + + ApiClient.clearUserItemRating(Dashboard.getCurrentUserId(), item.Id); + + BoxsetPage.renderFav(item); + }, + + setDislike: function () { + var item = BoxsetPage.item; + + item.UserData = item.UserData || {}; + + item.UserData.Likes = false; + + ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), item.Id, false); + + BoxsetPage.renderFav(item); + }, + + setPlayed: function () { + var item = BoxsetPage.item; + + item.UserData = item.UserData || {}; + + var setting = !item.UserData.Played; + item.UserData.Played = setting; + + ApiClient.updatePlayedStatus(Dashboard.getCurrentUserId(), item.Id, setting); + + BoxsetPage.renderFav(item); + } + +}; + +$(document).on('pageshow', "#boxsetPage", BoxsetPage.onPageShow).on('pagehide', "#boxsetPage", BoxsetPage.onPageHide); diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index 29f4cdec4..eeb3c9192 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -161,7 +161,7 @@ var hasPrimaryImage = item.ImageTags && item.ImageTags.Primary; - var href = item.url || (item.IsFolder ? (item.Id ? "itemList.html?parentId=" + item.Id : "#") : "itemdetails.html?id=" + item.Id); + var href = item.url || ("boxset.html?id=" + item.Id); var showText = options.showTitle || !hasPrimaryImage || (item.Type !== 'Movie' && item.Type !== 'Series' && item.Type !== 'Season' && item.Type !== 'Trailer'); @@ -257,8 +257,12 @@ getMetroColor: function (str) { if (str) { - var char = str.substr(0, 1).charCodeAt(); - var index = String(char).substr(char.length, 1); + var char = String(str.substr(0, 1).charCodeAt()); + var sum = 0; + for (var i = 0; i < char.length; i++) { + sum += parseInt(char.charAt(i)); + } + var index = String(sum).substr(-1); return LibraryBrowser.metroColors[index]; } else { diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index f05ba46d1..c03afad62 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -179,6 +179,37 @@ var screenHeight = Math.min(screen.height, screen.width); var volume = localStorage.getItem("volume") || 0.5; + var user = Dashboard.getCurrentUser(); + var defaults = {languageIndex: null, subtitleIndex: null}; + + var user_config = user.Configuration || {}; + if (item.MediaStreams && item.MediaStreams.length) { + $.each(item.MediaStreams, function (i, stream) { + //get default subtitle stream + if (stream.Type == "Subtitle") { + if (user_config.UseForcedSubtitlesOnly == true && user_config.SubtitleLanguagePreference && !defaults.subtitleIndex) { + if (stream.Language == user_config.SubtitleLanguagePreference && stream.IsForced == true) { + defaults.subtitleIndex = i; + } + }else if (user_config.SubtitleLanguagePreference && !defaults.subtitleIndex) { + if (stream.Language == user_config.SubtitleLanguagePreference) { + defaults.subtitleIndex = i; + } + }else if (user_config.UseForcedSubtitlesOnly == true && !defaults.subtitleIndex) { + if (stream.IsForced == true) { + defaults.subtitleIndex = i; + } + } + }else if (stream.Type == "Audio") { + //get default language stream + if (user_config.AudioLanguagePreference && !defaults.languageIndex) { + if (stream.Language == user_config.AudioLanguagePreference) { + defaults.languageIndex = i; + } + } + } + }); + } var baseParams = { audioChannels: 2, @@ -186,7 +217,9 @@ videoBitrate: 1500000, maxWidth: screenWidth, maxHeight: screenHeight, - StartTimeTicks: 0 + StartTimeTicks: 0, + SubtitleStreamIndex: null, + AudioStreamIndex: null }; if (typeof (startPosition) != "undefined") { @@ -235,7 +268,7 @@ { type: "video/ogg", src: ogvVideoUrl }] ).volume(volume); - videoJSextension.setup_video($('#videoWindow'), item); + videoJSextension.setup_video($('#videoWindow'), item, defaults); (this).addEvent("loadstart", function () { $(".vjs-remaining-time-display").hide(); @@ -276,7 +309,7 @@ ApiClient.reportPlaybackStopped(Dashboard.getCurrentUserId(), item_id, positionTicks); - clearTimeout(progressInterval); + clearTimeout(MediaPlayer.progressInterval); if (player.techName == "html5") { player.tag.src = ""; @@ -302,7 +335,7 @@ }, updateProgress: function () { - progressInterval = setInterval(function () { + MediaPlayer.progressInterval = setInterval(function () { var player = _V_("videoWindow"); var startTimeTicks = player.tag.src.match(new RegExp("StartTimeTicks=[0-9]+", "g")); diff --git a/dashboard-ui/scripts/tvshows.js b/dashboard-ui/scripts/tvshows.js index 5f282702b..03152e8b1 100644 --- a/dashboard-ui/scripts/tvshows.js +++ b/dashboard-ui/scripts/tvshows.js @@ -1 +1,157 @@ - \ No newline at end of file +(function ($, document) { + + // The base query options + var query = { + + SortBy: "SortName", + SortOrder: "Ascending", + IncludeItemTypes: "Episode", + Recursive: true, + Fields: "PrimaryImageAspectRatio,SeriesInfo" + }; + + function getTableHtml(items) { + + var html = '
'; + + html += ''; + + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + + html += ''; + + html += ''; + + for (var i = 0, length = items.length; i < length; i++) { + + html += getRowHtml(items[i]); + } + + html += ''; + + html += '
 NameYearOfficial RatingRuntimeCommunity Rating
'; + + return html; + } + + function getRowHtml(item) { + + var html = ''; + + html += ''; + + var url = "itemdetails.html?id=" + item.Id; + + var imageTags = item.ImageTags; + + html += ''; + + if (imageTags.Primary) { + + html += ''; + + } + else { + html += ''; + } + + html += ''; + + html += '' + item.Name + ''; + + html += '' + (item.ProductionYear || "") + ''; + + html += '' + (item.OfficialRating || "") + ''; + html += '' + (item.RunTimeTicks || "") + ''; + html += '' + (item.CommunityRating || "") + ''; + + html += ''; + return html; + } + + function reloadItems(page) { + + Dashboard.showLoadingMsg(); + + ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) { + + $('#items', page).html(LibraryBrowser.getEpisodePosterViewHtml({ + + items: result.Items, + useAverageAspectRatio: true + + }))/*.html(getTableHtml(result.Items)).trigger('create')*/; + + Dashboard.hideLoadingMsg(); + }); + } + + $(document).on('pageinit', "#tvShowsPage", function () { + + var page = this; + + $('.radioSortBy', this).on('click', function () { + query.SortBy = this.getAttribute('data-sortby'); + reloadItems(page); + }); + + $('.radioSortOrder', this).on('click', function () { + query.SortOrder = this.getAttribute('data-sortorder'); + reloadItems(page); + }); + + $('.chkStandardFilter', this).on('change', function () { + + var filterName = this.getAttribute('data-filter'); + var filters = query.Filters || ""; + + filters = (',' + filters).replace(',' + filterName, '').substring(1); + + if (this.checked) { + filters = filters ? (filters + ',' + filterName) : filterName; + } + + query.Filters = filters; + + reloadItems(page); + }); + + }).on('pageshow', "#tvShowsPage", function () { + + reloadItems(this); + + // Reset form values using the last used query + $('.radioSortBy', this).each(function () { + + this.checked = query.SortBy == this.getAttribute('data-sortby'); + + }).checkboxradio('refresh'); + + $('.radioSortOrder', this).each(function () { + + this.checked = query.SortOrder == this.getAttribute('data-sortorder'); + + }).checkboxradio('refresh'); + + $('.chkStandardFilter', this).each(function () { + + var filters = "," + (query.Filters || ""); + var filterName = this.getAttribute('data-filter'); + + this.checked = filters.indexOf(',' + filterName) != -1; + + }).checkboxradio('refresh'); + }); + +})(jQuery, document); \ No newline at end of file diff --git a/dashboard-ui/scripts/videojsextensions.js b/dashboard-ui/scripts/videojsextensions.js index 2c0437590..314c16dab 100644 --- a/dashboard-ui/scripts/videojsextensions.js +++ b/dashboard-ui/scripts/videojsextensions.js @@ -6,7 +6,7 @@ var videoJSextension = { a mandatory jQuery object of the