mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
more deminification
This commit is contained in:
parent
44ba7a5cc4
commit
141ff8887f
2 changed files with 83 additions and 36 deletions
|
@ -2,9 +2,18 @@ define(["jQuery", "loading", "fnchecked", "emby-checkbox", "emby-textarea", "emb
|
|||
"use strict";
|
||||
|
||||
function loadPage(page, config, languageOptions, systemInfo) {
|
||||
systemInfo.CanLaunchWebBrowser ? page.querySelector("#fldRunWebAppAtStartup").classList.remove("hide") : page.querySelector("#fldRunWebAppAtStartup").classList.add("hide"), page.querySelector("#txtCachePath").value = config.CachePath || "", $("#selectLocalizationLanguage", page).html(languageOptions.map(function(l) {
|
||||
systemInfo.CanLaunchWebBrowser ? page.querySelector("#fldRunWebAppAtStartup").classList.remove("hide") : page.querySelector("#fldRunWebAppAtStartup").classList.add("hide");
|
||||
page.querySelector("#txtCachePath").value = config.CachePath || "";
|
||||
$("#selectLocalizationLanguage", page).html(languageOptions.map(function(l) {
|
||||
return '<option value="' + l.Value + '">' + l.Name + "</option>"
|
||||
})).val(config.UICulture), currentLanguage = config.UICulture, systemInfo.CanSelfUpdate ? page.querySelector(".fldAutomaticUpdates").classList.remove("hide") : page.querySelector(".fldAutomaticUpdates").classList.add("hide"), $("#chkEnableAutomaticServerUpdates", page).checked(config.EnableAutoUpdate), $("#chkEnableAutomaticRestart", page).checked(config.EnableAutomaticRestart), systemInfo.CanSelfRestart ? page.querySelector("#fldEnableAutomaticRestart").classList.remove("hide") : page.querySelector("#fldEnableAutomaticRestart").classList.add("hide"), systemInfo.CanSelfRestart || systemInfo.CanSelfUpdate ? $(".autoUpdatesContainer", page).removeClass("hide") : $(".autoUpdatesContainer", page).addClass("hide"), loading.hide()
|
||||
})).val(config.UICulture);
|
||||
currentLanguage = config.UICulture;
|
||||
systemInfo.CanSelfUpdate ? page.querySelector(".fldAutomaticUpdates").classList.remove("hide") : page.querySelector(".fldAutomaticUpdates").classList.add("hide");
|
||||
$("#chkEnableAutomaticServerUpdates", page).checked(config.EnableAutoUpdate);
|
||||
$("#chkEnableAutomaticRestart", page).checked(config.EnableAutomaticRestart);
|
||||
systemInfo.CanSelfRestart ? page.querySelector("#fldEnableAutomaticRestart").classList.remove("hide") : page.querySelector("#fldEnableAutomaticRestart").classList.add("hide");
|
||||
systemInfo.CanSelfRestart || systemInfo.CanSelfUpdate ? $(".autoUpdatesContainer", page).removeClass("hide") : $(".autoUpdatesContainer", page).addClass("hide");
|
||||
loading.hide();
|
||||
}
|
||||
|
||||
function onSubmit() {
|
||||
|
@ -35,16 +44,21 @@ define(["jQuery", "loading", "fnchecked", "emby-checkbox", "emby-textarea", "emb
|
|||
})
|
||||
}), !1
|
||||
}
|
||||
var currentBrandingOptions, currentLanguage, brandingConfigKey = "branding";
|
||||
|
||||
var currentBrandingOptions;
|
||||
var currentLanguage;
|
||||
var brandingConfigKey = "branding";
|
||||
|
||||
return function(view, params) {
|
||||
$("#btnSelectCachePath", view).on("click.selectDirectory", function() {
|
||||
require(["directorybrowser"], function(directoryBrowser) {
|
||||
var picker = new directoryBrowser;
|
||||
picker.show({
|
||||
callback: function(path) {
|
||||
path && (view.querySelector("#txtCachePath").value = path), picker.close()
|
||||
path && (view.querySelector("#txtCachePath").value = path);
|
||||
picker.close();
|
||||
},
|
||||
validateWriteable: !0,
|
||||
validateWriteable: true,
|
||||
header: Globalize.translate("HeaderSelectServerCachePath"),
|
||||
instruction: Globalize.translate("HeaderSelectServerCachePathHelp")
|
||||
})
|
||||
|
@ -58,25 +72,31 @@ define(["jQuery", "loading", "fnchecked", "emby-checkbox", "emby-textarea", "emb
|
|||
path: $("#txtMetadataPath", view).val(),
|
||||
networkSharePath: $("#txtMetadataNetworkPath", view).val(),
|
||||
callback: function(path, networkPath) {
|
||||
path && ($("#txtMetadataPath", view).val(path), $("#txtMetadataNetworkPath", view).val(networkPath)), picker.close()
|
||||
path && ($("#txtMetadataPath", view).val(path);
|
||||
$("#txtMetadataNetworkPath", view).val(networkPath));
|
||||
picker.close();
|
||||
},
|
||||
validateWriteable: !0,
|
||||
validateWriteable: true,
|
||||
header: Globalize.translate("HeaderSelectMetadataPath"),
|
||||
instruction: Globalize.translate("HeaderSelectMetadataPathHelp"),
|
||||
enableNetworkSharePath: !0
|
||||
enableNetworkSharePath: true
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
$(".dashboardGeneralForm", view).off("submit", onSubmit).on("submit", onSubmit), view.addEventListener("viewshow", function() {
|
||||
var promise1 = ApiClient.getServerConfiguration(),
|
||||
promise2 = ApiClient.getJSON(ApiClient.getUrl("Localization/Options")),
|
||||
promise3 = ApiClient.getSystemInfo();
|
||||
$(".dashboardGeneralForm", view).off("submit", onSubmit).on("submit", onSubmit);
|
||||
view.addEventListener("viewshow", function() {
|
||||
var promise1 = ApiClient.getServerConfiguration();
|
||||
var promise2 = ApiClient.getJSON(ApiClient.getUrl("Localization/Options"));
|
||||
var promise3 = ApiClient.getSystemInfo();
|
||||
Promise.all([promise1, promise2, promise3]).then(function(responses) {
|
||||
loadPage(view, responses[0], responses[1], responses[2])
|
||||
}), ApiClient.getNamedConfiguration(brandingConfigKey).then(function(config) {
|
||||
currentBrandingOptions = config, view.querySelector("#txtLoginDisclaimer").value = config.LoginDisclaimer || "", view.querySelector("#txtCustomCss").value = config.CustomCss || ""
|
||||
})
|
||||
})
|
||||
loadPage(view, responses[0], responses[1], responses[2]);
|
||||
});
|
||||
ApiClient.getNamedConfiguration(brandingConfigKey).then(function(config) {
|
||||
currentBrandingOptions = config;
|
||||
view.querySelector("#txtLoginDisclaimer").value = config.LoginDisclaimer || "";
|
||||
view.querySelector("#txtCustomCss").value = config.CustomCss || "";
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -2,45 +2,66 @@ define(["jQuery", "loading", "libraryMenu", "fnchecked", "emby-checkbox", "emby-
|
|||
"use strict";
|
||||
|
||||
function loadPage(page, config) {
|
||||
config.MergeMetadataAndImagesByName ? $(".fldImagesByName", page).hide() : $(".fldImagesByName", page).show(), $("#chkSaveMetadataHidden", page).checked(config.SaveMetadataHidden), $("#txtMetadataPath", page).val(config.MetadataPath || ""), $("#txtMetadataNetworkPath", page).val(config.MetadataNetworkPath || ""), loading.hide()
|
||||
config.MergeMetadataAndImagesByName ? $(".fldImagesByName", page).hide() : $(".fldImagesByName", page).show();
|
||||
$("#chkSaveMetadataHidden", page).checked(config.SaveMetadataHidden);
|
||||
$("#txtMetadataPath", page).val(config.MetadataPath || "");
|
||||
$("#txtMetadataNetworkPath", page).val(config.MetadataNetworkPath || "");
|
||||
loading.hide();
|
||||
}
|
||||
|
||||
function loadMetadataConfig(page, config) {
|
||||
$("#selectDateAdded", page).val(config.UseFileCreationTimeForDateAdded ? "1" : "0")
|
||||
$("#selectDateAdded", page).val(config.UseFileCreationTimeForDateAdded ? "1" : "0");
|
||||
}
|
||||
|
||||
function loadFanartConfig(page, config) {
|
||||
$("#txtFanartApiKey", page).val(config.UserApiKey || "")
|
||||
$("#txtFanartApiKey", page).val(config.UserApiKey || "");
|
||||
}
|
||||
|
||||
function saveFanart(form) {
|
||||
ApiClient.getNamedConfiguration("fanart").then(function(config) {
|
||||
config.UserApiKey = $("#txtFanartApiKey", form).val(), ApiClient.updateNamedConfiguration("fanart", config)
|
||||
})
|
||||
config.UserApiKey = $("#txtFanartApiKey", form).val(), ApiClient.updateNamedConfiguration("fanart", config);
|
||||
});
|
||||
}
|
||||
|
||||
function saveMetadata(form) {
|
||||
ApiClient.getNamedConfiguration("metadata").then(function(config) {
|
||||
config.UseFileCreationTimeForDateAdded = "1" === $("#selectDateAdded", form).val(), ApiClient.updateNamedConfiguration("metadata", config)
|
||||
config.UseFileCreationTimeForDateAdded = "1" === $("#selectDateAdded", form).val(), ApiClient.updateNamedConfiguration("metadata", config);
|
||||
})
|
||||
}
|
||||
|
||||
function alertText(options) {
|
||||
require(["alert"], function(alert) {
|
||||
alert(options)
|
||||
})
|
||||
alert(options);
|
||||
});
|
||||
}
|
||||
|
||||
function onSubmitFail(response) {
|
||||
loading.hide(), response && 404 === response.status ? alertText("The metadata path entered could not be found. Please ensure the path is valid and try again.") : response && 500 === response.status && alertText("The metadata path entered is not valid. Please ensure the path exists and that Jellyfin server has write access to the folder.")
|
||||
loading.hide();
|
||||
if (response && ) {
|
||||
if (response.status === 404) {
|
||||
alertText("The metadata path entered could not be found. Please ensure the path is valid and try again.");
|
||||
} else if (response.status === 500) {
|
||||
alertText("The metadata path entered is not valid. Please ensure the path exists and that Jellyfin server has write access to the folder.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onSubmit() {
|
||||
loading.show();
|
||||
var form = this;
|
||||
return ApiClient.getServerConfiguration().then(function(config) {
|
||||
config.SaveMetadataHidden = $("#chkSaveMetadataHidden", form).checked(), config.EnableTvDbUpdates = $("#chkEnableTvdbUpdates", form).checked(), config.EnableTmdbUpdates = $("#chkEnableTmdbUpdates", form).checked(), config.EnableFanArtUpdates = $("#chkEnableFanartUpdates", form).checked(), config.MetadataPath = $("#txtMetadataPath", form).val(), config.MetadataNetworkPath = $("#txtMetadataNetworkPath", form).val(), config.FanartApiKey = $("#txtFanartApiKey", form).val(), ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult, onSubmitFail)
|
||||
}), saveMetadata(form), saveFanart(form), !1
|
||||
ApiClient.getServerConfiguration().then(function(config) {
|
||||
config.SaveMetadataHidden = $("#chkSaveMetadataHidden", form).checked();
|
||||
config.EnableTvDbUpdates = $("#chkEnableTvdbUpdates", form).checked();
|
||||
config.EnableTmdbUpdates = $("#chkEnableTmdbUpdates", form).checked();
|
||||
config.EnableFanArtUpdates = $("#chkEnableFanartUpdates", form).checked();
|
||||
config.MetadataPath = $("#txtMetadataPath", form).val();
|
||||
config.MetadataNetworkPath = $("#txtMetadataNetworkPath", form).val();
|
||||
config.FanartApiKey = $("#txtFanartApiKey", form).val();
|
||||
ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult, onSubmitFail);
|
||||
});
|
||||
saveMetadata(form);
|
||||
saveFanart(form);
|
||||
return false;
|
||||
}
|
||||
|
||||
function getTabs() {
|
||||
|
@ -61,19 +82,25 @@ define(["jQuery", "loading", "libraryMenu", "fnchecked", "emby-checkbox", "emby-
|
|||
name: Globalize.translate("TabAdvanced")
|
||||
}]
|
||||
}
|
||||
|
||||
return function(view, params) {
|
||||
$(".librarySettingsForm").off("submit", onSubmit).on("submit", onSubmit), view.addEventListener("viewshow", function() {
|
||||
libraryMenu.setTabs("librarysetup", 4, getTabs), loading.show();
|
||||
$(".librarySettingsForm").off("submit", onSubmit).on("submit", onSubmit);
|
||||
view.addEventListener("viewshow", function() {
|
||||
libraryMenu.setTabs("librarysetup", 4, getTabs);
|
||||
loading.show();
|
||||
var page = this;
|
||||
ApiClient.getServerConfiguration().then(function(config) {
|
||||
loadPage(page, config)
|
||||
}), ApiClient.getNamedConfiguration("metadata").then(function(metadata) {
|
||||
});
|
||||
ApiClient.getNamedConfiguration("metadata").then(function(metadata) {
|
||||
loadMetadataConfig(page, metadata)
|
||||
}), ApiClient.getNamedConfiguration("fanart").then(function(metadata) {
|
||||
});
|
||||
ApiClient.getNamedConfiguration("fanart").then(function(metadata) {
|
||||
loadFanartConfig(page, metadata)
|
||||
}), ApiClient.getSystemInfo().then(function(info) {
|
||||
});
|
||||
ApiClient.getSystemInfo().then(function(info) {
|
||||
"Windows" === info.OperatingSystem ? page.querySelector(".fldSaveMetadataHidden").classList.remove("hide") : page.querySelector(".fldSaveMetadataHidden").classList.add("hide")
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue