EmbyCrackedClient/web/librarysetup/advancedtab.js

1 line
5.3 KiB
JavaScript
Raw Normal View History

2025-06-25 11:46:04 +08:00
import BaseTab from"./../modules/tabbedview/basesettingstab.js";import loading from"./../modules/loading/loading.js";import globalize from"./../modules/common/globalize.js";import"./../modules/emby-elements/emby-input/emby-input.js";import"./../modules/emby-elements/emby-button/emby-button.js";import"./../modules/emby-elements/emby-checkbox/emby-checkbox.js";import"./../modules/emby-elements/emby-select/emby-select.js";import formHelper from"./../modules/common/responsehelper.js";function showAlert(options){return Emby.importModule("./modules/common/dialogs/alert.js").then(function(alert){return alert(options)})}function populateLanguages(select,apiClient){return apiClient.getCultures().then(function(languages){let html="";html+="<option value=''></option>";for(let i=0,length=languages.length;i<length;i++){var culture=languages[i];html+="<option value='"+culture.TwoLetterISOLanguageName+"'>"+culture.DisplayName+"</option>"}select.innerHTML=html})}function populateCountries(select,apiClient){return apiClient.getCountries().then(function(allCountries){let html="";html+="<option value=''></option>";for(let i=0,length=allCountries.length;i<length;i++){var culture=allCountries[i];html+="<option value='"+culture.TwoLetterISORegionName+"'>"+culture.DisplayName+"</option>"}select.innerHTML=html})}function loadPage(page,config,systemInfo){let metadataPath=config.MetadataPath||"";metadataPath=metadataPath||systemInfo.InternalMetadataPath,page.querySelector(".txtMetadataPath").value=metadataPath,page.querySelector(".txtMetadataNetworkPath").value=config.MetadataNetworkPath||"",page.querySelector(".chkExternalContentInSuggestions").checked=config.EnableExternalContentInSuggestions,page.querySelector(".chkPeopleMetadata").checked=config.EnableSavedMetadataForPeople,page.querySelector(".selectLanguage").value=config.PreferredMetadataLanguage||"",page.querySelector(".selectCountry").value=config.MetadataCountryCode||"",loading.hide()}function loadMetadataConfig(page,config){page.querySelector(".selectDateAdded").value=config.UseFileCreationTimeForDateAdded?"1":"0"}function saveMetadata(form,apiClient){apiClient.getNamedConfiguration("metadata").then(function(config){config.UseFileCreationTimeForDateAdded="1"===form.querySelector(".selectDateAdded").value,apiClient.updateNamedConfiguration("metadata",config)})}function onSubmitFail(response){loading.hide(),response&&404===response.status?showAlert("The metadata path entered could not be found. Please ensure the path is valid and try again."):response&&500===response.status&&showAlert("The metadata path entered is not valid. Please ensure the path exists and that Emby server has write access to the folder.")}function onSubmit(e){loading.show();let form=e.target,apiClient=this.getApiClient();return apiClient.getServerConfiguration().then(function(config){config.PreferredMetadataLanguage=form.querySelector(".selectLanguage").value,config.MetadataCountryCode=form.querySelector(".selectCountry").value,config.MetadataPath=form.querySelector(".txtMetadataPath").value,config.MetadataNetworkPath=form.querySelector(".txtMetadataNetworkPath").value,config.EnableExternalContentInSuggestions=form.querySelector(".chkExternalContentInSuggestions").checked,config.EnableSavedMetadataForPeople=form.querySelector(".chkPeopleMetadata").checked,apiClient.updateServerConfiguration(config).then(formHelper.handleConfigurationSavedResponse,onSubmitFail)}),saveMetadata(form,apiClient),e.preventDefault(),e.stopPropagation(),!1}function View(view,params){BaseTab.apply(this,arguments)}Object.assign(View.prototype,BaseTab.prototype),View.prototype.onTemplateLoaded=function(){BaseTab.prototype.onTemplateLoaded.apply(this,arguments);let view=this.view;view.querySelector(".metadataPathDescription").innerHTML=globalize.translate("LabelMetadataPathHelp",'<a href="scheduledtasks" is="emby-linkbutton" class="button-link">',"</a>"),view.querySelector(".btnSelectMetadataPath").addEventListener("click",function(){Emby.importModule("./modules/directorybrowser/directorybrowser.js").then(function(directoryBrowser){let picker=ne