From af8d421a8c33962da3640a7f4a74726048904b95 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 00:56:51 +0300 Subject: [PATCH 01/24] autobackdrops.js --- src/scripts/autobackdrops.js | 77 +++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 27 deletions(-) diff --git a/src/scripts/autobackdrops.js b/src/scripts/autobackdrops.js index 8cce154a19..73042f83ce 100644 --- a/src/scripts/autobackdrops.js +++ b/src/scripts/autobackdrops.js @@ -1,53 +1,76 @@ -define(["backdrop", "userSettings", "libraryMenu"], function(backdrop, userSettings, libraryMenu) { +define(["backdrop", "userSettings", "libraryMenu"], function (backdrop, userSettings, libraryMenu) { "use strict"; function enabled() { - return userSettings.enableBackdrops() + return userSettings.enableBackdrops(); } function getBackdropItemIds(apiClient, userId, types, parentId) { - var key = "backdrops2_" + userId + (types || "") + (parentId || ""), - data = cache[key]; - if (data) return console.log("Found backdrop id list in cache. Key: " + key), data = JSON.parse(data), Promise.resolve(data); + var key = "backdrops2_" + userId + (types || "") + (parentId || ""); + var data = cache[key]; + + if (data) { + console.log("Found backdrop id list in cache. Key: " + key); + data = JSON.parse(data); + return Promise.resolve(data); + } + var options = { SortBy: "IsFavoriteOrLiked,Random", Limit: 20, - Recursive: !0, + Recursive: true, IncludeItemTypes: types, ImageTypes: "Backdrop", ParentId: parentId, - EnableTotalRecordCount: !1 + EnableTotalRecordCount: false }; - return apiClient.getItems(apiClient.getCurrentUserId(), options).then(function(result) { - var images = result.Items.map(function(i) { + return apiClient.getItems(apiClient.getCurrentUserId(), options).then(function (result) { + var images = result.Items.map(function (i) { return { Id: i.Id, tag: i.BackdropImageTags[0], ServerId: i.ServerId - } + }; }); - return cache[key] = JSON.stringify(images), images - }) + cache[key] = JSON.stringify(images); + return images; + }); } function showBackdrop(type, parentId) { var apiClient = window.ApiClient; - apiClient && getBackdropItemIds(apiClient, apiClient.getCurrentUserId(), type, parentId).then(function(images) { - images.length ? backdrop.setBackdrops(images.map(function(i) { - return i.BackdropImageTags = [i.tag], i - })) : backdrop.clear() - }) + + if (apiClient) { + getBackdropItemIds(apiClient, apiClient.getCurrentUserId(), type, parentId).then(function (images) { + if (images.length) { + backdrop.setBackdrops(images.map(function (i) { + i.BackdropImageTags = [i.tag]; + return i; + })); + } else { + backdrop.clear(); + } + }); + } } + var cache = {}; - pageClassOn("pageshow", "page", function() { + pageClassOn("pageshow", "page", function () { var page = this; - if (!page.classList.contains("selfBackdropPage")) - if (page.classList.contains("backdropPage")) + + if (!page.classList.contains("selfBackdropPage")) { + if (page.classList.contains("backdropPage")) { if (enabled()) { - var type = page.getAttribute("data-backdroptype"), - parentId = page.classList.contains("globalBackdropPage") ? "" : libraryMenu.getTopParentId(); - showBackdrop(type, parentId) - } else page.classList.remove("backdropPage"), backdrop.clear(); - else backdrop.clear() - }) -}); \ No newline at end of file + var type = page.getAttribute("data-backdroptype"); + var parentId = page.classList.contains("globalBackdropPage") ? "" : libraryMenu.getTopParentId(); + showBackdrop(type, parentId); + } else { + page.classList.remove("backdropPage"); + backdrop.clear(); + } + } else { + backdrop.clear(); + } + } + }); +}); From 40e4f6a27a7d05218681cb4eb980115b9ece27e2 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 00:57:40 +0300 Subject: [PATCH 02/24] itembynamedetailpage.js --- src/scripts/itembynamedetailpage.js | 309 ++++++++++++++++++++-------- 1 file changed, 221 insertions(+), 88 deletions(-) diff --git a/src/scripts/itembynamedetailpage.js b/src/scripts/itembynamedetailpage.js index 720c8a1e4e..1de421e6a3 100644 --- a/src/scripts/itembynamedetailpage.js +++ b/src/scripts/itembynamedetailpage.js @@ -1,40 +1,90 @@ -define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryBrowser", "emby-itemscontainer", "emby-button"], function(connectionManager, listView, cardBuilder, imageLoader, libraryBrowser) { +define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryBrowser", "emby-itemscontainer", "emby-button"], function (connectionManager, listView, cardBuilder, imageLoader, libraryBrowser) { "use strict"; function renderItems(page, item) { var sections = []; - item.ArtistCount && sections.push({ - name: Globalize.translate("TabArtists"), - type: "MusicArtist" - }), item.ProgramCount && "Person" == item.Type && sections.push({ - name: Globalize.translate("HeaderUpcomingOnTV"), - type: "Program" - }), item.MovieCount && sections.push({ - name: Globalize.translate("TabMovies"), - type: "Movie" - }), item.SeriesCount && sections.push({ - name: Globalize.translate("TabShows"), - type: "Series" - }), item.EpisodeCount && sections.push({ - name: Globalize.translate("TabEpisodes"), - type: "Episode" - }), item.TrailerCount && sections.push({ - name: Globalize.translate("TabTrailers"), - type: "Trailer" - }), item.AlbumCount && sections.push({ - name: Globalize.translate("TabAlbums"), - type: "MusicAlbum" - }), item.MusicVideoCount && sections.push({ - name: Globalize.translate("TabMusicVideos"), - type: "MusicVideo" - }); + + if (item.ArtistCount) { + sections.push({ + name: Globalize.translate("TabArtists"), + type: "MusicArtist" + }); + } + + if (item.ProgramCount && "Person" == item.Type) { + sections.push({ + name: Globalize.translate("HeaderUpcomingOnTV"), + type: "Program" + }); + } + + if (item.MovieCount) { + sections.push({ + name: Globalize.translate("TabMovies"), + type: "Movie" + }); + } + + if (item.SeriesCount) { + sections.push({ + name: Globalize.translate("TabShows"), + type: "Series" + }); + } + + if (item.EpisodeCount) { + sections.push({ + name: Globalize.translate("TabEpisodes"), + type: "Episode" + }); + } + + if (item.TrailerCount) { + sections.push({ + name: Globalize.translate("TabTrailers"), + type: "Trailer" + }); + } + + if (item.AlbumCount) { + sections.push({ + name: Globalize.translate("TabAlbums"), + type: "MusicAlbum" + }); + } + + if (item.MusicVideoCount) { + sections.push({ + name: Globalize.translate("TabMusicVideos"), + type: "MusicVideo" + }); + } + var elem = page.querySelector("#childrenContent"); - elem.innerHTML = sections.map(function(section) { - var html = "", - sectionClass = "verticalSection"; - return "Audio" === section.type && (sectionClass += " verticalSection-extrabottompadding"), html += '
', html += '
', html += '

', html += section.name, html += "

", html += '", html += "
", html += '
', html += "
", html += "
" + elem.innerHTML = sections.map(function (section) { + var html = ""; + var sectionClass = "verticalSection"; + + if ("Audio" === section.type) { + sectionClass += " verticalSection-extrabottompadding"; + } + + html += '
'; + html += '
'; + html += '

'; + html += section.name; + html += "

"; + html += '"; + html += "
"; + html += '
'; + html += "
"; + return html += "
"; }).join(""); - for (var sectionElems = elem.querySelectorAll(".verticalSection"), i = 0, length = sectionElems.length; i < length; i++) renderSection(page, item, sectionElems[i], sectionElems[i].getAttribute("data-type")) + var sectionElems = elem.querySelectorAll(".verticalSection"); + + for (var i = 0, length = sectionElems.length; i < length; i++) { + renderSection(page, item, sectionElems[i], sectionElems[i].getAttribute("data-type")); + } } function renderSection(page, item, element, type) { @@ -50,16 +100,17 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB SortBy: "StartDate" }, { shape: "backdrop", - showTitle: !0, - centerText: !0, - overlayMoreButton: !0, - preferThumb: !0, - overlayText: !1, - showAirTime: !0, - showAirDateTime: !0, - showChannelName: !0 + showTitle: true, + centerText: true, + overlayMoreButton: true, + preferThumb: true, + overlayText: false, + showAirTime: true, + showAirDateTime: true, + showChannelName: true }); break; + case "Movie": loadItems(element, item, type, { MediaTypes: "", @@ -71,13 +122,14 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB SortBy: "SortName" }, { shape: "portrait", - showTitle: !0, - centerText: !0, - overlayMoreButton: !0, - overlayText: !1, - showYear: !0 + showTitle: true, + centerText: true, + overlayMoreButton: true, + overlayText: false, + showYear: true }); break; + case "MusicVideo": loadItems(element, item, type, { MediaTypes: "", @@ -89,11 +141,12 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB SortBy: "SortName" }, { shape: "portrait", - showTitle: !0, - centerText: !0, - overlayPlayButton: !0 + showTitle: true, + centerText: true, + overlayPlayButton: true }); break; + case "Trailer": loadItems(element, item, type, { MediaTypes: "", @@ -105,11 +158,12 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB SortBy: "SortName" }, { shape: "portrait", - showTitle: !0, - centerText: !0, - overlayPlayButton: !0 + showTitle: true, + centerText: true, + overlayPlayButton: true }); break; + case "Series": loadItems(element, item, type, { MediaTypes: "", @@ -121,11 +175,12 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB SortBy: "SortName" }, { shape: "portrait", - showTitle: !0, - centerText: !0, - overlayMoreButton: !0 + showTitle: true, + centerText: true, + overlayMoreButton: true }); break; + case "MusicAlbum": loadItems(element, item, type, { MediaTypes: "", @@ -137,14 +192,15 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB SortBy: "ProductionYear,Sortname" }, { shape: "square", - playFromHere: !0, - showTitle: !0, - showYear: !0, - coverImage: !0, - centerText: !0, - overlayPlayButton: !0 + playFromHere: true, + showTitle: true, + showYear: true, + coverImage: true, + centerText: true, + overlayPlayButton: true }); break; + case "MusicArtist": loadItems(element, item, type, { MediaTypes: "", @@ -156,14 +212,15 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB SortBy: "SortName" }, { shape: "square", - playFromHere: !0, - showTitle: !0, - showParentTitle: !0, - coverImage: !0, - centerText: !0, - overlayPlayButton: !0 + playFromHere: true, + showTitle: true, + showParentTitle: true, + coverImage: true, + centerText: true, + overlayPlayButton: true }); break; + case "Episode": loadItems(element, item, type, { MediaTypes: "", @@ -175,12 +232,13 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB SortBy: "SortName" }, { shape: "backdrop", - showTitle: !0, - showParentTitle: !0, - centerText: !0, - overlayPlayButton: !0 + showTitle: true, + showParentTitle: true, + centerText: true, + overlayPlayButton: true }); break; + case "Audio": loadItems(element, item, type, { MediaTypes: "", @@ -190,57 +248,132 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB AlbumArtistIds: "", SortBy: "AlbumArtist,Album,SortName" }, { - playFromHere: !0, + playFromHere: true, action: "playallfromhere", - smallIcon: !0, - artist: !0 - }) + smallIcon: true, + artist: true + }); } } function loadItems(element, item, type, query, listOptions) { - query = getQuery(query, item), getItemsFunction(query, item)(query.StartIndex, query.Limit, query.Fields).then(function(result) { + query = getQuery(query, item); + getItemsFunction(query, item)(query.StartIndex, query.Limit, query.Fields).then(function (result) { var html = ""; + if (query.Limit && result.TotalRecordCount > query.Limit) { var link = element.querySelector("a"); - link.classList.remove("hide"), link.setAttribute("href", getMoreItemsHref(item, type)) - } else element.querySelector("a").classList.add("hide"); + link.classList.remove("hide"); + link.setAttribute("href", getMoreItemsHref(item, type)); + } else { + element.querySelector("a").classList.add("hide"); + } + listOptions.items = result.Items; var itemsContainer = element.querySelector(".itemsContainer"); - "Audio" == type ? (html = listView.getListViewHtml(listOptions), itemsContainer.classList.remove("vertical-wrap"), itemsContainer.classList.add("vertical-list")) : (html = cardBuilder.getCardsHtml(listOptions), itemsContainer.classList.add("vertical-wrap"), itemsContainer.classList.remove("vertical-list")), itemsContainer.innerHTML = html, imageLoader.lazyChildren(itemsContainer) - }) + + if ("Audio" == type) { + html = listView.getListViewHtml(listOptions); + itemsContainer.classList.remove("vertical-wrap"); + itemsContainer.classList.add("vertical-list"); + } else { + html = cardBuilder.getCardsHtml(listOptions); + itemsContainer.classList.add("vertical-wrap"); + itemsContainer.classList.remove("vertical-list"); + } + + itemsContainer.innerHTML = html; + imageLoader.lazyChildren(itemsContainer); + }); } function getMoreItemsHref(item, type) { - return "Genre" == item.Type ? "list.html?type=" + type + "&genreId=" + item.Id + "&serverId=" + item.ServerId : "MusicGenre" == item.Type ? "list.html?type=" + type + "&musicGenreId=" + item.Id + "&serverId=" + item.ServerId : "Studio" == item.Type ? "list.html?type=" + type + "&studioId=" + item.Id + "&serverId=" + item.ServerId : "MusicArtist" == item.Type ? "list.html?type=" + type + "&artistId=" + item.Id + "&serverId=" + item.ServerId : "Person" == item.Type ? "list.html?type=" + type + "&personId=" + item.Id + "&serverId=" + item.ServerId : "list.html?type=" + type + "&parentId=" + item.Id + "&serverId=" + item.ServerId + if ("Genre" == item.Type) { + return "list.html?type=" + type + "&genreId=" + item.Id + "&serverId=" + item.ServerId; + } + + if ("MusicGenre" == item.Type) { + return "list.html?type=" + type + "&musicGenreId=" + item.Id + "&serverId=" + item.ServerId; + } + + if ("Studio" == item.Type) { + return "list.html?type=" + type + "&studioId=" + item.Id + "&serverId=" + item.ServerId; + } + + if ("MusicArtist" == item.Type) { + return "list.html?type=" + type + "&artistId=" + item.Id + "&serverId=" + item.ServerId; + } + + if ("Person" == item.Type) { + return "list.html?type=" + type + "&personId=" + item.Id + "&serverId=" + item.ServerId; + } + + return "list.html?type=" + type + "&parentId=" + item.Id + "&serverId=" + item.ServerId; } function addCurrentItemToQuery(query, item) { - "Person" == item.Type ? query.PersonIds = item.Id : "Genre" == item.Type ? query.GenreIds = item.Id : "MusicGenre" == item.Type ? query.GenreIds = item.Id : "Studio" == item.Type ? query.StudioIds = item.Id : "MusicArtist" == item.Type && (connectionManager.getApiClient(item.ServerId).isMinServerVersion("3.4.1.18") ? query.AlbumArtistIds = item.Id : query.ArtistIds = item.Id) + if ("Person" == item.Type) { + query.PersonIds = item.Id; + } else { + if ("Genre" == item.Type) { + query.GenreIds = item.Id; + } else { + if ("MusicGenre" == item.Type) { + query.GenreIds = item.Id; + } else { + if ("Studio" == item.Type) { + query.StudioIds = item.Id; + } else { + if ("MusicArtist" == item.Type) { + if (connectionManager.getApiClient(item.ServerId).isMinServerVersion("3.4.1.18")) { + query.AlbumArtistIds = item.Id; + } else { + query.ArtistIds = item.Id; + } + } + } + } + } + } } function getQuery(options, item) { var query = { SortOrder: "Ascending", IncludeItemTypes: "", - Recursive: !0, + Recursive: true, Fields: "AudioInfo,SeriesInfo,ParentId,PrimaryImageAspectRatio,BasicSyncInfo", Limit: 100, StartIndex: 0, - CollapseBoxSetItems: !1 + CollapseBoxSetItems: false }; - return query = Object.assign(query, options || {}), addCurrentItemToQuery(query, item), query + query = Object.assign(query, options || {}); + addCurrentItemToQuery(query, item); + return query; } function getItemsFunction(options, item) { var query = getQuery(options, item); - return function(index, limit, fields) { - query.StartIndex = index, query.Limit = limit, fields && (query.Fields += "," + fields); + return function (index, limit, fields) { + query.StartIndex = index; + query.Limit = limit; + + if (fields) { + query.Fields += "," + fields; + } + var apiClient = connectionManager.getApiClient(item.ServerId); - return "MusicArtist" === query.IncludeItemTypes ? (query.IncludeItemTypes = null, apiClient.getAlbumArtists(apiClient.getCurrentUserId(), query)) : apiClient.getItems(apiClient.getCurrentUserId(), query) - } + + if ("MusicArtist" === query.IncludeItemTypes) { + query.IncludeItemTypes = null; + return apiClient.getAlbumArtists(apiClient.getCurrentUserId(), query); + } + + return apiClient.getItems(apiClient.getCurrentUserId(), query); + }; } + window.ItemsByName = { renderItems: renderItems - } + }; }); From f7c8d7b044848c6d09740406c2d66d94711915e3 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 00:58:10 +0300 Subject: [PATCH 03/24] librarybrowser.js --- src/scripts/librarybrowser.js | 198 +++++++++++++++++++++++++--------- 1 file changed, 148 insertions(+), 50 deletions(-) diff --git a/src/scripts/librarybrowser.js b/src/scripts/librarybrowser.js index 5278842d7f..f2edc9030c 100644 --- a/src/scripts/librarybrowser.js +++ b/src/scripts/librarybrowser.js @@ -1,101 +1,199 @@ -define(["userSettings"], function(userSettings) { +define(["userSettings"], function (userSettings) { "use strict"; + var libraryBrowser = { - getSavedQueryKey: function(modifier) { - return window.location.href.split("#")[0] + (modifier || "") + getSavedQueryKey: function (modifier) { + return window.location.href.split("#")[0] + (modifier || ""); }, - loadSavedQueryValues: function(key, query) { + loadSavedQueryValues: function (key, query) { var values = userSettings.get(key); - return values ? (values = JSON.parse(values), Object.assign(query, values)) : query + + if (values) { + values = JSON.parse(values); + return Object.assign(query, values); + } + + return query; }, - saveQueryValues: function(key, query) { + saveQueryValues: function (key, query) { var values = {}; - query.SortBy && (values.SortBy = query.SortBy), query.SortOrder && (values.SortOrder = query.SortOrder), userSettings.set(key, JSON.stringify(values)) + + if (query.SortBy) { + values.SortBy = query.SortBy; + } + + if (query.SortOrder) { + values.SortOrder = query.SortOrder; + } + + userSettings.set(key, JSON.stringify(values)); }, - saveViewSetting: function(key, value) { - userSettings.set(key + "-_view", value) + saveViewSetting: function (key, value) { + userSettings.set(key + "-_view", value); }, - getSavedView: function(key) { - return userSettings.get(key + "-_view") + getSavedView: function (key) { + return userSettings.get(key + "-_view"); }, - showLayoutMenu: function(button, currentLayout, views) { - var dispatchEvent = !0; - views || (dispatchEvent = !1, views = button.getAttribute("data-layouts"), views = views ? views.split(",") : ["List", "Poster", "PosterCard", "Thumb", "ThumbCard"]); - var menuItems = views.map(function(v) { + showLayoutMenu: function (button, currentLayout, views) { + var dispatchEvent = true; + + if (!views) { + dispatchEvent = false; + views = button.getAttribute("data-layouts"); + views = views ? views.split(",") : ["List", "Poster", "PosterCard", "Thumb", "ThumbCard"]; + } + + var menuItems = views.map(function (v) { return { name: Globalize.translate("Option" + v), id: v, selected: currentLayout == v - } + }; }); - require(["actionsheet"], function(actionsheet) { + + require(["actionsheet"], function (actionsheet) { actionsheet.show({ items: menuItems, positionTo: button, - callback: function(id) { + callback: function (id) { button.dispatchEvent(new CustomEvent("layoutchange", { detail: { viewStyle: id }, - bubbles: !0, - cancelable: !1 - })), dispatchEvent || window.$ && $(button).trigger("layoutchange", [id]) + bubbles: true, + cancelable: false + })); + + if (!dispatchEvent) { + if (window.$) { + $(button).trigger("layoutchange", [id]); + } + } } - }) - }) + }); + }); }, - getQueryPagingHtml: function(options) { - var startIndex = options.startIndex, - limit = options.limit, - totalRecordCount = options.totalRecordCount, - html = "", - recordsEnd = Math.min(startIndex + limit, totalRecordCount), - showControls = limit < totalRecordCount; + getQueryPagingHtml: function (options) { + var startIndex = options.startIndex; + var limit = options.limit; + var totalRecordCount = options.totalRecordCount; + var html = ""; + var recordsEnd = Math.min(startIndex + limit, totalRecordCount); + var showControls = limit < totalRecordCount; + if (html += '
', showControls) { html += ''; - html += (totalRecordCount ? startIndex + 1 : 0) + "-" + recordsEnd + " of " + totalRecordCount, html += "" + html += (totalRecordCount ? startIndex + 1 : 0) + "-" + recordsEnd + " of " + totalRecordCount; + html += ""; } - return (showControls || options.viewButton || options.filterButton || options.sortButton || options.addLayoutButton) && (html += '
', showControls && (html += '', html += ''), options.addLayoutButton && (html += ''), options.sortButton && (html += ''), options.filterButton && (html += ''), html += "
"), html += "
" + + if (showControls || options.viewButton || options.filterButton || options.sortButton || options.addLayoutButton) { + html += '
'; + + if (showControls) { + html += ''; + html += ''; + } + + if (options.addLayoutButton) { + html += ''; + } + + if (options.sortButton) { + html += ''; + } + + if (options.filterButton) { + html += ''; + } + + html += "
"; + } + + return html += ""; }, - showSortMenu: function(options) { - require(["dialogHelper", "emby-radio"], function(dialogHelper) { + showSortMenu: function (options) { + require(["dialogHelper", "emby-radio"], function (dialogHelper) { function onSortByChange() { var newValue = this.value; + if (this.checked) { var changed = options.query.SortBy != newValue; - options.query.SortBy = newValue.replace("_", ","), options.query.StartIndex = 0, options.callback && changed && options.callback() + options.query.SortBy = newValue.replace("_", ","); + options.query.StartIndex = 0; + + if (options.callback && changed) { + options.callback(); + } } } function onSortOrderChange() { var newValue = this.value; + if (this.checked) { var changed = options.query.SortOrder != newValue; - options.query.SortOrder = newValue, options.query.StartIndex = 0, options.callback && changed && options.callback() + options.query.SortOrder = newValue; + options.query.StartIndex = 0; + + if (options.callback && changed) { + options.callback(); + } } } + var dlg = dialogHelper.createDialog({ - removeOnClose: !0, - modal: !1, + removeOnClose: true, + modal: false, entryAnimationDuration: 160, exitAnimationDuration: 200 }); - dlg.classList.add("ui-body-a"), dlg.classList.add("background-theme-a"), dlg.classList.add("formDialog"); + dlg.classList.add("ui-body-a"); + dlg.classList.add("background-theme-a"); + dlg.classList.add("formDialog"); var html = ""; - html += '
', html += '

', html += Globalize.translate("HeaderSortBy"), html += "

"; - var i, length, isChecked; + html += '
'; + html += '

'; + html += Globalize.translate("HeaderSortBy"); + html += "

"; + var i; + var length; + var isChecked; + for (html += "
", i = 0, length = options.items.length; i < length; i++) { - var option = options.items[i], - radioValue = option.id.replace(",", "_"); - isChecked = (options.query.SortBy || "").replace(",", "_") == radioValue ? " checked" : "", html += '" + var option = options.items[i]; + var radioValue = option.id.replace(",", "_"); + isChecked = (options.query.SortBy || "").replace(",", "_") == radioValue ? " checked" : ""; + html += '"; } - html += "
", html += '

', html += Globalize.translate("HeaderSortOrder"), html += "

", html += "
", isChecked = "Ascending" == options.query.SortOrder ? " checked" : "", html += '", isChecked = "Descending" == options.query.SortOrder ? " checked" : "", html += '", html += "
", html += "
", dlg.innerHTML = html, dialogHelper.open(dlg); + + html += "
"; + html += '

'; + html += Globalize.translate("HeaderSortOrder"); + html += "

"; + html += "
"; + isChecked = "Ascending" == options.query.SortOrder ? " checked" : ""; + html += '"; + isChecked = "Descending" == options.query.SortOrder ? " checked" : ""; + html += '"; + html += "
"; + html += ""; + dlg.innerHTML = html; + dialogHelper.open(dlg); var sortBys = dlg.querySelectorAll(".menuSortBy"); - for (i = 0, length = sortBys.length; i < length; i++) sortBys[i].addEventListener("change", onSortByChange); + + for (i = 0, length = sortBys.length; i < length; i++) { + sortBys[i].addEventListener("change", onSortByChange); + } + var sortOrders = dlg.querySelectorAll(".menuSortOrder"); - for (i = 0, length = sortOrders.length; i < length; i++) sortOrders[i].addEventListener("change", onSortOrderChange) - }) + + for (i = 0, length = sortOrders.length; i < length; i++) { + sortOrders[i].addEventListener("change", onSortOrderChange); + } + }); } }; - return window.LibraryBrowser = libraryBrowser, libraryBrowser -}); \ No newline at end of file + window.LibraryBrowser = libraryBrowser; + return libraryBrowser; +}); From ecccf00fcb66f36abe5bbd2daaaefb26f5486da2 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 01:01:20 +0300 Subject: [PATCH 04/24] librarymenu.js --- src/scripts/librarymenu.js | 59 +++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/src/scripts/librarymenu.js b/src/scripts/librarymenu.js index 9c303d3bde..6b64041966 100644 --- a/src/scripts/librarymenu.js +++ b/src/scripts/librarymenu.js @@ -105,6 +105,7 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " function bindMenuEvents() { mainDrawerButton = document.querySelector(".mainDrawerButton"); + if (mainDrawerButton) { mainDrawerButton.addEventListener("click", toggleMainDrawer); } @@ -198,18 +199,20 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " html += '

'; html += globalize.translate("HeaderUser"); html += "

"; + if (appHost.supports("multiserver")) { html += 'wifi' + globalize.translate("ButtonSelectServer") + ""; } + html += 'exit_to_app' + globalize.translate("ButtonSignOut") + ""; html += ""; - } + } // add buttons to navigation drawer - // add buttons to navigation drawer - navDrawerScrollContainer.innerHTML = html; - // bind logout button click to method + navDrawerScrollContainer.innerHTML = html; // bind logout button click to method + var btnLogout = navDrawerScrollContainer.querySelector(".btnLogout"); + if (btnLogout) { btnLogout.addEventListener("click", onLogoutClick); } @@ -250,6 +253,7 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " pageUrls = pageUrls.split("|"); selected = pageUrls.filter(isUrlInCurrentView).length > 0; } + if (selected) { link.classList.add("navMenuOption-selected"); var title = ""; @@ -377,6 +381,7 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " function addPluginPagesToMainMenu(links, pluginItems, section) { for (var i = 0, length = pluginItems.length; i < length; i++) { var pluginItem = pluginItems[i]; + if (pluginItem.EnableInMainMenu && pluginItem.MenuSection === section) { links.push({ name: pluginItem.DisplayName, @@ -416,15 +421,14 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " return getToolsMenuLinks(apiClient).then(function (items) { var item; var menuHtml = ""; - menuHtml += '
'; + for (var i = 0; i < items.length; i++) { item = items[i]; if (item.href) { menuHtml += getToolsLinkHtml(item); - } - else if (item.name) { + } else if (item.name) { menuHtml += '

'; menuHtml += item.name; menuHtml += "

"; @@ -460,8 +464,8 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " for (var i = 0, length = items.length; i < length; i++) { var view = items[i]; - list.push(view); + if ("livetv" == view.CollectionType) { view.ImageTags = {}; view.icon = "live_tv"; @@ -484,8 +488,7 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " if (elem) { if (show) { elem.classList.remove("hide"); - } - else { + } else { elem.classList.add("hide"); } } @@ -498,20 +501,18 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " showBySelector(".libraryMenuDownloads", false); showBySelector(".lnkSyncToOtherDevices", false); return void showBySelector(".userMenuOptions", false); - } + } // FIXME: Potentially the same as above + - // FIXME: Potentially the same as above if (user.Policy.EnableContentDownloading) { showBySelector(".lnkSyncToOtherDevices", true); - } - else { + } else { showBySelector(".lnkSyncToOtherDevices", false); } if (user.Policy.EnableContentDownloading && appHost.supports("sync")) { showBySelector(".libraryMenuDownloads", true); - } - else { + } else { showBySelector(".libraryMenuDownloads", false); } @@ -529,9 +530,11 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " html += items.map(function (i) { var icon = i.icon || imageHelper.getLibraryIcon(i.CollectionType); var itemId = i.Id; + if (i.onclick) { i.onclick; } + return '' + icon + '' + i.Name + ""; }).join(""); libraryMenuOptions.innerHTML = html; @@ -592,23 +595,17 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " if (isChannelsPage && "channels" === itemId) { lnkMediaFolder.classList.add("navMenuOption-selected"); - } - else if (isLiveTvPage && "livetv" === itemId) { + } else if (isLiveTvPage && "livetv" === itemId) { lnkMediaFolder.classList.add("navMenuOption-selected"); - } - else if (isEditorPage && "editor" === itemId) { + } else if (isEditorPage && "editor" === itemId) { lnkMediaFolder.classList.add("navMenuOption-selected"); - } - else if (isMySyncPage && "manageoffline" === itemId && -1 != window.location.href.toString().indexOf("mode=download")) { + } else if (isMySyncPage && "manageoffline" === itemId && -1 != window.location.href.toString().indexOf("mode=download")) { lnkMediaFolder.classList.add("navMenuOption-selected"); - } - else if (isMySyncPage && "syncotherdevices" === itemId && -1 == window.location.href.toString().indexOf("mode=download")) { + } else if (isMySyncPage && "syncotherdevices" === itemId && -1 == window.location.href.toString().indexOf("mode=download")) { lnkMediaFolder.classList.add("navMenuOption-selected"); - } - else if (id && itemId == id) { + } else if (id && itemId == id) { lnkMediaFolder.classList.add("navMenuOption-selected"); - } - else { + } else { lnkMediaFolder.classList.remove("navMenuOption-selected"); } } @@ -667,8 +664,7 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " if (title) { LibraryMenu.setTitle(title); - } - else if (page.classList.contains("standalonePage")) { + } else if (page.classList.contains("standalonePage")) { LibraryMenu.setDefaultTitle(); } } @@ -697,6 +693,7 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " function refreshLibraryDrawer(user) { loadNavDrawer(); currentDrawerType = "library"; + if (user) { Promise.resolve(user); } else { @@ -729,9 +726,11 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " return new Promise(function (resolve, reject) { require(["navdrawer"], function (navdrawer) { navDrawerInstance = new navdrawer(getNavDrawerOptions()); + if (!layoutManager.tv) { navDrawerElement.classList.remove("hide"); } + resolve(navDrawerInstance); }); }); From 44ba92261d934399fa4c66bfad52be5c68ece969 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 01:02:07 +0300 Subject: [PATCH 05/24] livetvcomponents.js --- src/scripts/livetvcomponents.js | 124 +++++++++++++++++++++----------- 1 file changed, 83 insertions(+), 41 deletions(-) diff --git a/src/scripts/livetvcomponents.js b/src/scripts/livetvcomponents.js index dee3a92bd1..a883885df1 100644 --- a/src/scripts/livetvcomponents.js +++ b/src/scripts/livetvcomponents.js @@ -1,57 +1,92 @@ -define(["layoutManager", "datetime", "cardBuilder", "apphost"], function(layoutManager, datetime, cardBuilder, appHost) { +define(["layoutManager", "datetime", "cardBuilder", "apphost"], function (layoutManager, datetime, cardBuilder, appHost) { "use strict"; function enableScrollX() { - return !layoutManager.desktop + return !layoutManager.desktop; } function getBackdropShape() { - return enableScrollX() ? "overflowBackdrop" : "backdrop" + if (enableScrollX()) { + return "overflowBackdrop"; + } + + return "backdrop"; } function getTimersHtml(timers, options) { options = options || {}; - var i, length, items = timers.map(function(t) { - return t.Type = "Timer", t - }), - groups = [], - currentGroupName = "", - currentGroup = []; + var i; + var length; + var items = timers.map(function (t) { + t.Type = "Timer"; + return t; + }); + var groups = []; + var currentGroupName = ""; + var currentGroup = []; + for (i = 0, length = items.length; i < length; i++) { - var item = items[i], - dateText = ""; - if (!1 !== options.indexByDate && item.StartDate) try { - var premiereDate = datetime.parseISO8601Date(item.StartDate, !0); - dateText = datetime.toLocaleDateString(premiereDate, { - weekday: "long", - month: "short", - day: "numeric" - }) - } catch (err) {} - dateText != currentGroupName ? (currentGroup.length && groups.push({ + var item = items[i]; + var dateText = ""; + + if (false !== options.indexByDate && item.StartDate) { + try { + var premiereDate = datetime.parseISO8601Date(item.StartDate, true); + dateText = datetime.toLocaleDateString(premiereDate, { + weekday: "long", + month: "short", + day: "numeric" + }); + } catch (err) {} + } + + if (dateText != currentGroupName) { + if (currentGroup.length) { + groups.push({ + name: currentGroupName, + items: currentGroup + }); + } + + currentGroupName = dateText; + currentGroup = [item]; + } else { + currentGroup.push(item); + } + } + + if (currentGroup.length) { + groups.push({ name: currentGroupName, items: currentGroup - }), currentGroupName = dateText, currentGroup = [item]) : currentGroup.push(item) + }); } - currentGroup.length && groups.push({ - name: currentGroupName, - items: currentGroup - }); + var html = ""; + for (i = 0, length = groups.length; i < length; i++) { - var group = groups[i], - supportsImageAnalysis = appHost.supports("imageanalysis"), - cardLayout = appHost.preferVisualCards || supportsImageAnalysis; - if (cardLayout = !0, group.name && (html += '
', html += '

' + group.name + "

"), enableScrollX()) { + var group = groups[i]; + var supportsImageAnalysis = appHost.supports("imageanalysis"); + var cardLayout = appHost.preferVisualCards || supportsImageAnalysis; + + if (cardLayout = true, group.name && (html += '
', html += '

' + group.name + "

"), enableScrollX()) { var scrollXClass = "scrollX hiddenScrollX"; - layoutManager.tv && (scrollXClass += " smoothScrollX"), html += '
' - } else html += '
'; + + if (layoutManager.tv) { + scrollXClass += " smoothScrollX"; + } + + html += '
'; + } else { + html += '
'; + } + html += cardBuilder.getCardsHtml({ items: group.items, shape: cardLayout ? getBackdropShape() : enableScrollX() ? "autoOverflow" : "autoVertical", - showParentTitleOrTitle: !0, - showAirTime: !0, - showAirEndTime: !0, + showParentTitleOrTitle: true, + showAirTime: true, + showAirEndTime: true, showChannelName: !cardLayout, cardLayout: cardLayout, centerText: !cardLayout, @@ -59,15 +94,22 @@ define(["layoutManager", "datetime", "cardBuilder", "apphost"], function(layoutM cardFooterAside: "none", preferThumb: !!cardLayout || "auto", defaultShape: cardLayout ? null : "portrait", - coverImage: !0, - allowBottomPadding: !1, - overlayText: !1, + coverImage: true, + allowBottomPadding: false, + overlayText: false, showChannelLogo: cardLayout - }), html += "
", group.name && (html += "
") + }); + html += "
"; + + if (group.name) { + html += "
"; + } } - return Promise.resolve(html) + + return Promise.resolve(html); } + window.LiveTvHelpers = { getTimersHtml: getTimersHtml - } -}); \ No newline at end of file + }; +}); From f5e62cbd65e59d504eb8f18cabf23d6db756b0f6 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 01:02:37 +0300 Subject: [PATCH 06/24] playlistedit.js --- src/scripts/playlistedit.js | 45 +++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/scripts/playlistedit.js b/src/scripts/playlistedit.js index ef0615e2ba..32a3a960a4 100644 --- a/src/scripts/playlistedit.js +++ b/src/scripts/playlistedit.js @@ -1,39 +1,50 @@ -define(["listView"], function(listView) { +define(["listView"], function (listView) { "use strict"; function getFetchPlaylistItemsFn(itemId) { - return function() { + return function () { var query = { Fields: "PrimaryImageAspectRatio,UserData", EnableImageTypes: "Primary,Backdrop,Banner,Thumb", UserId: ApiClient.getCurrentUserId() }; - return ApiClient.getJSON(ApiClient.getUrl("Playlists/" + itemId + "/Items", query)) - } + return ApiClient.getJSON(ApiClient.getUrl("Playlists/" + itemId + "/Items", query)); + }; } function getItemsHtmlFn(itemId) { - return function(items) { + return function (items) { return listView.getListViewHtml({ items: items, - showIndex: !1, - showRemoveFromPlaylist: !0, - playFromHere: !0, + showIndex: false, + showRemoveFromPlaylist: true, + playFromHere: true, action: "playallfromhere", - smallIcon: !0, - dragHandle: !0, + smallIcon: true, + dragHandle: true, playlistId: itemId - }) - } + }); + }; } function init(page, item) { var elem = page.querySelector("#childrenContent .itemsContainer"); - elem.classList.add("vertical-list"), elem.classList.remove("vertical-wrap"), elem.enableDragReordering(!0), elem.fetchData = getFetchPlaylistItemsFn(item.Id), elem.getItemsHtml = getItemsHtmlFn(item.Id) + elem.classList.add("vertical-list"); + elem.classList.remove("vertical-wrap"); + elem.enableDragReordering(true); + elem.fetchData = getFetchPlaylistItemsFn(item.Id); + elem.getItemsHtml = getItemsHtmlFn(item.Id); } + window.PlaylistViewer = { - render: function(page, item) { - page.playlistInit || (page.playlistInit = !0, init(page, item)), page.querySelector("#childrenContent").classList.add("verticalSection-extrabottompadding"), page.querySelector("#childrenContent .itemsContainer").refreshItems() + render: function (page, item) { + if (!page.playlistInit) { + page.playlistInit = true; + init(page, item); + } + + page.querySelector("#childrenContent").classList.add("verticalSection-extrabottompadding"); + page.querySelector("#childrenContent .itemsContainer").refreshItems(); } - } -}); \ No newline at end of file + }; +}); From 850c2c4baf03ab81b8fde3e66e70403c60e53af7 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 01:03:08 +0300 Subject: [PATCH 07/24] playlists.js --- src/scripts/playlists.js | 222 ++++++++++++++++++++++++--------------- 1 file changed, 137 insertions(+), 85 deletions(-) diff --git a/src/scripts/playlists.js b/src/scripts/playlists.js index ee9fac6c58..606a34c787 100644 --- a/src/scripts/playlists.js +++ b/src/scripts/playlists.js @@ -1,124 +1,176 @@ -define(["loading", "listView", "cardBuilder", "libraryMenu", "libraryBrowser", "apphost", "imageLoader", "emby-itemscontainer"], function(loading, listView, cardBuilder, libraryMenu, libraryBrowser, appHost, imageLoader) { +define(["loading", "listView", "cardBuilder", "libraryMenu", "libraryBrowser", "apphost", "imageLoader", "emby-itemscontainer"], function (loading, listView, cardBuilder, libraryMenu, libraryBrowser, appHost, imageLoader) { "use strict"; - return function(view, params) { + + return function (view, params) { function getPageData(context) { - var key = getSavedQueryKey(context), - pageData = data[key]; - return pageData || (pageData = data[key] = { - query: { - SortBy: "SortName", - SortOrder: "Ascending", - IncludeItemTypes: "Playlist", - Recursive: !0, - Fields: "PrimaryImageAspectRatio,SortName,CumulativeRunTimeTicks,CanDelete", - StartIndex: 0, - Limit: 100 - }, - view: libraryBrowser.getSavedView(key) || "Poster" - }, pageData.query.ParentId = libraryMenu.getTopParentId(), libraryBrowser.loadSavedQueryValues(key, pageData.query)), pageData + var key = getSavedQueryKey(context); + var pageData = data[key]; + + if (!pageData) { + pageData = data[key] = { + query: { + SortBy: "SortName", + SortOrder: "Ascending", + IncludeItemTypes: "Playlist", + Recursive: true, + Fields: "PrimaryImageAspectRatio,SortName,CumulativeRunTimeTicks,CanDelete", + StartIndex: 0, + Limit: 100 + }, + view: libraryBrowser.getSavedView(key) || "Poster" + }; + pageData.query.ParentId = libraryMenu.getTopParentId(); + libraryBrowser.loadSavedQueryValues(key, pageData.query); + } + + return pageData; } function getQuery(context) { - return getPageData(context).query + return getPageData(context).query; } function getSavedQueryKey(context) { - return context.savedQueryKey || (context.savedQueryKey = libraryBrowser.getSavedQueryKey()), context.savedQueryKey + if (!context.savedQueryKey) { + context.savedQueryKey = libraryBrowser.getSavedQueryKey(); + } + + return context.savedQueryKey; } function showLoadingMessage() { - loading.show() + loading.show(); } function hideLoadingMessage() { - loading.hide() + loading.hide(); } function onViewStyleChange() { - var viewStyle = getPageData(view).view, - itemsContainer = view.querySelector(".itemsContainer"); - "List" == viewStyle ? (itemsContainer.classList.add("vertical-list"), itemsContainer.classList.remove("vertical-wrap")) : (itemsContainer.classList.remove("vertical-list"), itemsContainer.classList.add("vertical-wrap")), itemsContainer.innerHTML = "" + var viewStyle = getPageData(view).view; + var itemsContainer = view.querySelector(".itemsContainer"); + + if ("List" == viewStyle) { + itemsContainer.classList.add("vertical-list"); + itemsContainer.classList.remove("vertical-wrap"); + } else { + itemsContainer.classList.remove("vertical-list"); + itemsContainer.classList.add("vertical-wrap"); + } + + itemsContainer.innerHTML = ""; } function reloadItems() { showLoadingMessage(); - var query = getQuery(view), - promise1 = ApiClient.getItems(Dashboard.getCurrentUserId(), query), - promise2 = Dashboard.getCurrentUser(); - Promise.all([promise1, promise2]).then(function(responses) { + var query = getQuery(view); + var promise1 = ApiClient.getItems(Dashboard.getCurrentUserId(), query); + var promise2 = Dashboard.getCurrentUser(); + Promise.all([promise1, promise2]).then(function (responses) { var result = responses[0]; responses[1]; window.scrollTo(0, 0); - var html = "", - viewStyle = getPageData(view).view; + var html = ""; + var viewStyle = getPageData(view).view; view.querySelector(".listTopPaging").innerHTML = libraryBrowser.getQueryPagingHtml({ startIndex: query.StartIndex, limit: query.Limit, totalRecordCount: result.TotalRecordCount, - viewButton: !1, - showLimit: !1, - updatePageSizeSetting: !1, - addLayoutButton: !0, + viewButton: false, + showLimit: false, + updatePageSizeSetting: false, + addLayoutButton: true, layouts: "List,Poster,PosterCard,Thumb,ThumbCard", currentLayout: viewStyle - }), result.TotalRecordCount ? (html = "List" == viewStyle ? listView.getListViewHtml({ - items: result.Items, - sortBy: query.SortBy - }) : "PosterCard" == viewStyle ? cardBuilder.getCardsHtml({ - items: result.Items, - shape: "square", - coverImage: !0, - showTitle: !0, - cardLayout: !0 - }) : "Thumb" == viewStyle ? cardBuilder.getCardsHtml({ - items: result.Items, - shape: "backdrop", - showTitle: !0, - centerText: !0, - preferThumb: !0, - overlayPlayButton: !0 - }) : "ThumbCard" == viewStyle ? cardBuilder.getCardsHtml({ - items: result.Items, - shape: "backdrop", - showTitle: !0, - preferThumb: !0, - cardLayout: !0 - }) : cardBuilder.getCardsHtml({ - items: result.Items, - shape: "square", - showTitle: !0, - coverImage: !0, - centerText: !0, - overlayPlayButton: !0 - }), view.querySelector(".noItemsMessage").classList.add("hide")) : view.querySelector(".noItemsMessage").classList.remove("hide"); + }); + + if (result.TotalRecordCount) { + html = "List" == viewStyle ? listView.getListViewHtml({ + items: result.Items, + sortBy: query.SortBy + }) : "PosterCard" == viewStyle ? cardBuilder.getCardsHtml({ + items: result.Items, + shape: "square", + coverImage: true, + showTitle: true, + cardLayout: true + }) : "Thumb" == viewStyle ? cardBuilder.getCardsHtml({ + items: result.Items, + shape: "backdrop", + showTitle: true, + centerText: true, + preferThumb: true, + overlayPlayButton: true + }) : "ThumbCard" == viewStyle ? cardBuilder.getCardsHtml({ + items: result.Items, + shape: "backdrop", + showTitle: true, + preferThumb: true, + cardLayout: true + }) : cardBuilder.getCardsHtml({ + items: result.Items, + shape: "square", + showTitle: true, + coverImage: true, + centerText: true, + overlayPlayButton: true + }); + view.querySelector(".noItemsMessage").classList.add("hide"); + } else { + view.querySelector(".noItemsMessage").classList.remove("hide"); + } + var elem = view.querySelector(".itemsContainer"); - elem.innerHTML = html, imageLoader.lazyChildren(elem); + elem.innerHTML = html; + imageLoader.lazyChildren(elem); var btnNextPage = view.querySelector(".btnNextPage"); - btnNextPage && btnNextPage.addEventListener("click", function() { - query.StartIndex += query.Limit, reloadItems() - }); + + if (btnNextPage) { + btnNextPage.addEventListener("click", function () { + query.StartIndex += query.Limit; + reloadItems(); + }); + } + var btnPreviousPage = view.querySelector(".btnPreviousPage"); - btnPreviousPage && btnPreviousPage.addEventListener("click", function() { - query.StartIndex -= query.Limit, reloadItems() - }); + + if (btnPreviousPage) { + btnPreviousPage.addEventListener("click", function () { + query.StartIndex -= query.Limit; + reloadItems(); + }); + } + var btnChangeLayout = view.querySelector(".btnChangeLayout"); - btnChangeLayout && btnChangeLayout.addEventListener("layoutchange", function(e) { - var layout = e.detail.viewStyle; - getPageData(view).view = layout, libraryBrowser.saveViewSetting(getSavedQueryKey(view), layout), onViewStyleChange(), reloadItems() - }), libraryBrowser.saveQueryValues(getSavedQueryKey(view), query), hideLoadingMessage() - }) + + if (btnChangeLayout) { + btnChangeLayout.addEventListener("layoutchange", function (e) { + var layout = e.detail.viewStyle; + getPageData(view).view = layout; + libraryBrowser.saveViewSetting(getSavedQueryKey(view), layout); + onViewStyleChange(); + reloadItems(); + }); + } + + libraryBrowser.saveQueryValues(getSavedQueryKey(view), query); + hideLoadingMessage(); + }); } + var data = {}; - view.addEventListener("viewbeforeshow", function() { - reloadItems() - }), view.querySelector(".btnNewPlaylist").addEventListener("click", function() { - require(["playlistEditor"], function(playlistEditor) { + view.addEventListener("viewbeforeshow", function () { + reloadItems(); + }); + view.querySelector(".btnNewPlaylist").addEventListener("click", function () { + require(["playlistEditor"], function (playlistEditor) { var serverId = ApiClient.serverInfo().Id; - (new playlistEditor).show({ + new playlistEditor().show({ items: [], serverId: serverId - }) - }) - }), onViewStyleChange() - } -}); \ No newline at end of file + }); + }); + }); + onViewStyleChange(); + }; +}); From 5bed7bbf350a805e6650495f3f90147fe3e914b9 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 01:03:29 +0300 Subject: [PATCH 08/24] searchtab.js --- src/scripts/searchtab.js | 52 +++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/src/scripts/searchtab.js b/src/scripts/searchtab.js index 538770e42e..c0852bfc77 100644 --- a/src/scripts/searchtab.js +++ b/src/scripts/searchtab.js @@ -1,30 +1,54 @@ -define(["searchFields", "searchResults", "events"], function(SearchFields, SearchResults, events) { +define(["searchFields", "searchResults", "events"], function (SearchFields, SearchResults, events) { "use strict"; function init(instance, tabContent, options) { - tabContent.innerHTML = '
', instance.searchFields = new SearchFields({ + tabContent.innerHTML = '
'; + instance.searchFields = new SearchFields({ element: tabContent.querySelector(".searchFields") - }), instance.searchResults = new SearchResults({ + }); + instance.searchResults = new SearchResults({ element: tabContent.querySelector(".searchResults"), serverId: ApiClient.serverId(), parentId: options.parentId, collectionType: options.collectionType - }), events.on(instance.searchFields, "search", function(e, value) { - instance.searchResults.search(value) - }) + }); + events.on(instance.searchFields, "search", function (e, value) { + instance.searchResults.search(value); + }); } function SearchTab(view, tabContent, options) { var self = this; - options = options || {}, init(this, tabContent, options), self.preRender = function() {}, self.renderTab = function() { + options = options || {}; + init(this, tabContent, options); + + self.preRender = function () {}; + + self.renderTab = function () { var searchFields = this.searchFields; - searchFields && searchFields.focus() - } + + if (searchFields) { + searchFields.focus(); + } + }; } - return SearchTab.prototype.destroy = function() { + + SearchTab.prototype.destroy = function () { var searchFields = this.searchFields; - searchFields && searchFields.destroy(), this.searchFields = null; + + if (searchFields) { + searchFields.destroy(); + } + + this.searchFields = null; var searchResults = this.searchResults; - searchResults && searchResults.destroy(), this.searchResults = null - }, SearchTab -}); \ No newline at end of file + + if (searchResults) { + searchResults.destroy(); + } + + this.searchResults = null; + }; + + return SearchTab; +}); From fe08645a9879b4c34dc34e8a3970459ed28fffa9 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 01:03:49 +0300 Subject: [PATCH 09/24] taskbutton.js --- src/scripts/taskbutton.js | 99 ++++++++++++++++++++++++++++++--------- 1 file changed, 77 insertions(+), 22 deletions(-) diff --git a/src/scripts/taskbutton.js b/src/scripts/taskbutton.js index d41cf7b5c2..37e4a3c973 100644 --- a/src/scripts/taskbutton.js +++ b/src/scripts/taskbutton.js @@ -1,48 +1,103 @@ -define(["events", "userSettings", "serverNotifications", "connectionManager", "emby-button"], function(events, userSettings, serverNotifications, connectionManager) { +define(["events", "userSettings", "serverNotifications", "connectionManager", "emby-button"], function (events, userSettings, serverNotifications, connectionManager) { "use strict"; - return function(options) { + + return function (options) { function pollTasks() { connectionManager.getApiClient(serverId).getScheduledTasks({ - IsEnabled: !0 - }).then(updateTasks) + IsEnabled: true + }).then(updateTasks); } function updateTasks(tasks) { - var task = tasks.filter(function(t) { - return t.Key == options.taskKey + var task = tasks.filter(function (t) { + return t.Key == options.taskKey; })[0]; + if (options.panel && (task ? options.panel.classList.remove("hide") : options.panel.classList.add("hide")), task) { - "Idle" == task.State ? button.removeAttribute("disabled") : button.setAttribute("disabled", "disabled"), button.setAttribute("data-taskid", task.Id); + if ("Idle" == task.State) { + button.removeAttribute("disabled"); + } else { + button.setAttribute("disabled", "disabled"); + } + + button.setAttribute("data-taskid", task.Id); var progress = (task.CurrentProgressPercentage || 0).toFixed(1); + if (options.progressElem && (options.progressElem.value = progress, "Running" == task.State ? options.progressElem.classList.remove("hide") : options.progressElem.classList.add("hide")), options.lastResultElem) { var lastResult = task.LastExecutionResult ? task.LastExecutionResult.Status : ""; - "Failed" == lastResult ? options.lastResultElem.html('(' + Globalize.translate("LabelFailed") + ")") : "Cancelled" == lastResult ? options.lastResultElem.html('(' + Globalize.translate("LabelCancelled") + ")") : "Aborted" == lastResult ? options.lastResultElem.html('' + Globalize.translate("LabelAbortedByServerShutdown") + "") : options.lastResultElem.html(lastResult) + + if ("Failed" == lastResult) { + options.lastResultElem.html('(' + Globalize.translate("LabelFailed") + ")"); + } else { + if ("Cancelled" == lastResult) { + options.lastResultElem.html('(' + Globalize.translate("LabelCancelled") + ")"); + } else { + if ("Aborted" == lastResult) { + options.lastResultElem.html('' + Globalize.translate("LabelAbortedByServerShutdown") + ""); + } else { + options.lastResultElem.html(lastResult); + } + } + } } } } function onScheduledTaskMessageConfirmed(id) { - connectionManager.getApiClient(serverId).startScheduledTask(id).then(pollTasks) + connectionManager.getApiClient(serverId).startScheduledTask(id).then(pollTasks); } function onButtonClick() { - onScheduledTaskMessageConfirmed(this.getAttribute("data-taskid")) + onScheduledTaskMessageConfirmed(this.getAttribute("data-taskid")); } function onScheduledTasksUpdate(e, apiClient, info) { - apiClient.serverId() === serverId && updateTasks(info) + if (apiClient.serverId() === serverId) { + updateTasks(info); + } } function onPollIntervalFired() { - connectionManager.getApiClient(serverId).isMessageChannelOpen() || pollTasks() + if (!connectionManager.getApiClient(serverId).isMessageChannelOpen()) { + pollTasks(); + } } - var pollInterval, button = options.button, - serverId = ApiClient.serverId(); - options.panel && options.panel.classList.add("hide"), "off" == options.mode ? (button.removeEventListener("click", onButtonClick), events.off(serverNotifications, "ScheduledTasksInfo", onScheduledTasksUpdate), function() { - connectionManager.getApiClient(serverId).sendMessage("ScheduledTasksInfoStop"), pollInterval && clearInterval(pollInterval) - }()) : (button.addEventListener("click", onButtonClick), pollTasks(), function() { - var apiClient = connectionManager.getApiClient(serverId); - pollInterval && clearInterval(pollInterval), apiClient.sendMessage("ScheduledTasksInfoStart", "1000,1000"), pollInterval = setInterval(onPollIntervalFired, 1e4) - }(), events.on(serverNotifications, "ScheduledTasksInfo", onScheduledTasksUpdate)) - } -}); \ No newline at end of file + + var pollInterval; + var button = options.button; + var serverId = ApiClient.serverId(); + + if (options.panel) { + options.panel.classList.add("hide"); + } + + if ("off" == options.mode) { + button.removeEventListener("click", onButtonClick); + events.off(serverNotifications, "ScheduledTasksInfo", onScheduledTasksUpdate); + + (function () { + connectionManager.getApiClient(serverId).sendMessage("ScheduledTasksInfoStop"); + + if (pollInterval) { + clearInterval(pollInterval); + } + })(); + } else { + button.addEventListener("click", onButtonClick); + pollTasks(); + + (function () { + var apiClient = connectionManager.getApiClient(serverId); + + if (pollInterval) { + clearInterval(pollInterval); + } + + apiClient.sendMessage("ScheduledTasksInfoStart", "1000,1000"); + pollInterval = setInterval(onPollIntervalFired, 1e4); + })(); + + events.on(serverNotifications, "ScheduledTasksInfo", onScheduledTasksUpdate); + } + }; +}); From 3464b847a6d118c49c905dd2f03aa2069a4a3848 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 01:28:15 +0300 Subject: [PATCH 10/24] wizardfinishpage.js --- src/controllers/wizardfinishpage.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/controllers/wizardfinishpage.js b/src/controllers/wizardfinishpage.js index 417b2425a5..ba26190a5f 100644 --- a/src/controllers/wizardfinishpage.js +++ b/src/controllers/wizardfinishpage.js @@ -1,22 +1,24 @@ -define(["loading"], function(loading) { +define(["loading"], function (loading) { "use strict"; function onFinish() { - loading.show(), ApiClient.ajax({ + loading.show(); + ApiClient.ajax({ url: ApiClient.getUrl("Startup/Complete"), type: "POST" - }).then(function() { + }).then(function () { Dashboard.navigate("dashboard.html"); loading.hide(); }); } - return function(view, params) { + + return function (view, params) { view.querySelector(".btnWizardNext").addEventListener("click", onFinish); - view.addEventListener("viewshow", function() { - document.querySelector(".skinHeader").classList.add("noHomeButtonHeader") + view.addEventListener("viewshow", function () { + document.querySelector(".skinHeader").classList.add("noHomeButtonHeader"); }); - view.addEventListener("viewhide", function() { - document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader") + view.addEventListener("viewhide", function () { + document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader"); }); }; }); From f9b6b10ef4ed1c979fc4734a0ac40007e79e6c20 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 01:28:30 +0300 Subject: [PATCH 11/24] wizardremoteaccess.js --- src/controllers/wizardremoteaccess.js | 40 ++++++++++++++++----------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/controllers/wizardremoteaccess.js b/src/controllers/wizardremoteaccess.js index 6856e0074f..554a417e57 100644 --- a/src/controllers/wizardremoteaccess.js +++ b/src/controllers/wizardremoteaccess.js @@ -1,31 +1,39 @@ -define(["loading", "emby-checkbox", "emby-button", "emby-select"], function(loading) { +define(["loading", "emby-checkbox", "emby-button", "emby-select"], function (loading) { "use strict"; function save(page) { loading.show(); - var apiClient = ApiClient, - config = {}; - config.EnableRemoteAccess = page.querySelector("#chkRemoteAccess").checked, config.EnableAutomaticPortMapping = page.querySelector("#chkEnableUpnp").checked, apiClient.ajax({ + var apiClient = ApiClient; + var config = {}; + config.EnableRemoteAccess = page.querySelector("#chkRemoteAccess").checked; + config.EnableAutomaticPortMapping = page.querySelector("#chkEnableUpnp").checked; + apiClient.ajax({ type: "POST", data: config, url: apiClient.getUrl("Startup/RemoteAccess") - }).then(function() { - loading.hide(), navigateToNextPage() - }) + }).then(function () { + loading.hide(); + navigateToNextPage(); + }); } function navigateToNextPage() { - Dashboard.navigate("wizardfinish.html") + Dashboard.navigate("wizardfinish.html"); } function onSubmit(e) { - return save(this), e.preventDefault(), !1 - } - return function(view, params) { - view.querySelector(".wizardSettingsForm").addEventListener("submit", onSubmit), view.addEventListener("viewshow", function() { - document.querySelector(".skinHeader").classList.add("noHomeButtonHeader") - }), view.addEventListener("viewhide", function() { - document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader") - }) + save(this); + e.preventDefault(); + return false; } + + return function (view, params) { + view.querySelector(".wizardSettingsForm").addEventListener("submit", onSubmit); + view.addEventListener("viewshow", function () { + document.querySelector(".skinHeader").classList.add("noHomeButtonHeader"); + }); + view.addEventListener("viewhide", function () { + document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader"); + }); + }; }); From c94e970ac029ca05e6bffff7d5fa173fd13d4434 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 01:28:44 +0300 Subject: [PATCH 12/24] wizardsettings.js --- src/controllers/wizardsettings.js | 75 +++++++++++++++++++------------ 1 file changed, 46 insertions(+), 29 deletions(-) diff --git a/src/controllers/wizardsettings.js b/src/controllers/wizardsettings.js index 6303d95efa..487f068a40 100644 --- a/src/controllers/wizardsettings.js +++ b/src/controllers/wizardsettings.js @@ -1,67 +1,84 @@ -define(["loading", "emby-checkbox", "emby-button", "emby-select"], function(loading) { +define(["loading", "emby-checkbox", "emby-button", "emby-select"], function (loading) { "use strict"; function save(page) { loading.show(); var apiClient = ApiClient; - apiClient.getJSON(apiClient.getUrl("Startup/Configuration")).then(function(config) { - config.PreferredMetadataLanguage = page.querySelector("#selectLanguage").value, config.MetadataCountryCode = page.querySelector("#selectCountry").value, apiClient.ajax({ + apiClient.getJSON(apiClient.getUrl("Startup/Configuration")).then(function (config) { + config.PreferredMetadataLanguage = page.querySelector("#selectLanguage").value; + config.MetadataCountryCode = page.querySelector("#selectCountry").value; + apiClient.ajax({ type: "POST", data: config, url: apiClient.getUrl("Startup/Configuration") - }).then(function() { - loading.hide(), navigateToNextPage() - }) - }) + }).then(function () { + loading.hide(); + navigateToNextPage(); + }); + }); } function populateLanguages(select, languages) { var html = ""; html += ""; + for (var i = 0, length = languages.length; i < length; i++) { var culture = languages[i]; - html += "" + html += ""; } - select.innerHTML = html + + select.innerHTML = html; } function populateCountries(select, allCountries) { var html = ""; html += ""; + for (var i = 0, length = allCountries.length; i < length; i++) { var culture = allCountries[i]; - html += "" + html += ""; } - select.innerHTML = html + + select.innerHTML = html; } function reloadData(page, config, cultures, countries) { - populateLanguages(page.querySelector("#selectLanguage"), cultures), populateCountries(page.querySelector("#selectCountry"), countries), page.querySelector("#selectLanguage").value = config.PreferredMetadataLanguage, page.querySelector("#selectCountry").value = config.MetadataCountryCode, loading.hide() + populateLanguages(page.querySelector("#selectLanguage"), cultures); + populateCountries(page.querySelector("#selectCountry"), countries); + page.querySelector("#selectLanguage").value = config.PreferredMetadataLanguage; + page.querySelector("#selectCountry").value = config.MetadataCountryCode; + loading.hide(); } function reload(page) { loading.show(); - var apiClient = ApiClient, - promise1 = apiClient.getJSON(apiClient.getUrl("Startup/Configuration")), - promise2 = apiClient.getCultures(), - promise3 = apiClient.getCountries(); - Promise.all([promise1, promise2, promise3]).then(function(responses) { - reloadData(page, responses[0], responses[1], responses[2]) - }) + var apiClient = ApiClient; + var promise1 = apiClient.getJSON(apiClient.getUrl("Startup/Configuration")); + var promise2 = apiClient.getCultures(); + var promise3 = apiClient.getCountries(); + Promise.all([promise1, promise2, promise3]).then(function (responses) { + reloadData(page, responses[0], responses[1], responses[2]); + }); } function navigateToNextPage() { - Dashboard.navigate("wizardremoteaccess.html") + Dashboard.navigate("wizardremoteaccess.html"); } function onSubmit(e) { - return save(this), e.preventDefault(), !1 + save(this); + e.preventDefault(); + return false; } - return function(view, params) { - view.querySelector(".wizardSettingsForm").addEventListener("submit", onSubmit), view.addEventListener("viewshow", function() { - document.querySelector(".skinHeader").classList.add("noHomeButtonHeader"), reload(this) - }), view.addEventListener("viewhide", function() { - document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader") - }) - } -}); \ No newline at end of file + + return function (view, params) { + view.querySelector(".wizardSettingsForm").addEventListener("submit", onSubmit); + view.addEventListener("viewshow", function () { + document.querySelector(".skinHeader").classList.add("noHomeButtonHeader"); + reload(this); + }); + view.addEventListener("viewhide", function () { + document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader"); + }); + }; +}); From e192f1f3c6b138e60e6d18c67d1fad76047b2299 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 01:28:58 +0300 Subject: [PATCH 13/24] wizardstart.js --- src/controllers/wizardstart.js | 59 +++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/src/controllers/wizardstart.js b/src/controllers/wizardstart.js index 568ef15b2b..1c2917b9ec 100644 --- a/src/controllers/wizardstart.js +++ b/src/controllers/wizardstart.js @@ -1,41 +1,48 @@ -define(["jQuery", "loading", "emby-button", "emby-select"], function($, loading) { +define(["jQuery", "loading", "emby-button", "emby-select"], function ($, loading) { "use strict"; function loadPage(page, config, languageOptions) { - $("#selectLocalizationLanguage", page).html(languageOptions.map(function(l) { - return '" - })).val(config.UICulture), loading.hide() + $("#selectLocalizationLanguage", page).html(languageOptions.map(function (l) { + return '"; + })).val(config.UICulture); + loading.hide(); } function save(page) { loading.show(); var apiClient = ApiClient; - apiClient.getJSON(apiClient.getUrl("Startup/Configuration")).then(function(config) { - config.UICulture = $("#selectLocalizationLanguage", page).val(), apiClient.ajax({ + apiClient.getJSON(apiClient.getUrl("Startup/Configuration")).then(function (config) { + config.UICulture = $("#selectLocalizationLanguage", page).val(); + apiClient.ajax({ type: "POST", data: config, url: apiClient.getUrl("Startup/Configuration") - }).then(function() { - Dashboard.navigate("wizarduser.html") - }) - }) + }).then(function () { + Dashboard.navigate("wizarduser.html"); + }); + }); } function onSubmit() { - return save($(this).parents(".page")), !1 + save($(this).parents(".page")); + return false; } - return function(view, params) { - $(".wizardStartForm", view).on("submit", onSubmit), view.addEventListener("viewshow", function() { - document.querySelector(".skinHeader").classList.add("noHomeButtonHeader"), loading.show(); - var page = this, - apiClient = ApiClient, - promise1 = apiClient.getJSON(apiClient.getUrl("Startup/Configuration")), - promise2 = apiClient.getJSON(apiClient.getUrl("Localization/Options")); - Promise.all([promise1, promise2]).then(function(responses) { - loadPage(page, responses[0], responses[1]) - }) - }), view.addEventListener("viewhide", function() { - document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader") - }) - } -}); \ No newline at end of file + + return function (view, params) { + $(".wizardStartForm", view).on("submit", onSubmit); + view.addEventListener("viewshow", function () { + document.querySelector(".skinHeader").classList.add("noHomeButtonHeader"); + loading.show(); + var page = this; + var apiClient = ApiClient; + var promise1 = apiClient.getJSON(apiClient.getUrl("Startup/Configuration")); + var promise2 = apiClient.getJSON(apiClient.getUrl("Localization/Options")); + Promise.all([promise1, promise2]).then(function (responses) { + loadPage(page, responses[0], responses[1]); + }); + }); + view.addEventListener("viewhide", function () { + document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader"); + }); + }; +}); From e0cf0141974b59e3c833f05e514278232bb01a0b Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 01:29:20 +0300 Subject: [PATCH 14/24] wizarduserpage.js --- src/controllers/wizarduserpage.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/controllers/wizarduserpage.js b/src/controllers/wizarduserpage.js index a3654edf0e..d29be37c13 100644 --- a/src/controllers/wizarduserpage.js +++ b/src/controllers/wizarduserpage.js @@ -1,4 +1,4 @@ -define(["loading", "globalize", "dashboardcss", "emby-input", "emby-button", "emby-button"], function(loading, globalize) { +define(["loading", "globalize", "dashboardcss", "emby-input", "emby-button", "emby-button"], function (loading, globalize) { "use strict"; function getApiClient() { @@ -30,13 +30,15 @@ define(["loading", "globalize", "dashboardcss", "emby-input", "emby-button", "em function onSubmit(e) { var form = this; + if (form.querySelector("#txtManualPassword").value != form.querySelector("#txtPasswordConfirm").value) { - require(["toast"], function(toast) { + require(["toast"], function (toast) { toast(Globalize.translate("PasswordMatchError")); }); } else { submit(form); } + e.preventDefault(); return false; } @@ -45,20 +47,21 @@ define(["loading", "globalize", "dashboardcss", "emby-input", "emby-button", "em loading.show(); var page = this; var apiClient = getApiClient(); - apiClient.getJSON(apiClient.getUrl("Startup/User")).then(function(user) { + apiClient.getJSON(apiClient.getUrl("Startup/User")).then(function (user) { page.querySelector("#txtUsername").value = user.Name || ""; page.querySelector("#txtManualPassword").value = user.Password || ""; loading.hide(); - }) - } - return function(view, params) { - view.querySelector(".wizardUserForm").addEventListener("submit", onSubmit); - view.addEventListener("viewshow", function() { - document.querySelector(".skinHeader").classList.add("noHomeButtonHeader") }); - view.addEventListener("viewhide", function() { - document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader") + } + + return function (view, params) { + view.querySelector(".wizardUserForm").addEventListener("submit", onSubmit); + view.addEventListener("viewshow", function () { + document.querySelector(".skinHeader").classList.add("noHomeButtonHeader"); + }); + view.addEventListener("viewhide", function () { + document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader"); }); view.addEventListener("viewshow", onViewShow); - } + }; }); From 5ebf1bda80f296a572e73d0edac1a9f1fcca1d2a Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 01:29:47 +0300 Subject: [PATCH 15/24] themeloader.js --- src/scripts/themeloader.js | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/scripts/themeloader.js b/src/scripts/themeloader.js index eb783b132d..ea7ff57f9a 100644 --- a/src/scripts/themeloader.js +++ b/src/scripts/themeloader.js @@ -1,15 +1,27 @@ -define(["userSettings", "skinManager", "connectionManager", "events"], function(userSettings, skinManager, connectionManager, events) { +define(["userSettings", "skinManager", "connectionManager", "events"], function (userSettings, skinManager, connectionManager, events) { "use strict"; + var currentViewType; - pageClassOn("viewbeforeshow", "page", function() { - var classList = this.classList, - viewType = classList.contains("type-interior") || classList.contains("wizardPage") ? "a" : "b"; + pageClassOn("viewbeforeshow", "page", function () { + var classList = this.classList; + var viewType = classList.contains("type-interior") || classList.contains("wizardPage") ? "a" : "b"; + if (viewType !== currentViewType) { currentViewType = viewType; - var theme, context; - "a" === viewType ? (theme = userSettings.dashboardTheme(), context = "serverdashboard") : theme = userSettings.theme(), skinManager.setTheme(theme, context) + var theme; + var context; + + if ("a" === viewType) { + theme = userSettings.dashboardTheme(); + context = "serverdashboard"; + } else { + theme = userSettings.theme(); + } + + skinManager.setTheme(theme, context); } - }), events.on(connectionManager, "localusersignedin", function(e, user) { - currentViewType = null - }) -}); \ No newline at end of file + }); + events.on(connectionManager, "localusersignedin", function (e, user) { + currentViewType = null; + }); +}); From 678b558935b684c207c61005218fe0448bcf7f95 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 01:30:02 +0300 Subject: [PATCH 16/24] userpassword.js --- src/scripts/userpassword.js | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/scripts/userpassword.js b/src/scripts/userpassword.js index 41dc290248..52e06e6cec 100644 --- a/src/scripts/userpassword.js +++ b/src/scripts/userpassword.js @@ -1,20 +1,30 @@ -define(["jQuery", "loading", "libraryMenu"], function($, loading, libraryMenu) { +define(["jQuery", "loading", "libraryMenu"], function ($, loading, libraryMenu) { "use strict"; function loadUser(page, user) { - libraryMenu.setTitle(user.Name), "Guest" == user.ConnectLinkType ? $(".connectMessage", page).show() : $(".connectMessage", page).hide(), loading.hide() + libraryMenu.setTitle(user.Name); + + if ("Guest" == user.ConnectLinkType) { + $(".connectMessage", page).show(); + } else { + $(".connectMessage", page).hide(); + } + + loading.hide(); } function loadData(page) { loading.show(); var userId = getParameterByName("userId"); - ApiClient.getUser(userId).then(function(user) { - loadUser(page, user) - }) + ApiClient.getUser(userId).then(function (user) { + loadUser(page, user); + }); } - $(document).on("pageinit", "#userPasswordPage", function() { - $(".adminUpdatePasswordForm").off("submit", UpdatePasswordPage.onSubmit).on("submit", UpdatePasswordPage.onSubmit), $(".adminLocalAccessForm").off("submit", UpdatePasswordPage.onLocalAccessSubmit).on("submit", UpdatePasswordPage.onLocalAccessSubmit) - }).on("pagebeforeshow", "#userPasswordPage", function() { - loadData(this) - }) -}); \ No newline at end of file + + $(document).on("pageinit", "#userPasswordPage", function () { + $(".adminUpdatePasswordForm").off("submit", UpdatePasswordPage.onSubmit).on("submit", UpdatePasswordPage.onSubmit); + $(".adminLocalAccessForm").off("submit", UpdatePasswordPage.onLocalAccessSubmit).on("submit", UpdatePasswordPage.onLocalAccessSubmit); + }).on("pagebeforeshow", "#userPasswordPage", function () { + loadData(this); + }); +}); From 307e66428609f5c116b975df03d4b93b21925ae6 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 01:30:21 +0300 Subject: [PATCH 17/24] wizardagreement.js --- src/scripts/wizardagreement.js | 36 ++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/scripts/wizardagreement.js b/src/scripts/wizardagreement.js index 77c12fb664..148b0ef39a 100644 --- a/src/scripts/wizardagreement.js +++ b/src/scripts/wizardagreement.js @@ -1,17 +1,27 @@ -define(["dom", "emby-button"], function(dom) { +define(["dom", "emby-button"], function (dom) { "use strict"; function onSubmit(e) { - return dom.parentWithClass(this, "page").querySelector(".chkAccept").checked ? Dashboard.navigate("wizardfinish.html") : Dashboard.alert({ - message: Globalize.translate("MessagePleaseAcceptTermsOfServiceBeforeContinuing"), - title: "" - }), e.preventDefault(), !1 + if (dom.parentWithClass(this, "page").querySelector(".chkAccept").checked) { + Dashboard.navigate("wizardfinish.html"); + } else { + Dashboard.alert({ + message: Globalize.translate("MessagePleaseAcceptTermsOfServiceBeforeContinuing"), + title: "" + }); + } + + e.preventDefault(); + return false; } - return function(view, params) { - view.querySelector(".wizardAgreementForm").addEventListener("submit", onSubmit), view.addEventListener("viewshow", function() { - document.querySelector(".skinHeader").classList.add("noHomeButtonHeader") - }), view.addEventListener("viewhide", function() { - document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader") - }) - } -}); \ No newline at end of file + + return function (view, params) { + view.querySelector(".wizardAgreementForm").addEventListener("submit", onSubmit); + view.addEventListener("viewshow", function () { + document.querySelector(".skinHeader").classList.add("noHomeButtonHeader"); + }); + view.addEventListener("viewhide", function () { + document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader"); + }); + }; +}); From e7570d856fd214d5805291fcc5498763bc1e08f9 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 19:54:02 +0300 Subject: [PATCH 18/24] Update Suggested change --- src/scripts/itembynamedetailpage.js | 32 ++++++------- src/scripts/librarybrowser.js | 7 ++- src/scripts/librarymenu.js | 6 ++- src/scripts/livetvcomponents.js | 15 ++++--- src/scripts/playlists.js | 70 ++++++++++++++++------------- src/scripts/taskbutton.js | 60 ++++++++++++++++--------- 6 files changed, 106 insertions(+), 84 deletions(-) diff --git a/src/scripts/itembynamedetailpage.js b/src/scripts/itembynamedetailpage.js index 1de421e6a3..74d69eecf8 100644 --- a/src/scripts/itembynamedetailpage.js +++ b/src/scripts/itembynamedetailpage.js @@ -312,27 +312,21 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB } function addCurrentItemToQuery(query, item) { - if ("Person" == item.Type) { + if (item.Type == "Person") { query.PersonIds = item.Id; - } else { - if ("Genre" == item.Type) { - query.GenreIds = item.Id; + } else if (item.Type == "Genre") { + query.Genres = item.Name; + } else if (item.Type == "MusicGenre") { + query.Genres = item.Name; + } else if (item.Type == "GameGenre") { + query.Genres = item.Name; + } else if (item.Type == "Studio") { + query.StudioIds = item.Id; + } else if (item.Type == "MusicArtist") { + if (connectionManager.getApiClient(item.ServerId).isMinServerVersion("3.4.1.18")) { + query.AlbumArtistIds = item.Id; } else { - if ("MusicGenre" == item.Type) { - query.GenreIds = item.Id; - } else { - if ("Studio" == item.Type) { - query.StudioIds = item.Id; - } else { - if ("MusicArtist" == item.Type) { - if (connectionManager.getApiClient(item.ServerId).isMinServerVersion("3.4.1.18")) { - query.AlbumArtistIds = item.Id; - } else { - query.ArtistIds = item.Id; - } - } - } - } + query.ArtistIds = item.Id; } } } diff --git a/src/scripts/librarybrowser.js b/src/scripts/librarybrowser.js index f2edc9030c..4f3eaf4144 100644 --- a/src/scripts/librarybrowser.js +++ b/src/scripts/librarybrowser.js @@ -156,11 +156,10 @@ define(["userSettings"], function (userSettings) { html += '

'; html += Globalize.translate("HeaderSortBy"); html += "

"; - var i; - var length; + var i, length; var isChecked; - - for (html += "
", i = 0, length = options.items.length; i < length; i++) { + html += '
'; + for (i = 0, length = options.items.length; i < length; i++) { var option = options.items[i]; var radioValue = option.id.replace(",", "_"); isChecked = (options.query.SortBy || "").replace(",", "_") == radioValue ? " checked" : ""; diff --git a/src/scripts/librarymenu.js b/src/scripts/librarymenu.js index 6b64041966..50031b33b8 100644 --- a/src/scripts/librarymenu.js +++ b/src/scripts/librarymenu.js @@ -206,8 +206,9 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " html += 'exit_to_app' + globalize.translate("ButtonSignOut") + ""; html += "
"; - } // add buttons to navigation drawer + } + // add buttons to navigation drawer navDrawerScrollContainer.innerHTML = html; // bind logout button click to method @@ -501,8 +502,9 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " showBySelector(".libraryMenuDownloads", false); showBySelector(".lnkSyncToOtherDevices", false); return void showBySelector(".userMenuOptions", false); - } // FIXME: Potentially the same as above + } + // FIXME: Potentially the same as above if (user.Policy.EnableContentDownloading) { showBySelector(".lnkSyncToOtherDevices", true); diff --git a/src/scripts/livetvcomponents.js b/src/scripts/livetvcomponents.js index a883885df1..cc0e94ca3f 100644 --- a/src/scripts/livetvcomponents.js +++ b/src/scripts/livetvcomponents.js @@ -6,11 +6,7 @@ define(["layoutManager", "datetime", "cardBuilder", "apphost"], function (layout } function getBackdropShape() { - if (enableScrollX()) { - return "overflowBackdrop"; - } - - return "backdrop"; + return enableScrollX() ? 'overflowBackdrop' : 'backdrop'; } function getTimersHtml(timers, options) { @@ -29,7 +25,7 @@ define(["layoutManager", "datetime", "cardBuilder", "apphost"], function (layout var item = items[i]; var dateText = ""; - if (false !== options.indexByDate && item.StartDate) { + if (options.indexByDate !== false && item.StartDate) { try { var premiereDate = datetime.parseISO8601Date(item.StartDate, true); dateText = datetime.toLocaleDateString(premiereDate, { @@ -69,7 +65,12 @@ define(["layoutManager", "datetime", "cardBuilder", "apphost"], function (layout var supportsImageAnalysis = appHost.supports("imageanalysis"); var cardLayout = appHost.preferVisualCards || supportsImageAnalysis; - if (cardLayout = true, group.name && (html += '
', html += '

' + group.name + "

"), enableScrollX()) { + cardLayout = true; + if (group.name) { + html += '
'; + html += '

' + group.name + "

"; + } + if (enableScrollX()) { var scrollXClass = "scrollX hiddenScrollX"; if (layoutManager.tv) { diff --git a/src/scripts/playlists.js b/src/scripts/playlists.js index 606a34c787..91c49017da 100644 --- a/src/scripts/playlists.js +++ b/src/scripts/playlists.js @@ -85,36 +85,46 @@ define(["loading", "listView", "cardBuilder", "libraryMenu", "libraryBrowser", " }); if (result.TotalRecordCount) { - html = "List" == viewStyle ? listView.getListViewHtml({ - items: result.Items, - sortBy: query.SortBy - }) : "PosterCard" == viewStyle ? cardBuilder.getCardsHtml({ - items: result.Items, - shape: "square", - coverImage: true, - showTitle: true, - cardLayout: true - }) : "Thumb" == viewStyle ? cardBuilder.getCardsHtml({ - items: result.Items, - shape: "backdrop", - showTitle: true, - centerText: true, - preferThumb: true, - overlayPlayButton: true - }) : "ThumbCard" == viewStyle ? cardBuilder.getCardsHtml({ - items: result.Items, - shape: "backdrop", - showTitle: true, - preferThumb: true, - cardLayout: true - }) : cardBuilder.getCardsHtml({ - items: result.Items, - shape: "square", - showTitle: true, - coverImage: true, - centerText: true, - overlayPlayButton: true - }); + if (viewStyle == "List") { + html = listView.getListViewHtml({ + items: result.Items, + sortBy: query.SortBy + }); + } else if (viewStyle == "PosterCard") { + html = cardBuilder.getCardsHtml({ + items: result.Items, + shape: "square", + coverImage: true, + showTitle: true, + cardLayout: true + }); + } else if (viewStyle == "Thumb") { + html = cardBuilder.getCardsHtml({ + items: result.Items, + shape: "backdrop", + showTitle: true, + centerText: true, + preferThumb: true, + overlayPlayButton: true + }); + } else if (viewStyle == "ThumbCard") { + html = cardBuilder.getCardsHtml({ + items: result.Items, + shape: "backdrop", + showTitle: true, + preferThumb: true, + cardLayout: true + }); + } else { + html = cardBuilder.getCardsHtml({ + items: result.Items, + shape: "square", + showTitle: true, + coverImage: true, + centerText: true, + overlayPlayButton: true + }); + } view.querySelector(".noItemsMessage").classList.add("hide"); } else { view.querySelector(".noItemsMessage").classList.remove("hide"); diff --git a/src/scripts/taskbutton.js b/src/scripts/taskbutton.js index 37e4a3c973..7e75e9423b 100644 --- a/src/scripts/taskbutton.js +++ b/src/scripts/taskbutton.js @@ -13,32 +13,48 @@ define(["events", "userSettings", "serverNotifications", "connectionManager", "e return t.Key == options.taskKey; })[0]; - if (options.panel && (task ? options.panel.classList.remove("hide") : options.panel.classList.add("hide")), task) { - if ("Idle" == task.State) { - button.removeAttribute("disabled"); + if (options.panel) { + if (task) { + options.panel.classList.remove('hide'); } else { - button.setAttribute("disabled", "disabled"); + options.panel.classList.add('hide'); } + } - button.setAttribute("data-taskid", task.Id); - var progress = (task.CurrentProgressPercentage || 0).toFixed(1); + if (!task) { + return; + } - if (options.progressElem && (options.progressElem.value = progress, "Running" == task.State ? options.progressElem.classList.remove("hide") : options.progressElem.classList.add("hide")), options.lastResultElem) { - var lastResult = task.LastExecutionResult ? task.LastExecutionResult.Status : ""; + if (task.State == 'Idle') { + button.removeAttribute("disabled"); + } else { + button.setAttribute("disabled", "disabled"); + } - if ("Failed" == lastResult) { - options.lastResultElem.html('(' + Globalize.translate("LabelFailed") + ")"); - } else { - if ("Cancelled" == lastResult) { - options.lastResultElem.html('(' + Globalize.translate("LabelCancelled") + ")"); - } else { - if ("Aborted" == lastResult) { - options.lastResultElem.html('' + Globalize.translate("LabelAbortedByServerShutdown") + ""); - } else { - options.lastResultElem.html(lastResult); - } - } - } + button.setAttribute("data-taskid", task.Id); + var progress = (task.CurrentProgressPercentage || 0).toFixed(1); + + if (options.progressElem) { + options.progressElem.value = progress; + + if (task.State == 'Running') { + options.progressElem.classList.remove('hide'); + } else { + options.progressElem.classList.add('hide'); + } + } + + if (options.lastResultElem) { + var lastResult = task.LastExecutionResult ? task.LastExecutionResult.Status : ''; + + if (lastResult == "Failed") { + options.lastResultElem.html('(' + Globalize.translate('LabelFailed') + ')'); + } else if (lastResult == "Cancelled") { + options.lastResultElem.html('(' + Globalize.translate('LabelCancelled') + ')'); + } else if (lastResult == "Aborted") { + options.lastResultElem.html('' + Globalize.translate('LabelAbortedByServerShutdown') + ''); + } else { + options.lastResultElem.html(lastResult); } } } @@ -71,7 +87,7 @@ define(["events", "userSettings", "serverNotifications", "connectionManager", "e options.panel.classList.add("hide"); } - if ("off" == options.mode) { + if (options.mode == 'off') { button.removeEventListener("click", onButtonClick); events.off(serverNotifications, "ScheduledTasksInfo", onScheduledTasksUpdate); From 0e306cad76021063affb75f65af606ec0f2ed7fb Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 20:14:43 +0300 Subject: [PATCH 19/24] update taskbutton Suggested change --- src/scripts/taskbutton.js | 46 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/scripts/taskbutton.js b/src/scripts/taskbutton.js index 7e75e9423b..f9774167c0 100644 --- a/src/scripts/taskbutton.js +++ b/src/scripts/taskbutton.js @@ -73,15 +73,33 @@ define(["events", "userSettings", "serverNotifications", "connectionManager", "e } } + var pollInterval; + var button = options.button; + var serverId = ApiClient.serverId(); + function onPollIntervalFired() { if (!connectionManager.getApiClient(serverId).isMessageChannelOpen()) { pollTasks(); } } - var pollInterval; - var button = options.button; - var serverId = ApiClient.serverId(); + function startInterval() { + var apiClient = connectionManager.getApiClient(serverId); + + if (pollInterval) { + clearInterval(pollInterval); + } + apiClient.sendMessage("ScheduledTasksInfoStart", "1000,1000"); + pollInterval = setInterval(onPollIntervalFired, 5000); + } + + function stopInterval() { + connectionManager.getApiClient(serverId).sendMessage("ScheduledTasksInfoStop"); + + if (pollInterval) { + clearInterval(pollInterval); + } + } if (options.panel) { options.panel.classList.add("hide"); @@ -90,29 +108,11 @@ define(["events", "userSettings", "serverNotifications", "connectionManager", "e if (options.mode == 'off') { button.removeEventListener("click", onButtonClick); events.off(serverNotifications, "ScheduledTasksInfo", onScheduledTasksUpdate); - - (function () { - connectionManager.getApiClient(serverId).sendMessage("ScheduledTasksInfoStop"); - - if (pollInterval) { - clearInterval(pollInterval); - } - })(); + stopInterval(); } else { button.addEventListener("click", onButtonClick); pollTasks(); - - (function () { - var apiClient = connectionManager.getApiClient(serverId); - - if (pollInterval) { - clearInterval(pollInterval); - } - - apiClient.sendMessage("ScheduledTasksInfoStart", "1000,1000"); - pollInterval = setInterval(onPollIntervalFired, 1e4); - })(); - + startInterval(); events.on(serverNotifications, "ScheduledTasksInfo", onScheduledTasksUpdate); } }; From 6eb8e1b8fa8fb2ab28647cb3f8fbde80c7c4fb74 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 20:46:05 +0300 Subject: [PATCH 20/24] add console.log --- src/scripts/librarymenu.js | 3 ++- src/scripts/livetvcomponents.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/scripts/librarymenu.js b/src/scripts/librarymenu.js index 50031b33b8..ed6284b164 100644 --- a/src/scripts/librarymenu.js +++ b/src/scripts/librarymenu.js @@ -210,7 +210,8 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " // add buttons to navigation drawer - navDrawerScrollContainer.innerHTML = html; // bind logout button click to method + navDrawerScrollContainer.innerHTML = html; + // bind logout button click to method var btnLogout = navDrawerScrollContainer.querySelector(".btnLogout"); diff --git a/src/scripts/livetvcomponents.js b/src/scripts/livetvcomponents.js index cc0e94ca3f..983b86a478 100644 --- a/src/scripts/livetvcomponents.js +++ b/src/scripts/livetvcomponents.js @@ -33,7 +33,9 @@ define(["layoutManager", "datetime", "cardBuilder", "apphost"], function (layout month: "short", day: "numeric" }); - } catch (err) {} + } catch (err) { + console.log("Error parsing premiereDate:" + item.StartDate); + } } if (dateText != currentGroupName) { From 61897f15e20160bd6c58498eaef10cfde2ce8e7c Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Tue, 8 Oct 2019 21:00:31 +0300 Subject: [PATCH 21/24] double quote --- src/scripts/livetvcomponents.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/livetvcomponents.js b/src/scripts/livetvcomponents.js index 983b86a478..fb8dadef78 100644 --- a/src/scripts/livetvcomponents.js +++ b/src/scripts/livetvcomponents.js @@ -6,7 +6,7 @@ define(["layoutManager", "datetime", "cardBuilder", "apphost"], function (layout } function getBackdropShape() { - return enableScrollX() ? 'overflowBackdrop' : 'backdrop'; + return enableScrollX() ? "overflowBackdrop" : "backdrop"; } function getTimersHtml(timers, options) { From d467499a7aab68e0ffa865582602775cfb96bf1c Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Thu, 10 Oct 2019 20:40:27 +0300 Subject: [PATCH 22/24] remove new lines --- src/scripts/librarymenu.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/scripts/librarymenu.js b/src/scripts/librarymenu.js index ed6284b164..18eddb08bc 100644 --- a/src/scripts/librarymenu.js +++ b/src/scripts/librarymenu.js @@ -208,11 +208,10 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " html += "
"; } - // add buttons to navigation drawer + // add buttons to navigation drawer navDrawerScrollContainer.innerHTML = html; // bind logout button click to method - var btnLogout = navDrawerScrollContainer.querySelector(".btnLogout"); if (btnLogout) { @@ -506,7 +505,6 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " } // FIXME: Potentially the same as above - if (user.Policy.EnableContentDownloading) { showBySelector(".lnkSyncToOtherDevices", true); } else { From af3579f328781247f008fa5f05940993fae945fa Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Thu, 10 Oct 2019 20:41:58 +0300 Subject: [PATCH 23/24] update console.log livetvcomponents --- src/scripts/livetvcomponents.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/livetvcomponents.js b/src/scripts/livetvcomponents.js index fb8dadef78..4215de4cbe 100644 --- a/src/scripts/livetvcomponents.js +++ b/src/scripts/livetvcomponents.js @@ -34,7 +34,7 @@ define(["layoutManager", "datetime", "cardBuilder", "apphost"], function (layout day: "numeric" }); } catch (err) { - console.log("Error parsing premiereDate:" + item.StartDate); + console.log("Error parsing premiereDate:" + item.StartDate + "; error: " + err); } } From 03a16287a033c45812fe5ecee444d1b98fb207c3 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Thu, 10 Oct 2019 20:43:04 +0300 Subject: [PATCH 24/24] remove query.Artistids conditions --- src/scripts/itembynamedetailpage.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/scripts/itembynamedetailpage.js b/src/scripts/itembynamedetailpage.js index 74d69eecf8..5d3c9dedb9 100644 --- a/src/scripts/itembynamedetailpage.js +++ b/src/scripts/itembynamedetailpage.js @@ -323,11 +323,7 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB } else if (item.Type == "Studio") { query.StudioIds = item.Id; } else if (item.Type == "MusicArtist") { - if (connectionManager.getApiClient(item.ServerId).isMinServerVersion("3.4.1.18")) { - query.AlbumArtistIds = item.Id; - } else { - query.ArtistIds = item.Id; - } + query.AlbumArtistIds = item.Id; } }