fix js crash from missing method and deminification

This commit is contained in:
dkanada 2019-03-06 18:18:49 +09:00
parent 579fbe90c8
commit 74eabd2af9
3 changed files with 80 additions and 24 deletions

View File

@ -2,31 +2,54 @@ define(["globalize", "loading", "libraryMenu", "dom", "emby-input", "emby-button
"use strict";
function isM3uVariant(type) {
return -1 !== ["nextpvr"].indexOf(type || "")
return ["nextpvr"].indexOf(type || "") !== -1;
}
function fillTypes(view, currentId) {
return ApiClient.getJSON(ApiClient.getUrl("LiveTv/TunerHosts/Types")).then(function(types) {
ApiClient.getJSON(ApiClient.getUrl("LiveTv/TunerHosts/Types")).then(function(types) {
var selectType = view.querySelector(".selectType");
selectType.innerHTML = types.map(function(t) {
return '<option value="' + t.Id + '">' + t.Name + "</option>"
}).join("") + '<option value="other">' + globalize.translate("TabOther") + "</option>", selectType.disabled = null != currentId, selectType.value = "", onTypeChange.call(selectType)
})
return '<option value="' + t.Id + '">' + t.Name + "</option>";
}).join("");
selectType.innerHTML += '<option value="other">';
selectType.innerHTML += globalize.translate("TabOther");
selectType.innerHTML += "</option>";
selectType.disabled = null != currentId;
selectType.value = "";
onTypeChange.call(selectType);
});
}
function reload(view, providerId) {
view.querySelector(".txtDevicePath").value = "", view.querySelector(".chkFavorite").checked = !1, view.querySelector(".txtDevicePath").value = "", providerId && ApiClient.getNamedConfiguration("livetv").then(function(config) {
var info = config.TunerHosts.filter(function(i) {
return i.Id === providerId
})[0];
fillTunerHostInfo(view, info)
})
view.querySelector(".txtDevicePath").value = "";
view.querySelector(".chkFavorite").checked = false;
view.querySelector(".txtDevicePath").value = "";
if (providerId) {
ApiClient.getNamedConfiguration("livetv").then(function(config) {
var info = config.TunerHosts.filter(function(i) {
return i.Id === providerId;
})[0];
fillTunerHostInfo(view, info);
});
}
}
function fillTunerHostInfo(view, info) {
var selectType = view.querySelector(".selectType"),
type = info.Type || "";
info.Source && isM3uVariant(info.Source) && (type = info.Source), selectType.value = type, onTypeChange.call(selectType), view.querySelector(".txtDevicePath").value = info.Url || "", view.querySelector(".txtFriendlyName").value = info.FriendlyName || "", view.querySelector(".txtUserAgent").value = info.UserAgent || "", view.querySelector(".fldDeviceId").value = info.DeviceId || "", view.querySelector(".chkFavorite").checked = info.ImportFavoritesOnly, view.querySelector(".chkTranscode").checked = info.AllowHWTranscoding, view.querySelector(".chkStreamLoop").checked = info.EnableStreamLooping, view.querySelector(".txtTunerCount").value = info.TunerCount || "0"
var selectType = view.querySelector(".selectType");
var type = info.Type || "";
if (info.Source && isM3uVariant(info.Source)) {
selectType.value = info.Source;
onTypeChange.call(selectType);
}
view.querySelector(".txtDevicePath").value = info.Url || "";
view.querySelector(".txtFriendlyName").value = info.FriendlyName || "";
view.querySelector(".txtUserAgent").value = info.UserAgent || "";
view.querySelector(".fldDeviceId").value = info.DeviceId || "";
view.querySelector(".chkFavorite").checked = info.ImportFavoritesOnly;
view.querySelector(".chkTranscode").checked = info.AllowHWTranscoding;
view.querySelector(".chkStreamLoop").checked = info.EnableStreamLooping;
view.querySelector(".txtTunerCount").value = info.TunerCount || "0";
}
function submitForm(page) {
@ -92,7 +115,6 @@ define(["globalize", "loading", "libraryMenu", "dom", "emby-input", "emby-button
}
return function(view, params) {
params.id || view.querySelector(".btnDetect").classList.remove("hide"), view.addEventListener("viewshow", function() {
libraryMenu.setTabs("livetvadmin", 0, getTabs);
var currentId = params.id;
fillTypes(view, currentId).then(function() {
reload(view, currentId)

View File

@ -230,7 +230,6 @@ define(["jQuery", "globalize", "scripts/taskbutton", "dom", "libraryMenu", "layo
addProvider(this)
}), page.querySelector(".devicesList").addEventListener("click", onDevicesListClick)
}).on("pageshow", "#liveTvStatusPage", function() {
libraryMenu.setTabs("livetvadmin", 0, getTabs);
var page = this;
reload(page), taskButton({
mode: "on",

View File

@ -2,20 +2,55 @@ define(["loading", "libraryMenu", "globalize", "listViewStyle", "emby-linkbutton
"use strict";
function reload(page) {
loading.show(), ApiClient.getJSON(ApiClient.getUrl("Notifications/Types")).then(function(list) {
var html = "",
lastCategory = "",
showHelp = !0;
loading.show();
ApiClient.getJSON(ApiClient.getUrl("Notifications/Types")).then(function(list) {
var html = "";
var lastCategory = "";
var showHelp = true;
html += list.map(function(i) {
var itemHtml = "";
return i.Category != lastCategory && (lastCategory = i.Category, lastCategory && (itemHtml += "</div>", itemHtml += "</div>"), itemHtml += '<div class="verticalSection verticalSection-extrabottompadding">', itemHtml += '<div class="sectionTitleContainer" style="margin-bottom:1em;">', itemHtml += '<h2 class="sectionTitle">', itemHtml += i.Category, itemHtml += "</h2>", showHelp && (showHelp = !1, itemHtml += '<a is="emby-linkbutton" class="raised button-alt headerHelpButton" target="_blank" href="https://web.archive.org/web/20181216120305/https://github.com/MediaBrowser/Wiki/wiki/Notifications">' + globalize.translate("Help") + "</a>"), itemHtml += "</div>", itemHtml += '<div class="paperList">'), itemHtml += '<a class="listItem listItem-border" is="emby-linkbutton" data-ripple="false" href="notificationsetting.html?type=' + i.Type + '">', i.Enabled ? itemHtml += '<i class="listItemIcon md-icon">notifications_active</i>' : itemHtml += '<i class="listItemIcon md-icon" style="background-color:#999;">notifications_off</i>', itemHtml += '<div class="listItemBody">', itemHtml += '<div class="listItemBodyText">' + i.Name + "</div>", itemHtml += "</div>", itemHtml += '<button type="button" is="paper-icon-button-light"><i class="md-icon">mode_edit</i></button>', itemHtml += "</a>"
}).join(""), list.length && (html += "</div>", html += "</div>"), page.querySelector(".notificationList").innerHTML = html, loading.hide()
if (i.Category !== lastCategory) {
lastCategory = i.Category;
if (lastCategory) {
itemHtml += "</div>";
itemHtml += "</div>";
}
itemHtml += '<div class="verticalSection verticalSection-extrabottompadding">';
itemHtml += '<div class="sectionTitleContainer" style="margin-bottom:1em;">';
itemHtml += '<h2 class="sectionTitle">';
itemHtml += i.Category;
itemHtml += "</h2>";
if (showHelp) {
showHelp = false;
itemHtml += '<a is="emby-linkbutton" class="raised button-alt headerHelpButton" target="_blank" href="https://web.archive.org/web/20181216120305/https://github.com/MediaBrowser/Wiki/wiki/Notifications">';
itemHtml += globalize.translate("Help");
itemHtml += "</a>";
}
itemHtml += "</div>";
itemHtml += '<div class="paperList">';
}
itemHtml += '<a class="listItem listItem-border" is="emby-linkbutton" data-ripple="false" href="notificationsetting.html?type=' + i.Type + '">';
i.Enabled ? itemHtml += '<i class="listItemIcon md-icon">notifications_active</i>' : itemHtml += '<i class="listItemIcon md-icon" style="background-color:#999;">notifications_off</i>';
itemHtml += '<div class="listItemBody">';
itemHtml += '<div class="listItemBodyText">' + i.Name + "</div>";
itemHtml += "</div>";
itemHtml += '<button type="button" is="paper-icon-button-light"><i class="md-icon">mode_edit</i></button>';
itemHtml += "</a>";
return itemHtml;
}).join("");
if (list.length) {
html += "</div>";
html += "</div>";
}
page.querySelector(".notificationList").innerHTML = html;
loading.hide();
})
}
return function(view, params) {
view.addEventListener("viewshow", function() {
libraryMenu.setTabs("notifications", 0, getTabs), reload(view)
})
reload(view);
});
}
});