Merge pull request #511 from grafixeyehero/Deminify-part-3-components

Deminify part 3
This commit is contained in:
dkanada 2019-10-27 04:01:38 +09:00 committed by GitHub
commit e89a45e887
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 982 additions and 492 deletions

View File

@ -1,19 +1,33 @@
define(["dialogHelper", "datetime", "emby-select", "paper-icon-button-light", "formDialogStyle"], function(dialogHelper, datetime) {
define(["dialogHelper", "datetime", "emby-select", "paper-icon-button-light", "formDialogStyle"], function (dialogHelper, datetime) {
"use strict";
function getDisplayTime(hours) {
var minutes = 0,
pct = hours % 1;
return pct && (minutes = parseInt(60 * pct)), datetime.getDisplayTime(new Date(2e3, 1, 1, hours, minutes, 0, 0))
var minutes = 0;
var pct = hours % 1;
if (pct) {
minutes = parseInt(60 * pct);
}
return datetime.getDisplayTime(new Date(2000, 1, 1, hours, minutes, 0, 0));
}
function populateHours(context) {
for (var html = "", i = 0; i < 24; i++) html += '<option value="' + i + '">' + getDisplayTime(i) + "</option>";
html += '<option value="24">' + getDisplayTime(0) + "</option>", context.querySelector("#selectStart").innerHTML = html, context.querySelector("#selectEnd").innerHTML = html
var html = "";
for (var i = 0; i < 24; i++) {
html += '<option value="' + i + '">' + getDisplayTime(i) + "</option>";
}
html += '<option value="24">' + getDisplayTime(0) + "</option>";
context.querySelector("#selectStart").innerHTML = html;
context.querySelector("#selectEnd").innerHTML = html;
}
function loadSchedule(context, schedule) {
context.querySelector("#selectDay").value = schedule.DayOfWeek || "Sunday", context.querySelector("#selectStart").value = schedule.StartHour || 0, context.querySelector("#selectEnd").value = schedule.EndHour || 0
context.querySelector("#selectDay").value = schedule.DayOfWeek || "Sunday";
context.querySelector("#selectStart").value = schedule.StartHour || 0;
context.querySelector("#selectEnd").value = schedule.EndHour || 0;
}
function submitSchedule(context, options) {
@ -22,30 +36,54 @@ define(["dialogHelper", "datetime", "emby-select", "paper-icon-button-light", "f
StartHour: context.querySelector("#selectStart").value,
EndHour: context.querySelector("#selectEnd").value
};
if (parseFloat(updatedSchedule.StartHour) >= parseFloat(updatedSchedule.EndHour)) return void alert(Globalize.translate("ErrorMessageStartHourGreaterThanEnd"));
context.submitted = !0, options.schedule = Object.assign(options.schedule, updatedSchedule), dialogHelper.close(context)
if (parseFloat(updatedSchedule.StartHour) >= parseFloat(updatedSchedule.EndHour)) {
return void alert(Globalize.translate("ErrorMessageStartHourGreaterThanEnd"));
}
context.submitted = true;
options.schedule = Object.assign(options.schedule, updatedSchedule);
dialogHelper.close(context);
}
return {
show: function(options) {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest;
xhr.open("GET", "components/accessschedule/accessschedule.template.html", !0), xhr.onload = function(e) {
var template = this.response,
dlg = dialogHelper.createDialog({
removeOnClose: !0,
size: "small"
});
show: function (options) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open("GET", "components/accessschedule/accessschedule.template.html", true);
xhr.onload = function (e) {
var template = this.response;
var dlg = dialogHelper.createDialog({
removeOnClose: true,
size: "small"
});
dlg.classList.add("formDialog");
var html = "";
html += Globalize.translateDocument(template), dlg.innerHTML = html, populateHours(dlg), loadSchedule(dlg, options.schedule), dialogHelper.open(dlg), dlg.addEventListener("close", function() {
dlg.submitted ? resolve(options.schedule) : reject()
}), dlg.querySelector(".btnCancel").addEventListener("click", function(e) {
dialogHelper.close(dlg)
}), dlg.querySelector("form").addEventListener("submit", function(e) {
return submitSchedule(dlg, options), e.preventDefault(), !1
})
}, xhr.send()
})
html += Globalize.translateDocument(template);
dlg.innerHTML = html;
populateHours(dlg);
loadSchedule(dlg, options.schedule);
dialogHelper.open(dlg);
dlg.addEventListener("close", function () {
if (dlg.submitted) {
resolve(options.schedule);
} else {
reject();
}
});
dlg.querySelector(".btnCancel").addEventListener("click", function (e) {
dialogHelper.close(dlg);
});
dlg.querySelector("form").addEventListener("submit", function (e) {
submitSchedule(dlg, options);
e.preventDefault();
return false;
});
};
xhr.send();
});
}
}
});
};
});

View File

@ -1,15 +1,17 @@
define(["events", "globalize", "dom", "datetime", "userSettings", "serverNotifications", "connectionManager", "emby-button", "listViewStyle"], function(events, globalize, dom, datetime, userSettings, serverNotifications, connectionManager) {
define(["events", "globalize", "dom", "datetime", "userSettings", "serverNotifications", "connectionManager", "emby-button", "listViewStyle"], function (events, globalize, dom, datetime, userSettings, serverNotifications, connectionManager) {
"use strict";
function getEntryHtml(entry, apiClient) {
var html = "";
html += '<div class="listItem listItem-border">';
var color = "#00a4dc";
var icon = "notifications";
var icon = "notifications";
if ("Error" == entry.Severity || "Fatal" == entry.Severity || "Warn" == entry.Severity) {
color = "#cc0000";
icon = "notification_important";
}
if (entry.UserId && entry.UserPrimaryImageTag) {
html += '<i class="listItemIcon md-icon" style="width:2em!important;height:2em!important;padding:0;color:transparent;background-color:' + color + ";background-image:url('" + apiClient.getUserImageUrl(entry.UserId, {
type: "Primary",
@ -18,78 +20,138 @@ define(["events", "globalize", "dom", "datetime", "userSettings", "serverNotific
} else {
html += '<i class="listItemIcon md-icon" style="background-color:' + color + '">' + icon + '</i>';
}
html += '<div class="listItemBody three-line">', html += '<div class="listItemBodyText">', html += entry.Name, html += "</div>", html += '<div class="listItemBodyText secondary">';
var date = datetime.parseISO8601Date(entry.Date, !0);
return html += datetime.toLocaleString(date).toLowerCase(), html += "</div>", html += '<div class="listItemBodyText secondary listItemBodyText-nowrap">', html += entry.ShortOverview || "", html += "</div>", html += "</div>", entry.Overview && (html += '<button type="button" is="paper-icon-button-light" class="btnEntryInfo" data-id="' + entry.Id + '" title="' + globalize.translate("Info") + '"><i class="md-icon">info</i></button>'), html += "</div>"
html += '<div class="listItemBody three-line">';
html += '<div class="listItemBodyText">';
html += entry.Name;
html += "</div>";
html += '<div class="listItemBodyText secondary">';
var date = datetime.parseISO8601Date(entry.Date, true);
html += datetime.toLocaleString(date).toLowerCase();
html += "</div>";
html += '<div class="listItemBodyText secondary listItemBodyText-nowrap">';
html += entry.ShortOverview || "";
html += "</div>";
html += "</div>";
if (entry.Overview) {
html += '<button type="button" is="paper-icon-button-light" class="btnEntryInfo" data-id="' + entry.Id + '" title="' + globalize.translate("Info") + '"><i class="md-icon">info</i></button>';
}
return html += "</div>";
}
function renderList(elem, apiClient, result, startIndex, limit) {
elem.innerHTML = result.Items.map(function(i) {
return getEntryHtml(i, apiClient)
}).join("")
elem.innerHTML = result.Items.map(function (i) {
return getEntryHtml(i, apiClient);
}).join("");
}
function reloadData(instance, elem, apiClient, startIndex, limit) {
null == startIndex && (startIndex = parseInt(elem.getAttribute("data-activitystartindex") || "0")), limit = limit || parseInt(elem.getAttribute("data-activitylimit") || "7");
var minDate = new Date,
hasUserId = "false" !== elem.getAttribute("data-useractivity");
hasUserId ? minDate.setTime(minDate.getTime() - 864e5) : minDate.setTime(minDate.getTime() - 6048e5), ApiClient.getJSON(ApiClient.getUrl("System/ActivityLog/Entries", {
if (null == startIndex) {
startIndex = parseInt(elem.getAttribute("data-activitystartindex") || "0");
}
limit = limit || parseInt(elem.getAttribute("data-activitylimit") || "7");
var minDate = new Date();
var hasUserId = "false" !== elem.getAttribute("data-useractivity");
if (hasUserId) {
minDate.setTime(minDate.getTime() - 24 * 60 * 60 * 1000); // one day back
} else {
minDate.setTime(minDate.getTime() - 7 * 24 * 60 * 60 * 1000); // one week back
}
ApiClient.getJSON(ApiClient.getUrl("System/ActivityLog/Entries", {
startIndex: startIndex,
limit: limit,
minDate: minDate.toISOString(),
hasUserId: hasUserId
})).then(function(result) {
if (elem.setAttribute("data-activitystartindex", startIndex), elem.setAttribute("data-activitylimit", limit), !startIndex) {
})).then(function (result) {
elem.setAttribute("data-activitystartindex", startIndex);
elem.setAttribute("data-activitylimit", limit);
if (!startIndex) {
var activityContainer = dom.parentWithClass(elem, "activityContainer");
activityContainer && (result.Items.length ? activityContainer.classList.remove("hide") : activityContainer.classList.add("hide"))
if (activityContainer) {
if (result.Items.length) {
activityContainer.classList.remove("hide");
} else {
activityContainer.classList.add("hide");
}
}
}
instance.items = result.Items, renderList(elem, apiClient, result, startIndex, limit)
})
instance.items = result.Items;
renderList(elem, apiClient, result, startIndex, limit);
});
}
function onActivityLogUpdate(e, apiClient, data) {
var options = this.options;
options && options.serverId === apiClient.serverId() && reloadData(this, options.element, apiClient)
if (options && options.serverId === apiClient.serverId()) {
reloadData(this, options.element, apiClient);
}
}
function onListClick(e) {
var btnEntryInfo = dom.parentWithClass(e.target, "btnEntryInfo");
if (btnEntryInfo) {
var id = btnEntryInfo.getAttribute("data-id"),
items = this.items;
var id = btnEntryInfo.getAttribute("data-id");
var items = this.items;
if (items) {
var item = items.filter(function(i) {
return i.Id.toString() === id
var item = items.filter(function (i) {
return i.Id.toString() === id;
})[0];
item && showItemOverview(item)
if (item) {
showItemOverview(item);
}
}
}
}
function showItemOverview(item) {
require(["alert"], function(alert) {
require(["alert"], function (alert) {
alert({
text: item.Overview
})
})
});
});
}
function ActivityLog(options) {
this.options = options;
var element = options.element;
element.classList.add("activityLogListWidget"), element.addEventListener("click", onListClick.bind(this));
element.classList.add("activityLogListWidget");
element.addEventListener("click", onListClick.bind(this));
var apiClient = connectionManager.getApiClient(options.serverId);
reloadData(this, element, apiClient);
var onUpdate = onActivityLogUpdate.bind(this);
this.updateFn = onUpdate, events.on(serverNotifications, "ActivityLogEntry", onUpdate), apiClient.sendMessage("ActivityLogEntryStart", "0,1500")
this.updateFn = onUpdate;
events.on(serverNotifications, "ActivityLogEntry", onUpdate);
apiClient.sendMessage("ActivityLogEntryStart", "0,1500");
}
return ActivityLog.prototype.destroy = function() {
ActivityLog.prototype.destroy = function () {
var options = this.options;
if (options) {
options.element.classList.remove("activityLogListWidget");
connectionManager.getApiClient(options.serverId).sendMessage("ActivityLogEntryStop", "0,1500")
connectionManager.getApiClient(options.serverId).sendMessage("ActivityLogEntryStop", "0,1500");
}
var onUpdate = this.updateFn;
onUpdate && events.off(serverNotifications, "ActivityLogEntry", onUpdate), this.items = null, this.options = null
}, ActivityLog
if (onUpdate) {
events.off(serverNotifications, "ActivityLogEntry", onUpdate);
}
this.items = null;
this.options = null;
};
return ActivityLog;
});

View File

@ -1,10 +1,16 @@
define(["dialogHelper", "loading", "connectionManager", "globalize", "actionsheet", "emby-input", "paper-icon-button-light", "emby-button", "listViewStyle", "material-icons", "formDialogStyle"], function(dialogHelper, loading, connectionManager, globalize, actionsheet) {
define(["dialogHelper", "loading", "connectionManager", "globalize", "actionsheet", "emby-input", "paper-icon-button-light", "emby-button", "listViewStyle", "material-icons", "formDialogStyle"], function (dialogHelper, loading, connectionManager, globalize, actionsheet) {
"use strict";
return function(options) {
return function (options) {
function parentWithClass(elem, className) {
for (; !elem.classList || !elem.classList.contains(className);)
if (!(elem = elem.parentNode)) return null;
return elem
while (!elem.classList || !elem.classList.contains(className)) {
elem = elem.parentNode;
if (!elem) {
return null;
}
}
return elem;
}
function mapChannel(button, channelId, providerChannelId) {
@ -19,33 +25,35 @@ define(["dialogHelper", "loading", "connectionManager", "globalize", "actionshee
providerChannelId: providerChannelId
},
dataType: "json"
}).then(function(mapping) {
}).then(function (mapping) {
var listItem = parentWithClass(button, "listItem");
button.setAttribute("data-providerid", mapping.ProviderChannelId), listItem.querySelector(".secondary").innerHTML = getMappingSecondaryName(mapping, currentMappingOptions.ProviderName), loading.hide()
})
button.setAttribute("data-providerid", mapping.ProviderChannelId);
listItem.querySelector(".secondary").innerHTML = getMappingSecondaryName(mapping, currentMappingOptions.ProviderName);
loading.hide();
});
}
function onChannelsElementClick(e) {
var btnMap = parentWithClass(e.target, "btnMap");
if (btnMap) {
var channelId = btnMap.getAttribute("data-id");
var providerChannelId = btnMap.getAttribute("data-providerid");
var menuItems = currentMappingOptions.ProviderChannels.map(function(m) {
var menuItems = currentMappingOptions.ProviderChannels.map(function (m) {
return {
name: m.Name,
id: m.Id,
selected: m.Id.toLowerCase() === providerChannelId.toLowerCase()
}
};
}).sort(function (a, b) {
return a.name.localeCompare(b.name);
});
actionsheet.show({
positionTo: btnMap,
items: menuItems
}).then(function(newChannelId) {
mapChannel(btnMap, channelId, newChannelId)
})
}).then(function (newChannelId) {
mapChannel(btnMap, channelId, newChannelId);
});
}
}
@ -53,47 +61,87 @@ define(["dialogHelper", "loading", "connectionManager", "globalize", "actionshee
var apiClient = connectionManager.getApiClient(serverId);
return apiClient.getJSON(apiClient.getUrl("LiveTv/ChannelMappingOptions", {
providerId: providerId
}))
}));
}
function getMappingSecondaryName(mapping, providerName) {
return (mapping.ProviderChannelName || "") + " - " + providerName
return (mapping.ProviderChannelName || "") + " - " + providerName;
}
function getTunerChannelHtml(channel, providerName) {
var html = "";
return html += '<div class="listItem">', html += '<i class="md-icon listItemIcon">dvr</i>', html += '<div class="listItemBody two-line">', html += '<h3 class="listItemBodyText">', html += channel.Name, html += "</h3>", html += '<div class="secondary listItemBodyText">', channel.ProviderChannelName && (html += getMappingSecondaryName(channel, providerName)), html += "</div>", html += "</div>", html += '<button class="btnMap autoSize" is="paper-icon-button-light" type="button" data-id="' + channel.Id + '" data-providerid="' + channel.ProviderChannelId + '"><i class="md-icon">mode_edit</i></button>', html += "</div>"
html += '<div class="listItem">';
html += '<i class="md-icon listItemIcon">dvr</i>';
html += '<div class="listItemBody two-line">';
html += '<h3 class="listItemBodyText">';
html += channel.Name;
html += "</h3>";
html += '<div class="secondary listItemBodyText">';
if (channel.ProviderChannelName) {
html += getMappingSecondaryName(channel, providerName);
}
html += "</div>";
html += "</div>";
html += '<button class="btnMap autoSize" is="paper-icon-button-light" type="button" data-id="' + channel.Id + '" data-providerid="' + channel.ProviderChannelId + '"><i class="md-icon">mode_edit</i></button>';
return html += "</div>";
}
function getEditorHtml() {
var html = "";
return html += '<div class="formDialogContent">', html += '<div class="dialogContentInner dialog-content-centered">', html += '<form style="margin:auto;">', html += "<h1>" + globalize.translate("HeaderChannels") + "</h1>", html += '<div class="channels paperList">', html += "</div>", html += "</form>", html += "</div>", html += "</div>"
html += '<div class="formDialogContent">';
html += '<div class="dialogContentInner dialog-content-centered">';
html += '<form style="margin:auto;">';
html += "<h1>" + globalize.translate("HeaderChannels") + "</h1>";
html += '<div class="channels paperList">';
html += "</div>";
html += "</form>";
html += "</div>";
return html += "</div>";
}
function initEditor(dlg, options) {
getChannelMappingOptions(options.serverId, options.providerId).then(function(result) {
getChannelMappingOptions(options.serverId, options.providerId).then(function (result) {
currentMappingOptions = result;
var channelsElement = dlg.querySelector(".channels");
channelsElement.innerHTML = result.TunerChannels.map(function(channel) {
return getTunerChannelHtml(channel, result.ProviderName)
}).join(""), channelsElement.addEventListener("click", onChannelsElementClick)
})
channelsElement.innerHTML = result.TunerChannels.map(function (channel) {
return getTunerChannelHtml(channel, result.ProviderName);
}).join("");
channelsElement.addEventListener("click", onChannelsElementClick);
});
}
var currentMappingOptions, self = this;
self.show = function() {
var currentMappingOptions;
var self = this;
self.show = function () {
var dialogOptions = {
removeOnClose: !0
removeOnClose: true
};
dialogOptions.size = "small";
var dlg = dialogHelper.createDialog(dialogOptions);
dlg.classList.add("formDialog"), dlg.classList.add("ui-body-a"), dlg.classList.add("background-theme-a");
var html = "",
title = globalize.translate("MapChannels");
return html += '<div class="formDialogHeader">', html += '<button is="paper-icon-button-light" class="btnCancel autoSize" tabindex="-1"><i class="md-icon">&#xE5C4;</i></button>', html += '<h3 class="formDialogHeaderTitle">', html += title, html += "</h3>", html += "</div>", html += getEditorHtml(), dlg.innerHTML = html, initEditor(dlg, options), dlg.querySelector(".btnCancel").addEventListener("click", function() {
dialogHelper.close(dlg)
}), new Promise(function(resolve, reject) {
dlg.addEventListener("close", resolve), dialogHelper.open(dlg)
})
}
}
dlg.classList.add("formDialog");
dlg.classList.add("ui-body-a");
dlg.classList.add("background-theme-a");
var html = "";
var title = globalize.translate("MapChannels");
html += '<div class="formDialogHeader">';
html += '<button is="paper-icon-button-light" class="btnCancel autoSize" tabindex="-1"><i class="md-icon">&#xE5C4;</i></button>';
html += '<h3 class="formDialogHeaderTitle">';
html += title;
html += "</h3>";
html += "</div>";
html += getEditorHtml();
dlg.innerHTML = html;
initEditor(dlg, options);
dlg.querySelector(".btnCancel").addEventListener("click", function () {
dialogHelper.close(dlg);
});
return new Promise(function (resolve, reject) {
dlg.addEventListener("close", resolve);
dialogHelper.open(dlg);
});
};
};
});

View File

@ -1,20 +1,20 @@
define(["loading", "libraryBrowser", "cardBuilder", "dom", "apphost", "imageLoader", "globalize", "layoutManager", "scrollStyles", "emby-itemscontainer"], function(loading, libraryBrowser, cardBuilder, dom, appHost, imageLoader, globalize, layoutManager) {
define(["loading", "libraryBrowser", "cardBuilder", "dom", "apphost", "imageLoader", "globalize", "layoutManager", "scrollStyles", "emby-itemscontainer"], function (loading, libraryBrowser, cardBuilder, dom, appHost, imageLoader, globalize, layoutManager) {
"use strict";
function enableScrollX() {
return !layoutManager.desktop
return !layoutManager.desktop;
}
function getThumbShape() {
return enableScrollX() ? "overflowBackdrop" : "backdrop"
return enableScrollX() ? "overflowBackdrop" : "backdrop";
}
function getPosterShape() {
return enableScrollX() ? "overflowPortrait" : "portrait"
return enableScrollX() ? "overflowPortrait" : "portrait";
}
function getSquareShape() {
return enableScrollX() ? "overflowSquare" : "square"
return enableScrollX() ? "overflowSquare" : "square";
}
function getSections() {
@ -23,147 +23,208 @@ define(["loading", "libraryBrowser", "cardBuilder", "dom", "apphost", "imageLoad
types: "Movie",
id: "favoriteMovies",
shape: getPosterShape(),
showTitle: !1,
overlayPlayButton: !0
showTitle: false,
overlayPlayButton: true
}, {
name: "HeaderFavoriteShows",
types: "Series",
id: "favoriteShows",
shape: getPosterShape(),
showTitle: !1,
overlayPlayButton: !0
showTitle: false,
overlayPlayButton: true
}, {
name: "HeaderFavoriteEpisodes",
types: "Episode",
id: "favoriteEpisode",
shape: getThumbShape(),
preferThumb: !1,
showTitle: !0,
showParentTitle: !0,
overlayPlayButton: !0,
overlayText: !1,
centerText: !0
preferThumb: false,
showTitle: true,
showParentTitle: true,
overlayPlayButton: true,
overlayText: false,
centerText: true
}, {
name: "HeaderFavoriteVideos",
types: "Video,MusicVideo",
id: "favoriteVideos",
shape: getThumbShape(),
preferThumb: !0,
showTitle: !0,
overlayPlayButton: !0,
overlayText: !1,
centerText: !0
preferThumb: true,
showTitle: true,
overlayPlayButton: true,
overlayText: false,
centerText: true
}, {
name: "HeaderFavoriteArtists",
types: "MusicArtist",
id: "favoriteArtists",
shape: getSquareShape(),
preferThumb: !1,
showTitle: !0,
overlayText: !1,
showParentTitle: !1,
centerText: !0,
overlayPlayButton: !0,
coverImage: !0
preferThumb: false,
showTitle: true,
overlayText: false,
showParentTitle: false,
centerText: true,
overlayPlayButton: true,
coverImage: true
}, {
name: "HeaderFavoriteAlbums",
types: "MusicAlbum",
id: "favoriteAlbums",
shape: getSquareShape(),
preferThumb: !1,
showTitle: !0,
overlayText: !1,
showParentTitle: !0,
centerText: !0,
overlayPlayButton: !0,
coverImage: !0
preferThumb: false,
showTitle: true,
overlayText: false,
showParentTitle: true,
centerText: true,
overlayPlayButton: true,
coverImage: true
}, {
name: "HeaderFavoriteSongs",
types: "Audio",
id: "favoriteSongs",
shape: getSquareShape(),
preferThumb: !1,
showTitle: !0,
overlayText: !1,
showParentTitle: !0,
centerText: !0,
overlayMoreButton: !0,
preferThumb: false,
showTitle: true,
overlayText: false,
showParentTitle: true,
centerText: true,
overlayMoreButton: true,
action: "instantmix",
coverImage: !0
}]
coverImage: true
}];
}
function loadSection(elem, userId, topParentId, section, isSingleSection) {
var screenWidth = dom.getWindowSize().innerWidth,
options = {
SortBy: "SortName",
SortOrder: "Ascending",
Filters: "IsFavorite",
Recursive: !0,
Fields: "PrimaryImageAspectRatio,BasicSyncInfo",
CollapseBoxSetItems: !1,
ExcludeLocationTypes: "Virtual",
EnableTotalRecordCount: !1
};
topParentId && (options.ParentId = topParentId), isSingleSection || (options.Limit = screenWidth >= 1920 ? 10 : screenWidth >= 1440 ? 8 : 6, enableScrollX() && (options.Limit = 20));
var screenWidth = dom.getWindowSize().innerWidth;
var options = {
SortBy: "SortName",
SortOrder: "Ascending",
Filters: "IsFavorite",
Recursive: true,
Fields: "PrimaryImageAspectRatio,BasicSyncInfo",
CollapseBoxSetItems: false,
ExcludeLocationTypes: "Virtual",
EnableTotalRecordCount: false
};
if (topParentId) {
options.ParentId = topParentId;
}
if (!isSingleSection) {
options.Limit = screenWidth >= 1920 ? 10 : screenWidth >= 1440 ? 8 : 6;
if (enableScrollX()) {
options.Limit = 20;
}
}
var promise;
return "MusicArtist" === section.types ? promise = ApiClient.getArtists(userId, options) : (options.IncludeItemTypes = section.types, promise = ApiClient.getItems(userId, options)), promise.then(function(result) {
if ("MusicArtist" === section.types) {
promise = ApiClient.getArtists(userId, options);
} else {
options.IncludeItemTypes = section.types;
promise = ApiClient.getItems(userId, options);
}
return promise.then(function (result) {
var html = "";
if (result.Items.length) {
if (html += '<div class="sectionTitleContainer sectionTitleContainer-cards padded-left">', !layoutManager.tv && options.Limit && result.Items.length >= options.Limit) {
html += '<a is="emby-linkbutton" href="' + ("list.html?serverId=" + ApiClient.serverId() + "&type=" + section.types + "&IsFavorite=true") + '" class="more button-flat button-flat-mini sectionTitleTextButton">', html += '<h2 class="sectionTitle sectionTitle-cards">', html += globalize.translate(section.name), html += "</h2>", html += '<i class="md-icon">&#xE5CC;</i>', html += "</a>"
} else html += '<h2 class="sectionTitle sectionTitle-cards">' + globalize.translate(section.name) + "</h2>";
if (html += "</div>", enableScrollX()) {
html += '<a is="emby-linkbutton" href="' + ("list.html?serverId=" + ApiClient.serverId() + "&type=" + section.types + "&IsFavorite=true") + '" class="more button-flat button-flat-mini sectionTitleTextButton">';
html += '<h2 class="sectionTitle sectionTitle-cards">';
html += globalize.translate(section.name);
html += "</h2>";
html += '<i class="md-icon">&#xE5CC;</i>';
html += "</a>";
} else {
html += '<h2 class="sectionTitle sectionTitle-cards">' + globalize.translate(section.name) + "</h2>";
}
html += "</div>";
if (enableScrollX()) {
var scrollXClass = "scrollX hiddenScrollX";
layoutManager.tv && (scrollXClass += " smoothScrollX"), html += '<div is="emby-itemscontainer" class="itemsContainer ' + scrollXClass + ' padded-left padded-right">'
} else html += '<div is="emby-itemscontainer" class="itemsContainer vertical-wrap padded-left padded-right">';
var supportsImageAnalysis = appHost.supports("imageanalysis"),
cardLayout = (appHost.preferVisualCards || supportsImageAnalysis) && section.autoCardLayout && section.showTitle;
cardLayout = !1, html += cardBuilder.getCardsHtml(result.Items, {
if (layoutManager.tv) {
scrollXClass += " smoothScrollX";
}
html += '<div is="emby-itemscontainer" class="itemsContainer ' + scrollXClass + ' padded-left padded-right">';
} else {
html += '<div is="emby-itemscontainer" class="itemsContainer vertical-wrap padded-left padded-right">';
}
var supportsImageAnalysis = appHost.supports("imageanalysis");
var cardLayout = (appHost.preferVisualCards || supportsImageAnalysis) && section.autoCardLayout && section.showTitle;
cardLayout = false;
html += cardBuilder.getCardsHtml(result.Items, {
preferThumb: section.preferThumb,
shape: section.shape,
centerText: section.centerText && !cardLayout,
overlayText: !1 !== section.overlayText,
overlayText: false !== section.overlayText,
showTitle: section.showTitle,
showParentTitle: section.showParentTitle,
scalable: !0,
scalable: true,
coverImage: section.coverImage,
overlayPlayButton: section.overlayPlayButton,
overlayMoreButton: section.overlayMoreButton && !cardLayout,
action: section.action,
allowBottomPadding: !enableScrollX(),
cardLayout: cardLayout
}), html += "</div>"
});
html += "</div>";
}
elem.innerHTML = html, imageLoader.lazyChildren(elem)
})
elem.innerHTML = html;
imageLoader.lazyChildren(elem);
});
}
function loadSections(page, userId, topParentId, types) {
loading.show();
var sections = getSections(),
sectionid = getParameterByName("sectionid");
sectionid && (sections = sections.filter(function(s) {
return s.id === sectionid
})), types && (sections = sections.filter(function(s) {
return -1 !== types.indexOf(s.id)
}));
var i, length, elem = page.querySelector(".favoriteSections");
var sections = getSections();
var sectionid = getParameterByName("sectionid");
if (sectionid) {
sections = sections.filter(function (s) {
return s.id === sectionid;
});
}
if (types) {
sections = sections.filter(function (s) {
return -1 !== types.indexOf(s.id);
});
}
var i;
var length;
var elem = page.querySelector(".favoriteSections");
if (!elem.innerHTML) {
var html = "";
for (i = 0, length = sections.length; i < length; i++) html += '<div class="verticalSection section' + sections[i].id + '"></div>';
elem.innerHTML = html
for (i = 0, length = sections.length; i < length; i++) {
html += '<div class="verticalSection section' + sections[i].id + '"></div>';
}
elem.innerHTML = html;
}
var promises = [];
for (i = 0, length = sections.length; i < length; i++) {
var section = sections[i];
elem = page.querySelector(".section" + section.id), promises.push(loadSection(elem, userId, topParentId, section, 1 === sections.length))
elem = page.querySelector(".section" + section.id);
promises.push(loadSection(elem, userId, topParentId, section, 1 === sections.length));
}
Promise.all(promises).then(function() {
loading.hide()
})
Promise.all(promises).then(function () {
loading.hide();
});
}
return {
render: loadSections
}
};
});

View File

@ -1,32 +1,45 @@
define(["dom", "appRouter", "connectionManager"], function(dom, appRouter, connectionManager) {
define(["dom", "appRouter", "connectionManager"], function (dom, appRouter, connectionManager) {
"use strict";
function onGroupedCardClick(e, card) {
var itemId = card.getAttribute("data-id"),
serverId = card.getAttribute("data-serverid"),
apiClient = connectionManager.getApiClient(serverId),
userId = apiClient.getCurrentUserId(),
playedIndicator = card.querySelector(".playedIndicator"),
playedIndicatorHtml = playedIndicator ? playedIndicator.innerHTML : null,
options = {
Limit: parseInt(playedIndicatorHtml || "10"),
Fields: "PrimaryImageAspectRatio,DateCreated",
ParentId: itemId,
GroupItems: !1
},
actionableParent = dom.parentWithTag(e.target, ["A", "BUTTON", "INPUT"]);
if (!actionableParent || actionableParent.classList.contains("cardContent")) return apiClient.getJSON(apiClient.getUrl("Users/" + userId + "/Items/Latest", options)).then(function(items) {
if (1 === items.length) return void appRouter.showItem(items[0]);
var url = "itemdetails.html?id=" + itemId + "&serverId=" + serverId;
Dashboard.navigate(url)
}), e.stopPropagation(), e.preventDefault(), !1
var itemId = card.getAttribute("data-id");
var serverId = card.getAttribute("data-serverid");
var apiClient = connectionManager.getApiClient(serverId);
var userId = apiClient.getCurrentUserId();
var playedIndicator = card.querySelector(".playedIndicator");
var playedIndicatorHtml = playedIndicator ? playedIndicator.innerHTML : null;
var options = {
Limit: parseInt(playedIndicatorHtml || "10"),
Fields: "PrimaryImageAspectRatio,DateCreated",
ParentId: itemId,
GroupItems: false
};
var actionableParent = dom.parentWithTag(e.target, ["A", "BUTTON", "INPUT"]);
if (!actionableParent || actionableParent.classList.contains("cardContent")) {
apiClient.getJSON(apiClient.getUrl("Users/" + userId + "/Items/Latest", options)).then(function (items) {
if (1 === items.length) {
return void appRouter.showItem(items[0]);
}
var url = "itemdetails.html?id=" + itemId + "&serverId=" + serverId;
Dashboard.navigate(url);
});
e.stopPropagation();
e.preventDefault();
return false;
}
}
function onItemsContainerClick(e) {
var groupedCard = dom.parentWithClass(e.target, "groupedCard");
groupedCard && onGroupedCardClick(e, groupedCard)
if (groupedCard) {
onGroupedCardClick(e, groupedCard);
}
}
return {
onItemsContainerClick: onItemsContainerClick
}
});
};
});

View File

@ -1,28 +1,45 @@
define(["datetime"], function(datetime) {
define(["datetime"], function (datetime) {
"use strict";
function humaneDate(date_str) {
var format, time_formats = [
[90, "a minute"],
[3600, "minutes", 60],
[5400, "an hour"],
[86400, "hours", 3600],
[129600, "a day"],
[604800, "days", 86400],
[907200, "a week"],
[2628e3, "weeks", 604800],
[3942e3, "a month"],
[31536e3, "months", 2628e3],
[47304e3, "a year"],
[31536e5, "years", 31536e3]
],
dt = new Date,
date = datetime.parseISO8601Date(date_str, !0),
seconds = (dt - date) / 1e3,
i = 0;
for (seconds < 0 && (seconds = Math.abs(seconds)); format = time_formats[i++];)
if (seconds < format[0]) return 2 == format.length ? format[1] + " ago" : Math.round(seconds / format[2]) + " " + format[1] + " ago";
return seconds > 47304e5 ? Math.round(seconds / 47304e5) + " centuries ago" : date_str
var format;
var time_formats = [
[90, "a minute"],
[3600, "minutes", 60],
[5400, "an hour"],
[86400, "hours", 3600],
[129600, "a day"],
[604800, "days", 86400],
[907200, "a week"],
[2628e3, "weeks", 604800],
[3942e3, "a month"],
[31536e3, "months", 2628e3],
[47304e3, "a year"],
[31536e5, "years", 31536e3]
];
var dt = new Date();
var date = datetime.parseISO8601Date(date_str, true);
var seconds = (dt - date) / 1000.0;
var i = 0;
if (seconds < 0) {
seconds = Math.abs(seconds);
}
for (; format = time_formats[i++];) {
if (seconds < format[0]) {
if (2 == format.length) {
return format[1] + " ago";
}
return Math.round(seconds / format[2]) + " " + format[1] + " ago";
}
}
if (seconds > 47304e5) {
return Math.round(seconds / 47304e5) + " centuries ago";
}
return date_str;
}
function humaneElapsed(firstDateStr, secondDateStr) {
@ -30,12 +47,10 @@ define(["datetime"], function(datetime) {
var dateOne = new Date(firstDateStr);
var dateTwo = new Date(secondDateStr);
var delta = (dateTwo.getTime() - dateOne.getTime()) / 1e3;
var days = Math.floor(delta % 31536e3 / 86400);
var hours = Math.floor(delta % 31536e3 % 86400 / 3600);
var minutes = Math.floor(delta % 31536e3 % 86400 % 3600 / 60);
var seconds = Math.round(delta % 31536e3 % 86400 % 3600 % 60);
var elapsed = "";
elapsed += 1 == days ? days + " day " : "";
elapsed += days > 1 ? days + " days " : "";
@ -46,15 +61,13 @@ define(["datetime"], function(datetime) {
elapsed += elapsed.length > 0 ? "and " : "";
elapsed += 1 == seconds ? seconds + " second" : "";
elapsed += 0 == seconds || seconds > 1 ? seconds + " seconds" : "";
return elapsed;
}
window.humaneDate = humaneDate;
window.humaneElapsed = humaneElapsed;
return {
humaneDate: humaneDate,
humaneElapsed: humaneElapsed
}
});
};
});

View File

@ -1,4 +1,4 @@
define(["globalize", "dom", "dialogHelper", "emby-checkbox", "emby-select", "emby-input"], function(globalize, dom, dialogHelper) {
define(["globalize", "dom", "dialogHelper", "emby-checkbox", "emby-select", "emby-input"], function (globalize, dom, dialogHelper) {
"use strict";
function getDefaultImageConfig(itemType, type) {
@ -6,72 +6,107 @@ define(["globalize", "dom", "dialogHelper", "emby-checkbox", "emby-select", "emb
Type: type,
MinWidth: 0,
Limit: "Primary" === type ? 1 : 0
}
};
}
function findImageOptions(imageOptions, type) {
return imageOptions.filter(function(i) {
return i.Type == type
})[0]
return imageOptions.filter(function (i) {
return i.Type == type;
})[0];
}
function getImageConfig(options, availableOptions, imageType, itemType) {
return findImageOptions(options.ImageOptions || [], imageType) || findImageOptions(availableOptions.DefaultImageOptions || [], imageType) || getDefaultImageConfig(itemType, imageType)
return findImageOptions(options.ImageOptions || [], imageType) || findImageOptions(availableOptions.DefaultImageOptions || [], imageType) || getDefaultImageConfig(itemType, imageType);
}
function setVisibilityOfBackdrops(elem, visible) {
visible ? (elem.classList.remove("hide"), elem.querySelector("input").setAttribute("required", "required")) : (elem.classList.add("hide"), elem.querySelector("input").setAttribute("required", ""), elem.querySelector("input").removeAttribute("required"))
if (visible) {
elem.classList.remove("hide");
elem.querySelector("input").setAttribute("required", "required");
} else {
elem.classList.add("hide");
elem.querySelector("input").setAttribute("required", "");
elem.querySelector("input").removeAttribute("required");
}
}
function loadValues(context, itemType, options, availableOptions) {
var supportedImageTypes = availableOptions.SupportedImageTypes || [];
setVisibilityOfBackdrops(context.querySelector(".backdropFields"), -1 != supportedImageTypes.indexOf("Backdrop")), setVisibilityOfBackdrops(context.querySelector(".screenshotFields"), -1 != supportedImageTypes.indexOf("Screenshot")), Array.prototype.forEach.call(context.querySelectorAll(".imageType"), function(i) {
var imageType = i.getAttribute("data-imagetype"),
container = dom.parentWithTag(i, "LABEL"); - 1 == supportedImageTypes.indexOf(imageType) ? container.classList.add("hide") : container.classList.remove("hide"), getImageConfig(options, availableOptions, imageType, itemType).Limit ? i.checked = !0 : i.checked = !1
setVisibilityOfBackdrops(context.querySelector(".backdropFields"), -1 != supportedImageTypes.indexOf("Backdrop"));
setVisibilityOfBackdrops(context.querySelector(".screenshotFields"), -1 != supportedImageTypes.indexOf("Screenshot"));
Array.prototype.forEach.call(context.querySelectorAll(".imageType"), function (i) {
var imageType = i.getAttribute("data-imagetype");
var container = dom.parentWithTag(i, "LABEL");
if (-1 == supportedImageTypes.indexOf(imageType)) {
container.classList.add("hide");
} else {
container.classList.remove("hide");
}
if (getImageConfig(options, availableOptions, imageType, itemType).Limit) {
i.checked = true;
} else {
i.checked = false;
}
});
var backdropConfig = getImageConfig(options, availableOptions, "Backdrop", itemType);
context.querySelector("#txtMaxBackdrops").value = backdropConfig.Limit, context.querySelector("#txtMinBackdropDownloadWidth").value = backdropConfig.MinWidth;
context.querySelector("#txtMaxBackdrops").value = backdropConfig.Limit;
context.querySelector("#txtMinBackdropDownloadWidth").value = backdropConfig.MinWidth;
var screenshotConfig = getImageConfig(options, availableOptions, "Screenshot", itemType);
context.querySelector("#txtMaxScreenshots").value = screenshotConfig.Limit, context.querySelector("#txtMinScreenshotDownloadWidth").value = screenshotConfig.MinWidth
context.querySelector("#txtMaxScreenshots").value = screenshotConfig.Limit;
context.querySelector("#txtMinScreenshotDownloadWidth").value = screenshotConfig.MinWidth;
}
function saveValues(context, options) {
options.ImageOptions = Array.prototype.map.call(context.querySelectorAll(".imageType:not(.hide)"), function(c) {
options.ImageOptions = Array.prototype.map.call(context.querySelectorAll(".imageType:not(.hide)"), function (c) {
return {
Type: c.getAttribute("data-imagetype"),
Limit: c.checked ? 1 : 0,
MinWidth: 0
}
}), options.ImageOptions.push({
};
});
options.ImageOptions.push({
Type: "Backdrop",
Limit: context.querySelector("#txtMaxBackdrops").value,
MinWidth: context.querySelector("#txtMinBackdropDownloadWidth").value
}), options.ImageOptions.push({
});
options.ImageOptions.push({
Type: "Screenshot",
Limit: context.querySelector("#txtMaxScreenshots").value,
MinWidth: context.querySelector("#txtMinScreenshotDownloadWidth").value
})
});
}
function editor() {
this.show = function(itemType, options, availableOptions) {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest;
xhr.open("GET", "components/imageoptionseditor/imageoptionseditor.template.html", !0), xhr.onload = function(e) {
var template = this.response,
dlg = dialogHelper.createDialog({
size: "medium-tall",
removeOnClose: !0,
scrollY: !1
});
dlg.classList.add("formDialog"), dlg.innerHTML = globalize.translateDocument(template), dlg.addEventListener("close", function() {
saveValues(dlg, options)
}), loadValues(dlg, itemType, options, availableOptions), dialogHelper.open(dlg).then(resolve, resolve), dlg.querySelector(".btnCancel").addEventListener("click", function() {
dialogHelper.close(dlg)
})
}, xhr.send()
})
}
this.show = function (itemType, options, availableOptions) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open("GET", "components/imageoptionseditor/imageoptionseditor.template.html", true);
xhr.onload = function (e) {
var template = this.response;
var dlg = dialogHelper.createDialog({
size: "medium-tall",
removeOnClose: true,
scrollY: false
});
dlg.classList.add("formDialog");
dlg.innerHTML = globalize.translateDocument(template);
dlg.addEventListener("close", function () {
saveValues(dlg, options);
});
loadValues(dlg, itemType, options, availableOptions);
dialogHelper.open(dlg).then(resolve, resolve);
dlg.querySelector(".btnCancel").addEventListener("click", function () {
dialogHelper.close(dlg);
});
};
xhr.send();
});
};
}
return editor
});
return editor;
});

View File

@ -1,5 +1,5 @@
define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize', 'scrollHelper', 'layoutManager', 'focusManager', 'browser', 'emby-input', 'emby-checkbox', 'paper-icon-button-light', 'css!./../formdialog', 'material-icons', 'cardStyle'], function (dialogHelper, loading, connectionManager, require, globalize, scrollHelper, layoutManager, focusManager, browser) {
'use strict';
define(["dialogHelper", "loading", "connectionManager", "require", "globalize", "scrollHelper", "layoutManager", "focusManager", "browser", "emby-input", "emby-checkbox", "paper-icon-button-light", "css!./../formdialog", "material-icons", "cardStyle"], function (dialogHelper, loading, connectionManager, require, globalize, scrollHelper, layoutManager, focusManager, browser) {
"use strict";
var currentItem;
var currentItemType;
@ -20,7 +20,7 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
};
var i, length;
var identifyField = page.querySelectorAll('.identifyField');
var identifyField = page.querySelectorAll(".identifyField");
var value;
for (i = 0, length = identifyField.length; i < length; i++) {
@ -28,17 +28,17 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
if (value) {
if (identifyField[i].type === 'number') {
if (identifyField[i].type === "number") {
value = parseInt(value);
}
lookupInfo[identifyField[i].getAttribute('data-lookup')] = value;
lookupInfo[identifyField[i].getAttribute("data-lookup")] = value;
}
}
var hasId = false;
var txtLookupId = page.querySelectorAll('.txtLookupId');
var txtLookupId = page.querySelectorAll(".txtLookupId");
for (i = 0, length = txtLookupId.length; i < length; i++) {
value = txtLookupId[i].value;
@ -46,12 +46,12 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
if (value) {
hasId = true;
}
lookupInfo.ProviderIds[txtLookupId[i].getAttribute('data-providerkey')] = value;
lookupInfo.ProviderIds[txtLookupId[i].getAttribute("data-providerkey")] = value;
}
if (!hasId && !lookupInfo.Name) {
require(['toast'], function (toast) {
toast(globalize.translate('PleaseEnterNameOrId'));
require(["toast"], function (toast) {
toast(globalize.translate("PleaseEnterNameOrId"));
});
return;
}
@ -76,7 +76,7 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
url: apiClient.getUrl("Items/RemoteSearch/" + currentItemType),
data: JSON.stringify(lookupInfo),
contentType: "application/json",
dataType: 'json'
dataType: "json"
}).then(function (results) {
@ -87,14 +87,14 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
function showIdentificationSearchResults(page, results) {
var identificationSearchResults = page.querySelector('.identificationSearchResults');
var identificationSearchResults = page.querySelector(".identificationSearchResults");
page.querySelector('.popupIdentifyForm').classList.add('hide');
identificationSearchResults.classList.remove('hide');
page.querySelector('.identifyOptionsForm').classList.add('hide');
page.querySelector('.dialogContentInner').classList.remove('dialog-content-centered');
page.querySelector(".popupIdentifyForm").classList.add("hide");
identificationSearchResults.classList.remove("hide");
page.querySelector(".identifyOptionsForm").classList.add("hide");
page.querySelector(".dialogContentInner").classList.remove("dialog-content-centered");
var html = '';
var html = "";
var i, length;
for (i = 0, length = results.length; i < length; i++) {
@ -102,11 +102,11 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
html += getSearchResultHtml(result, i);
}
var elem = page.querySelector('.identificationSearchResultList');
var elem = page.querySelector(".identificationSearchResultList");
elem.innerHTML = html;
function onSearchImageClick() {
var index = parseInt(this.getAttribute('data-index'));
var index = parseInt(this.getAttribute("data-index"));
var currentResult = results[index];
@ -119,10 +119,10 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
}
}
var searchImages = elem.querySelectorAll('.card');
var searchImages = elem.querySelectorAll(".card");
for (i = 0, length = searchImages.length; i < length; i++) {
searchImages[i].addEventListener('click', onSearchImageClick);
searchImages[i].addEventListener("click", onSearchImageClick);
}
if (layoutManager.tv) {
@ -140,13 +140,13 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
function showIdentifyOptions(page, identifyResult) {
var identifyOptionsForm = page.querySelector('.identifyOptionsForm');
var identifyOptionsForm = page.querySelector(".identifyOptionsForm");
page.querySelector('.popupIdentifyForm').classList.add('hide');
page.querySelector('.identificationSearchResults').classList.add('hide');
identifyOptionsForm.classList.remove('hide');
page.querySelector('#chkIdentifyReplaceImages').checked = true;
page.querySelector('.dialogContentInner').classList.add('dialog-content-centered');
page.querySelector(".popupIdentifyForm").classList.add("hide");
page.querySelector(".identificationSearchResults").classList.add("hide");
identifyOptionsForm.classList.remove("hide");
page.querySelector("#chkIdentifyReplaceImages").checked = true;
page.querySelector(".dialogContentInner").classList.add("dialog-content-centered");
currentSearchResult = identifyResult;
@ -157,47 +157,47 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
lines.push(identifyResult.ProductionYear);
}
var resultHtml = lines.join('<br/>');
var resultHtml = lines.join("<br/>");
if (identifyResult.ImageUrl) {
var displayUrl = getSearchImageDisplayUrl(identifyResult.ImageUrl, identifyResult.SearchProviderName);
resultHtml = '<div style="display:flex;align-items:center;"><img src="' + displayUrl + '" style="max-height:240px;" /><div style="margin-left:1em;">' + resultHtml + '</div>';
resultHtml = '<div style="display:flex;align-items:center;"><img src="' + displayUrl + '" style="max-height:240px;" /><div style="margin-left:1em;">' + resultHtml + "</div>";
}
page.querySelector('.selectedSearchResult').innerHTML = resultHtml;
page.querySelector(".selectedSearchResult").innerHTML = resultHtml;
focusManager.focus(identifyOptionsForm.querySelector('.btnSubmit'));
focusManager.focus(identifyOptionsForm.querySelector(".btnSubmit"));
}
function getSearchResultHtml(result, index) {
var html = '';
var html = "";
var cssClass = "card scalableCard";
var cardBoxCssClass = 'cardBox';
var cardBoxCssClass = "cardBox";
var padderClass;
if (currentItemType === "Episode") {
cssClass += " backdropCard backdropCard-scalable";
padderClass = 'cardPadder-backdrop';
padderClass = "cardPadder-backdrop";
}
else if (currentItemType === "MusicAlbum" || currentItemType === "MusicArtist") {
cssClass += " squareCard squareCard-scalable";
padderClass = 'cardPadder-square';
padderClass = "cardPadder-square";
}
else {
cssClass += " portraitCard portraitCard-scalable";
padderClass = 'cardPadder-portrait';
padderClass = "cardPadder-portrait";
}
if (layoutManager.tv && !browser.slow) {
cardBoxCssClass += ' cardBox-focustransform';
cardBoxCssClass += " cardBox-focustransform";
}
cardBoxCssClass += ' cardBox-bottompadded';
cardBoxCssClass += " cardBox-bottompadded";
if (layoutManager.tv) {
cardBoxCssClass += ' card-focuscontent cardBox-withfocuscontent';
cardBoxCssClass += " card-focuscontent cardBox-withfocuscontent";
}
html += '<button type="button" class="' + cssClass + '" data-index="' + index + '">';
@ -215,8 +215,8 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
html += '<div class="cardImageContainer coveredImage defaultCardBackground defaultCardBackground1"><div class="cardText cardCenteredText">' + result.Name + '</div></div>';
}
html += '</div>';
html += '</div>';
html += "</div>";
html += "</div>";
var numLines = 2;
if (currentItemType === "MusicAlbum") {
@ -239,12 +239,12 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
} else {
html += '<div class="cardText cardText-secondary cardTextCentered">';
}
html += lines[i] || '&nbsp;';
html += '</div>';
html += lines[i] || "&nbsp;";
html += "</div>";
}
html += '</div>';
html += '</button>';
html += "</div>";
html += "</button>";
return html;
}
@ -259,7 +259,7 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
loading.show();
var options = {
ReplaceAllImages: page.querySelector('#chkIdentifyReplaceImages').checked
ReplaceAllImages: page.querySelector("#chkIdentifyReplaceImages").checked
};
var apiClient = getApiClient();
@ -291,7 +291,7 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
apiClient.getJSON(apiClient.getUrl("Items/" + item.Id + "/ExternalIdInfos")).then(function (idList) {
var html = '';
var html = "";
var providerIds = item.ProviderIds || {};
@ -303,30 +303,30 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
html += '<div class="inputContainer">';
var idLabel = globalize.translate('LabelDynamicExternalId').replace('{0}', idInfo.Name);
var idLabel = globalize.translate("LabelDynamicExternalId").replace("{0}", idInfo.Name);
var value = providerIds[idInfo.Key] || '';
var value = providerIds[idInfo.Key] || "";
html += '<input is="emby-input" class="txtLookupId" data-providerkey="' + idInfo.Key + '" id="' + id + '" label="' + idLabel + '"/>';
html += '</div>';
html += "</div>";
}
page.querySelector('#txtLookupName').value = '';
page.querySelector("#txtLookupName").value = "";
if (item.Type === "Person" || item.Type === "BoxSet") {
page.querySelector('.fldLookupYear').classList.add('hide');
page.querySelector('#txtLookupYear').value = '';
page.querySelector(".fldLookupYear").classList.add("hide");
page.querySelector("#txtLookupYear").value = "";
} else {
page.querySelector('.fldLookupYear').classList.remove('hide');
page.querySelector('#txtLookupYear').value = '';
page.querySelector(".fldLookupYear").classList.remove("hide");
page.querySelector("#txtLookupYear").value = "";
}
page.querySelector('.identifyProviderIds').innerHTML = html;
page.querySelector(".identifyProviderIds").innerHTML = html;
page.querySelector('.formDialogHeaderTitle').innerHTML = globalize.translate('Identify');
page.querySelector(".formDialogHeaderTitle").innerHTML = globalize.translate("Identify");
});
}
@ -334,7 +334,7 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
loading.show();
require(['text!./itemidentifier.template.html'], function (template) {
require(["text!./itemidentifier.template.html"], function (template) {
var apiClient = getApiClient();
@ -344,30 +344,30 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
currentItemType = currentItem.Type;
var dialogOptions = {
size: 'fullscreen-border',
size: "fullscreen-border",
removeOnClose: true,
scrollY: false
};
if (layoutManager.tv) {
dialogOptions.size = 'fullscreen';
dialogOptions.size = "fullscreen";
}
var dlg = dialogHelper.createDialog(dialogOptions);
dlg.classList.add('formDialog');
dlg.classList.add('recordingDialog');
dlg.classList.add("formDialog");
dlg.classList.add("recordingDialog");
var html = '';
html += globalize.translateDocument(template, 'core');
var html = "";
html += globalize.translateDocument(template, "core");
dlg.innerHTML = html;
// Has to be assigned a z-index after the call to .open()
dlg.addEventListener('close', onDialogClosed);
dlg.addEventListener("close", onDialogClosed);
if (layoutManager.tv) {
scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false);
scrollHelper.centerFocus.on(dlg.querySelector(".formDialogContent"), false);
}
if (item.Path) {
@ -380,26 +380,26 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
dialogHelper.open(dlg);
dlg.querySelector('.popupIdentifyForm').addEventListener('submit', function (e) {
dlg.querySelector(".popupIdentifyForm").addEventListener("submit", function (e) {
e.preventDefault();
searchForIdentificationResults(dlg);
return false;
});
dlg.querySelector('.identifyOptionsForm').addEventListener('submit', function (e) {
dlg.querySelector(".identifyOptionsForm").addEventListener("submit", function (e) {
e.preventDefault();
submitIdentficationResult(dlg);
return false;
});
dlg.querySelector('.btnCancel').addEventListener('click', function (e) {
dlg.querySelector(".btnCancel").addEventListener("click", function (e) {
dialogHelper.close(dlg);
});
dlg.classList.add('identifyDialog');
dlg.classList.add("identifyDialog");
showIdentificationForm(dlg, item);
loading.hide();
@ -422,49 +422,49 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
currentItem = null;
currentItemType = itemType;
require(['text!./itemidentifier.template.html'], function (template) {
require(["text!./itemidentifier.template.html"], function (template) {
var dialogOptions = {
size: 'fullscreen-border',
size: "fullscreen-border",
removeOnClose: true,
scrollY: false
};
if (layoutManager.tv) {
dialogOptions.size = 'fullscreen';
dialogOptions.size = "fullscreen";
}
var dlg = dialogHelper.createDialog(dialogOptions);
dlg.classList.add('formDialog');
dlg.classList.add('recordingDialog');
dlg.classList.add("formDialog");
dlg.classList.add("recordingDialog");
var html = '';
html += globalize.translateDocument(template, 'core');
var html = "";
html += globalize.translateDocument(template, "core");
dlg.innerHTML = html;
if (layoutManager.tv) {
scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false);
scrollHelper.centerFocus.on(dlg.querySelector(".formDialogContent"), false);
}
dialogHelper.open(dlg);
dlg.querySelector('.btnCancel').addEventListener('click', function (e) {
dlg.querySelector(".btnCancel").addEventListener("click", function (e) {
dialogHelper.close(dlg);
});
dlg.querySelector('.popupIdentifyForm').addEventListener('submit', function (e) {
dlg.querySelector(".popupIdentifyForm").addEventListener("submit", function (e) {
e.preventDefault();
searchForIdentificationResults(dlg);
return false;
});
dlg.addEventListener('close', function () {
dlg.addEventListener("close", function () {
loading.hide();
var foundItem = hasChanges ? currentSearchResult : null;
@ -472,7 +472,7 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
resolveFunc(foundItem);
});
dlg.classList.add('identifyDialog');
dlg.classList.add("identifyDialog");
showIdentificationFormFindNew(dlg, itemName, itemYear, itemType);
});
@ -480,20 +480,20 @@ define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize',
function showIdentificationFormFindNew(dlg, itemName, itemYear, itemType) {
dlg.querySelector('#txtLookupName').value = itemName;
dlg.querySelector("#txtLookupName").value = itemName;
if (itemType === "Person" || itemType === "BoxSet") {
dlg.querySelector('.fldLookupYear').classList.add('hide');
dlg.querySelector('#txtLookupYear').value = '';
dlg.querySelector(".fldLookupYear").classList.add("hide");
dlg.querySelector("#txtLookupYear").value = "";
} else {
dlg.querySelector('.fldLookupYear').classList.remove('hide');
dlg.querySelector('#txtLookupYear').value = itemYear;
dlg.querySelector(".fldLookupYear").classList.remove("hide");
dlg.querySelector("#txtLookupYear").value = itemYear;
}
dlg.querySelector('.formDialogHeaderTitle').innerHTML = globalize.translate('Search');
dlg.querySelector(".formDialogHeaderTitle").innerHTML = globalize.translate("Search");
}
return {

View File

@ -1,78 +1,171 @@
define(["dialogHelper", "dom", "layoutManager", "connectionManager", "globalize", "loading", "material-icons", "formDialogStyle", "emby-button", "emby-itemscontainer", "cardStyle"], function(dialogHelper, dom, layoutManager, connectionManager, globalize, loading) {
define(["dialogHelper", "dom", "layoutManager", "connectionManager", "globalize", "loading", "material-icons", "formDialogStyle", "emby-button", "emby-itemscontainer", "cardStyle"], function (dialogHelper, dom, layoutManager, connectionManager, globalize, loading) {
"use strict";
function getEditorHtml() {
var html = "";
return html += '<div class="formDialogContent scrollY">', html += '<div class="dialogContentInner dialog-content-centered">', html += '<div class="loadingContent hide">', html += "<h1>" + globalize.translate("DetectingDevices") + "...</h1>", html += "<p>" + globalize.translate("MessagePleaseWait") + "</p>", html += "</div>", html += '<h1 style="margin-bottom:.25em;" class="devicesHeader hide">' + globalize.translate("HeaderNewDevices") + "</h1>", html += '<div is="emby-itemscontainer" class="results vertical-wrap">', html += "</div>", html += "</div>", html += "</div>"
html += '<div class="formDialogContent scrollY">';
html += '<div class="dialogContentInner dialog-content-centered">';
html += '<div class="loadingContent hide">';
html += "<h1>" + globalize.translate("DetectingDevices") + "...</h1>";
html += "<p>" + globalize.translate("MessagePleaseWait") + "</p>";
html += "</div>";
html += '<h1 style="margin-bottom:.25em;" class="devicesHeader hide">' + globalize.translate("HeaderNewDevices") + "</h1>";
html += '<div is="emby-itemscontainer" class="results vertical-wrap">';
html += "</div>";
html += "</div>";
return html += "</div>";
}
function getDeviceHtml(device) {
var padderClass, html = "",
cssClass = "card scalableCard",
cardBoxCssClass = "cardBox visualCardBox";
return cssClass += " backdropCard backdropCard-scalable", padderClass = "cardPadder-backdrop", layoutManager.tv && (cssClass += " card-focusscale", cardBoxCssClass += " cardBox-focustransform"), cardBoxCssClass += " card-focuscontent", html += '<button type="button" class="' + cssClass + '" data-id="' + device.DeviceId + '" style="min-width:33.3333%;">', html += '<div class="' + cardBoxCssClass + '">', html += '<div class="cardScalable visualCardBox-cardScalable">', html += '<div class="' + padderClass + '"></div>', html += '<div class="cardContent searchImage">', html += '<div class="cardImageContainer coveredImage"><i class="cardImageIcon md-icon">dvr</i></div>', html += "</div>", html += "</div>", html += '<div class="cardFooter visualCardBox-cardFooter">', html += '<div class="cardText cardTextCentered">' + getTunerName(device.Type) + "</div>", html += '<div class="cardText cardTextCentered cardText-secondary">' + device.FriendlyName + "</div>", html += '<div class="cardText cardText-secondary cardTextCentered">', html += device.Url || "&nbsp;", html += "</div>", html += "</div>", html += "</div>", html += "</button>"
var padderClass;
var html = "";
var cssClass = "card scalableCard";
var cardBoxCssClass = "cardBox visualCardBox";
cssClass += " backdropCard backdropCard-scalable";
padderClass = "cardPadder-backdrop";
if (layoutManager.tv) {
cssClass += " card-focusscale";
cardBoxCssClass += " cardBox-focustransform";
}
cardBoxCssClass += " card-focuscontent";
html += '<button type="button" class="' + cssClass + '" data-id="' + device.DeviceId + '" style="min-width:33.3333%;">';
html += '<div class="' + cardBoxCssClass + '">';
html += '<div class="cardScalable visualCardBox-cardScalable">';
html += '<div class="' + padderClass + '"></div>';
html += '<div class="cardContent searchImage">';
html += '<div class="cardImageContainer coveredImage"><i class="cardImageIcon md-icon">dvr</i></div>';
html += "</div>";
html += "</div>";
html += '<div class="cardFooter visualCardBox-cardFooter">';
html += '<div class="cardText cardTextCentered">' + getTunerName(device.Type) + "</div>";
html += '<div class="cardText cardTextCentered cardText-secondary">' + device.FriendlyName + "</div>";
html += '<div class="cardText cardText-secondary cardTextCentered">';
html += device.Url || "&nbsp;";
html += "</div>";
html += "</div>";
html += "</div>";
return html += "</button>";
}
function getTunerName(providerId) {
switch (providerId = providerId.toLowerCase()) {
case "m3u":
return "M3U";
case "hdhomerun":
return "HDHomerun";
case "hauppauge":
return "Hauppauge";
case "satip":
return "DVB";
default:
return "Unknown"
return "Unknown";
}
}
function renderDevices(view, devices) {
var i, length, html = "";
for (i = 0, length = devices.length; i < length; i++) html += getDeviceHtml(devices[i]);
devices.length ? view.querySelector(".devicesHeader").classList.remove("hide") : (html = "<p><br/>" + globalize.translate("NoNewDevicesFound") + "</p>", view.querySelector(".devicesHeader").classList.add("hide"));
var i;
var length;
var html = "";
for (i = 0, length = devices.length; i < length; i++) {
html += getDeviceHtml(devices[i]);
}
if (devices.length) {
view.querySelector(".devicesHeader").classList.remove("hide");
} else {
html = "<p><br/>" + globalize.translate("NoNewDevicesFound") + "</p>";
view.querySelector(".devicesHeader").classList.add("hide");
}
var elem = view.querySelector(".results");
elem.innerHTML = html, layoutManager.tv && focusManager.autoFocus(elem)
elem.innerHTML = html;
if (layoutManager.tv) {
focusManager.autoFocus(elem);
}
}
function discoverDevices(view, apiClient) {
return loading.show(), view.querySelector(".loadingContent").classList.remove("hide"), ApiClient.getJSON(ApiClient.getUrl("LiveTv/Tuners/Discvover", {
NewDevicesOnly: !0
})).then(function(devices) {
currentDevices = devices, renderDevices(view, devices), view.querySelector(".loadingContent").classList.add("hide"), loading.hide()
})
loading.show();
view.querySelector(".loadingContent").classList.remove("hide");
return ApiClient.getJSON(ApiClient.getUrl("LiveTv/Tuners/Discvover", {
NewDevicesOnly: true
})).then(function (devices) {
currentDevices = devices;
renderDevices(view, devices);
view.querySelector(".loadingContent").classList.add("hide");
loading.hide();
});
}
function tunerPicker() {
this.show = function(options) {
this.show = function (options) {
var dialogOptions = {
removeOnClose: !0,
scrollY: !1
removeOnClose: true,
scrollY: false
};
layoutManager.tv ? dialogOptions.size = "fullscreen" : dialogOptions.size = "small";
if (layoutManager.tv) {
dialogOptions.size = "fullscreen";
} else {
dialogOptions.size = "small";
}
var dlg = dialogHelper.createDialog(dialogOptions);
dlg.classList.add("formDialog");
var html = "";
html += '<div class="formDialogHeader">', html += '<button is="paper-icon-button-light" class="btnCancel autoSize" tabindex="-1"><i class="md-icon">&#xE5C4;</i></button>', html += '<h3 class="formDialogHeaderTitle">', html += globalize.translate("HeaderLiveTvTunerSetup"), html += "</h3>", html += "</div>", html += getEditorHtml(), dlg.innerHTML = html, dlg.querySelector(".btnCancel").addEventListener("click", function() {
dialogHelper.close(dlg)
html += '<div class="formDialogHeader">';
html += '<button is="paper-icon-button-light" class="btnCancel autoSize" tabindex="-1"><i class="md-icon">&#xE5C4;</i></button>';
html += '<h3 class="formDialogHeaderTitle">';
html += globalize.translate("HeaderLiveTvTunerSetup");
html += "</h3>";
html += "</div>";
html += getEditorHtml();
dlg.innerHTML = html;
dlg.querySelector(".btnCancel").addEventListener("click", function () {
dialogHelper.close(dlg);
});
var deviceResult;
dlg.querySelector(".results").addEventListener("click", function(e) {
dlg.querySelector(".results").addEventListener("click", function (e) {
var tunerCard = dom.parentWithClass(e.target, "card");
if (tunerCard) {
var deviceId = tunerCard.getAttribute("data-id");
deviceResult = currentDevices.filter(function(d) {
return d.DeviceId === deviceId
})[0], dialogHelper.close(dlg)
deviceResult = currentDevices.filter(function (d) {
return d.DeviceId === deviceId;
})[0];
dialogHelper.close(dlg);
}
}), layoutManager.tv && centerFocus(dlg.querySelector(".formDialogContent"), !1, !0);
});
if (layoutManager.tv) {
centerFocus(dlg.querySelector(".formDialogContent"), false, true);
}
var apiClient = connectionManager.getApiClient(options.serverId);
return discoverDevices(dlg, apiClient), layoutManager.tv && centerFocus(dlg.querySelector(".formDialogContent"), !1, !1), dialogHelper.open(dlg).then(function() {
return deviceResult ? Promise.resolve(deviceResult) : Promise.reject()
})
}
discoverDevices(dlg, apiClient);
if (layoutManager.tv) {
centerFocus(dlg.querySelector(".formDialogContent"), false, false);
}
return dialogHelper.open(dlg).then(function () {
if (deviceResult) {
return Promise.resolve(deviceResult);
}
return Promise.reject();
});
};
}
var currentDevices = [];
return tunerPicker
});
return tunerPicker;
});

View File

@ -1,119 +1,196 @@
define(["jQuery", "loading", "emby-checkbox", "listViewStyle", "emby-input", "emby-select", "emby-button", "flexStyles"], function($, loading) {
define(["jQuery", "loading", "emby-checkbox", "listViewStyle", "emby-input", "emby-select", "emby-button", "flexStyles"], function ($, loading) {
"use strict";
return function(page, providerId, options) {
return function (page, providerId, options) {
function reload() {
loading.show(), ApiClient.getNamedConfiguration("livetv").then(function(config) {
var info = config.ListingProviders.filter(function(i) {
return i.Id === providerId
loading.show();
ApiClient.getNamedConfiguration("livetv").then(function (config) {
var info = config.ListingProviders.filter(function (i) {
return i.Id === providerId;
})[0] || {};
listingsId = info.ListingsId, $("#selectListing", page).val(info.ListingsId || ""), page.querySelector(".txtUser").value = info.Username || "", page.querySelector(".txtPass").value = "", page.querySelector(".txtZipCode").value = info.ZipCode || "", info.Username && info.Password ? page.querySelector(".listingsSection").classList.remove("hide") : page.querySelector(".listingsSection").classList.add("hide"), page.querySelector(".chkAllTuners").checked = info.EnableAllTuners, page.querySelector(".chkAllTuners").checked ? page.querySelector(".selectTunersSection").classList.add("hide") : page.querySelector(".selectTunersSection").classList.remove("hide"), setCountry(info), refreshTunerDevices(page, info, config.TunerHosts)
})
listingsId = info.ListingsId;
$("#selectListing", page).val(info.ListingsId || "");
page.querySelector(".txtUser").value = info.Username || "";
page.querySelector(".txtPass").value = "";
page.querySelector(".txtZipCode").value = info.ZipCode || "";
if (info.Username && info.Password) {
page.querySelector(".listingsSection").classList.remove("hide");
} else {
page.querySelector(".listingsSection").classList.add("hide");
}
page.querySelector(".chkAllTuners").checked = info.EnableAllTuners;
if (info.EnableAllTuners) {
page.querySelector(".selectTunersSection").classList.add("hide");
} else {
page.querySelector(".selectTunersSection").classList.remove("hide");
}
setCountry(info);
refreshTunerDevices(page, info, config.TunerHosts);
});
}
function setCountry(info) {
ApiClient.getJSON(ApiClient.getUrl("LiveTv/ListingProviders/SchedulesDirect/Countries")).then(function(result) {
var i, length, countryList = [];
ApiClient.getJSON(ApiClient.getUrl("LiveTv/ListingProviders/SchedulesDirect/Countries")).then(function (result) {
var i;
var length;
var countryList = [];
for (var region in result) {
var countries = result[region];
if (countries.length && "ZZZ" !== region)
for (i = 0, length = countries.length; i < length; i++) countryList.push({
name: countries[i].fullName,
value: countries[i].shortName
})
if (countries.length && "ZZZ" !== region) {
for (i = 0, length = countries.length; i < length; i++) {
countryList.push({
name: countries[i].fullName,
value: countries[i].shortName
});
}
}
}
countryList.sort(function(a, b) {
return a.name > b.name ? 1 : a.name < b.name ? -1 : 0
}), $("#selectCountry", page).html(countryList.map(function(c) {
return '<option value="' + c.value + '">' + c.name + "</option>"
}).join("")).val(info.Country || ""), $(page.querySelector(".txtZipCode")).trigger("change")
}, function() {
countryList.sort(function (a, b) {
if (a.name > b.name) {
return 1;
}
if (a.name < b.name) {
return -1;
}
return 0;
});
$("#selectCountry", page).html(countryList.map(function (c) {
return '<option value="' + c.value + '">' + c.name + "</option>";
}).join("")).val(info.Country || "");
$(page.querySelector(".txtZipCode")).trigger("change");
}, function () { // ApiClient.getJSON() error handler
Dashboard.alert({
message: Globalize.translate("ErrorGettingTvLineups")
})
}), loading.hide()
});
});
loading.hide();
}
function sha256(str) {
if (!self.TextEncoder) return Promise.resolve("");
if (!self.TextEncoder) {
return Promise.resolve("");
}
var buffer = new TextEncoder("utf-8").encode(str);
return crypto.subtle.digest("SHA-256", buffer).then(function(hash) {
return hex(hash)
})
return crypto.subtle.digest("SHA-256", buffer).then(function (hash) {
return hex(hash);
});
}
function hex(buffer) {
for (var hexCodes = [], view = new DataView(buffer), i = 0; i < view.byteLength; i += 4) {
var value = view.getUint32(i),
stringValue = value.toString(16),
paddedValue = ("00000000" + stringValue).slice(-"00000000".length);
hexCodes.push(paddedValue)
var hexCodes = [];
var view = new DataView(buffer);
for (var i = 0; i < view.byteLength; i += 4) {
var value = view.getUint32(i);
var stringValue = value.toString(16);
var paddedValue = ("00000000" + stringValue).slice(-"00000000".length);
hexCodes.push(paddedValue);
}
return hexCodes.join("")
return hexCodes.join("");
}
function submitLoginForm() {
loading.show(), sha256(page.querySelector(".txtPass").value).then(function(passwordHash) {
loading.show();
sha256(page.querySelector(".txtPass").value).then(function (passwordHash) {
var info = {
Type: "SchedulesDirect",
Username: page.querySelector(".txtUser").value,
EnableAllTuners: !0,
Password: passwordHash,
Pw: page.querySelector(".txtPass").value
},
id = providerId;
id && (info.Id = id), ApiClient.ajax({
Type: "SchedulesDirect",
Username: page.querySelector(".txtUser").value,
EnableAllTuners: true,
Password: passwordHash,
Pw: page.querySelector(".txtPass").value
};
var id = providerId;
if (id) {
info.Id = id;
}
ApiClient.ajax({
type: "POST",
url: ApiClient.getUrl("LiveTv/ListingProviders", {
ValidateLogin: !0
ValidateLogin: true
}),
data: JSON.stringify(info),
contentType: "application/json",
dataType: "json"
}).then(function(result) {
Dashboard.processServerConfigurationUpdateResult(), providerId = result.Id, reload()
}, function() {
Dashboard.alert({
}).then(function (result) {
Dashboard.processServerConfigurationUpdateResult();
providerId = result.Id;
reload();
}, function () {
Dashboard.alert({ // ApiClient.ajax() error handler
message: Globalize.translate("ErrorSavingTvProvider")
})
})
})
});
});
});
}
function submitListingsForm() {
var selectedListingsId = $("#selectListing", page).val();
if (!selectedListingsId) return void Dashboard.alert({
message: Globalize.translate("ErrorPleaseSelectLineup")
});
if (!selectedListingsId) {
return void Dashboard.alert({
message: Globalize.translate("ErrorPleaseSelectLineup")
});
}
loading.show();
var id = providerId;
ApiClient.getNamedConfiguration("livetv").then(function(config) {
var info = config.ListingProviders.filter(function(i) {
return i.Id === id
ApiClient.getNamedConfiguration("livetv").then(function (config) {
var info = config.ListingProviders.filter(function (i) {
return i.Id === id;
})[0];
info.ZipCode = page.querySelector(".txtZipCode").value, info.Country = $("#selectCountry", page).val(), info.ListingsId = selectedListingsId, info.EnableAllTuners = page.querySelector(".chkAllTuners").checked, info.EnabledTuners = info.EnableAllTuners ? [] : $(".chkTuner", page).get().filter(function(i) {
return i.checked
}).map(function(i) {
return i.getAttribute("data-id")
}), ApiClient.ajax({
info.ZipCode = page.querySelector(".txtZipCode").value;
info.Country = $("#selectCountry", page).val();
info.ListingsId = selectedListingsId;
info.EnableAllTuners = page.querySelector(".chkAllTuners").checked;
info.EnabledTuners = info.EnableAllTuners ? [] : $(".chkTuner", page).get().filter(function (i) {
return i.checked;
}).map(function (i) {
return i.getAttribute("data-id");
});
ApiClient.ajax({
type: "POST",
url: ApiClient.getUrl("LiveTv/ListingProviders", {
ValidateListings: !0
ValidateListings: true
}),
data: JSON.stringify(info),
contentType: "application/json"
}).then(function(result) {
loading.hide(), !1 !== options.showConfirmation && Dashboard.processServerConfigurationUpdateResult(), Events.trigger(self, "submitted")
}, function() {
loading.hide(), Dashboard.alert({
}).then(function (result) {
loading.hide();
if (options.showConfirmation) {
Dashboard.processServerConfigurationUpdateResult();
}
Events.trigger(self, "submitted");
}, function () {
loading.hide();
Dashboard.alert({
message: Globalize.translate("ErrorAddingListingsToSchedulesDirect")
})
})
})
});
});
});
}
function refreshListings(value) {
if (!value) return void $("#selectListing", page).html("");
loading.show(), ApiClient.ajax({
if (!value) {
return void $("#selectListing", page).html("");
}
loading.show();
ApiClient.ajax({
type: "GET",
url: ApiClient.getUrl("LiveTv/ListingProviders/Lineups", {
Id: providerId,
@ -121,15 +198,23 @@ define(["jQuery", "loading", "emby-checkbox", "listViewStyle", "emby-input", "em
Country: $("#selectCountry", page).val()
}),
dataType: "json"
}).then(function(result) {
$("#selectListing", page).html(result.map(function(o) {
return '<option value="' + o.Id + '">' + o.Name + "</option>"
})), listingsId && $("#selectListing", page).val(listingsId), loading.hide()
}, function(result) {
}).then(function (result) {
$("#selectListing", page).html(result.map(function (o) {
return '<option value="' + o.Id + '">' + o.Name + "</option>";
}));
if (listingsId) {
$("#selectListing", page).val(listingsId);
}
loading.hide();
}, function (result) {
Dashboard.alert({
message: Globalize.translate("ErrorGettingTvLineups")
}), refreshListings(""), loading.hide()
})
});
refreshListings("");
loading.hide();
});
}
function getTunerName(providerId) {
@ -141,34 +226,76 @@ define(["jQuery", "loading", "emby-checkbox", "listViewStyle", "emby-input", "em
case "satip":
return "DVB";
default:
return "Unknown"
return "Unknown";
}
}
function refreshTunerDevices(page, providerInfo, devices) {
for (var html = "", i = 0, length = devices.length; i < length; i++) {
var html = "";
for (var i = 0, length = devices.length; i < length; i++) {
var device = devices[i];
html += '<div class="listItem">';
var enabledTuners = providerInfo.EnabledTuners || [],
isChecked = providerInfo.EnableAllTuners || -1 !== enabledTuners.indexOf(device.Id),
checkedAttribute = isChecked ? " checked" : "";
html += '<label class="checkboxContainer listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" data-id="' + device.Id + '" class="chkTuner" ' + checkedAttribute + "/><span></span></label>", html += '<div class="listItemBody two-line">', html += '<div class="listItemBodyText">', html += device.FriendlyName || getTunerName(device.Type), html += "</div>", html += '<div class="listItemBodyText secondary">', html += device.Url, html += "</div>", html += "</div>", html += "</div>"
var enabledTuners = providerInfo.EnabledTuners || [];
var isChecked = providerInfo.EnableAllTuners || -1 !== enabledTuners.indexOf(device.Id);
var checkedAttribute = isChecked ? " checked" : "";
html += '<label class="checkboxContainer listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" data-id="' + device.Id + '" class="chkTuner" ' + checkedAttribute + "/><span></span></label>";
html += '<div class="listItemBody two-line">';
html += '<div class="listItemBodyText">';
html += device.FriendlyName || getTunerName(device.Type);
html += "</div>";
html += '<div class="listItemBodyText secondary">';
html += device.Url;
html += "</div>";
html += "</div>";
html += "</div>";
}
page.querySelector(".tunerList").innerHTML = html
page.querySelector(".tunerList").innerHTML = html;
}
var listingsId, self = this;
self.submit = function() {
page.querySelector(".btnSubmitListingsContainer").click()
}, self.init = function() {
options = options || {}, !1 !== options.showCancelButton ? page.querySelector(".btnCancel").classList.remove("hide") : page.querySelector(".btnCancel").classList.add("hide"), !1 !== options.showSubmitButton ? page.querySelector(".btnSubmitListings").classList.remove("hide") : page.querySelector(".btnSubmitListings").classList.add("hide"), $(".formLogin", page).on("submit", function() {
return submitLoginForm(), !1
}), $(".formListings", page).on("submit", function() {
return submitListingsForm(), !1
}), $(".txtZipCode", page).on("change", function() {
refreshListings(this.value)
}), page.querySelector(".chkAllTuners").addEventListener("change", function(e) {
e.target.checked ? page.querySelector(".selectTunersSection").classList.add("hide") : page.querySelector(".selectTunersSection").classList.remove("hide")
}), $(".createAccountHelp", page).html(Globalize.translate("MessageCreateAccountAt", '<a is="emby-linkbutton" class="button-link" href="http://www.schedulesdirect.org" target="_blank">http://www.schedulesdirect.org</a>')), reload()
}
}
});
var listingsId;
var self = this;
self.submit = function () {
page.querySelector(".btnSubmitListingsContainer").click();
};
self.init = function () {
options = options || {};
if (options.showCancelButton) {
page.querySelector(".btnCancel").classList.remove("hide");
} else {
page.querySelector(".btnCancel").classList.add("hide");
}
if (options.showSubmitButton) {
page.querySelector(".btnSubmitListings").classList.remove("hide");
} else {
page.querySelector(".btnSubmitListings").classList.add("hide");
}
$(".formLogin", page).on("submit", function () {
submitLoginForm();
return false;
});
$(".formListings", page).on("submit", function () {
submitListingsForm();
return false;
});
$(".txtZipCode", page).on("change", function () {
refreshListings(this.value);
});
page.querySelector(".chkAllTuners").addEventListener("change", function (e) {
if (e.target.checked) {
page.querySelector(".selectTunersSection").classList.add("hide");
} else {
page.querySelector(".selectTunersSection").classList.remove("hide");
}
});
$(".createAccountHelp", page).html(Globalize.translate("MessageCreateAccountAt", '<a is="emby-linkbutton" class="button-link" href="http://www.schedulesdirect.org" target="_blank">http://www.schedulesdirect.org</a>'));
reload();
};
};
});

View File

@ -1,4 +1,4 @@
define(["jQuery", "loading", "emby-checkbox", "emby-input", "listViewStyle", "paper-icon-button-light"], function ($__q, loading) {
define(["jQuery", "loading", "emby-checkbox", "emby-input", "listViewStyle", "paper-icon-button-light"], function ($, loading) {
"use strict";
return function (page, providerId, options) {
@ -69,7 +69,7 @@ define(["jQuery", "loading", "emby-checkbox", "emby-input", "listViewStyle", "pa
info.NewsCategories = getCategories(page.querySelector(".txtNews"));
info.SportsCategories = getCategories(page.querySelector(".txtSports"));
info.EnableAllTuners = page.querySelector(".chkAllTuners").checked;
info.EnabledTuners = info.EnableAllTuners ? [] : $__q(".chkTuner", page).get().filter(function (tuner) {
info.EnabledTuners = info.EnableAllTuners ? [] : $(".chkTuner", page).get().filter(function (tuner) {
return tuner.checked;
}).map(function (tuner) {
return tuner.getAttribute("data-id");
@ -135,8 +135,8 @@ define(["jQuery", "loading", "emby-checkbox", "emby-input", "listViewStyle", "pa
page.querySelector(".tunerList").innerHTML = html;
}
function onSelectPathClick(e__u) {
var page = $__q(e__u.target).parents(".xmltvForm")[0];
function onSelectPathClick(e) {
var page = $(e.target).parents(".xmltvForm")[0];
require(["directorybrowser"], function (directoryBrowser) {
var picker = new directoryBrowser();
@ -175,7 +175,7 @@ define(["jQuery", "loading", "emby-checkbox", "emby-input", "listViewStyle", "pa
page.querySelector(".btnSubmitListings").classList.add("hide");
}
$__q("form", page).on("submit", function () {
$("form", page).on("submit", function () {
submitListingsForm();
return false;
});