EmbyCrackedClient/web/settings/download/settingstab.js

1 line
6.4 KiB
JavaScript
Raw Permalink Normal View History

2025-06-25 11:46:04 +08:00
import BaseTab from"./../../modules/tabbedview/basesettingstab.js";import globalize from"./../../modules/common/globalize.js";import"./../../modules/emby-elements/emby-scroller/emby-scroller.js";import"./../../modules/emby-elements/emby-select/emby-select.js";import"./../../modules/emby-elements/emby-button/emby-button.js";import"./../../modules/emby-elements/emby-button/paper-icon-button-light.js";import"./../../modules/emby-elements/emby-input/emby-input.js";import"./../../modules/emby-elements/emby-checkbox/emby-checkbox.js";import appSettings from"./../../modules/common/appsettings.js";import events from"./../../modules/emby-apiclient/events.js";import{localSync}from"./../../modules/common/servicelocator.js";import textEncoding from"./../../modules/common/textencoding.js";function fillAndroidLocation(view){let html='<option value="">'+globalize.translate("InternalStorage")+"</option>";var dirs=AndroidAppHost.getWritableExternalStorageDirs(),size=dirs.size();for(let i=0;i<size;i++){var dir=dirs.get(i),name=dir.getName(),dir=dir.getUuid();let value=dir?dir:"%externalstorage%";html+='<option value="'+value+'">'+globalize.translate("ExternalStorage")+" ("+textEncoding.htmlEncode(name)+")</option>"}view=view.querySelector(".selectSyncLocation");view.innerHTML=html,view.value=appSettings.syncPath()||""}function filliOSLocation(view){var html='<option value="">'+globalize.translate("InternalStorage")+"</option>";let syncPathValue="%externalstorage%",syncPathName="";var syncPath=appSettings.syncPath(),view=(syncPath&&syncPath.length?(syncPathValue=syncPath,syncPathName=" ("+syncPath.split("/").pop()+")",view.querySelector(".btnSelectPickerSyncPath").classList.remove("hide")):view.querySelector(".btnSelectPickerSyncPath").classList.add("hide"),html+='<option value="'+syncPathValue+'">Custom'+textEncoding.htmlEncode(syncPathName)+"</option>",view.querySelector(".selectSyncLocation"));view.innerHTML=html,view.value=syncPath||""}function onAndroidSyncLocationChange(e){e=e.target.closest("form").querySelector(".selectSyncLocation").value;appSettings.syncPath(e),AndroidAppSettings.setSyncPath(e),MainActivity.authorizeStorage()}function oniOSSyncLocationChange(e){var e=e.target.closest("form"),path=e.querySelector(".selectSyncLocation").value,path=("%externalstorage%"===path?selectDownloadPathiOS.call(this):appSettings.syncPath(path),appSettings.syncPath());path&&path.length?e.querySelector(".btnSelectPickerSyncPath").classList.remove("hide"):e.querySelector(".btnSelectPickerSyncPath").classList.add("hide")}function loadForm(view){view.querySelector(".txtSyncPath").value=appSettings.syncPath()||"",window.AndroidAppSettings?fillAndroidLocation(view):window.webkit.messageHandlers&&filliOSLocation(view)}function selectDownloadPathiOS(){let selectContainer=this.closest(".selectContainer");window.webkit.messageHandlers.selectSyncLocation.postMessage({}).then(function(result){result?(appSettings.syncPath(result.Path||""),console.log("Picked folder: "+result),filliOSLocation(selectContainer)):appSettings.syncPath("")},function(){console.log("Operation cancelled."),filliOSLocation(selectContainer)})}function selectDownloadPathWindows(){let inputContainer=this.closest(".inputContainer");var folderPicker=new Windows.Storage.Pickers.FolderPicker;folderPicker.suggestedStartLocation=Windows.Storage.Pickers.PickerLocationId.desktop,folderPicker.fileTypeFilter.replaceAll(["*"]),folderPicker.pickSingleFolderAsync().then(function(folder){folder?(Windows.Storage.AccessCache.StorageApplicationPermissions.futureAccessList.addOrReplace("PickedFolderToken",folder),inputContainer.querySelector(".txtSyncPath").value=folder.path,appSettings.syncPath(folder.path),console.log("Picked folder: "+folder.path)):console.log("Operation cancelled.")})}function onDownloadProgress(e,progressInfo){var numItems=progressInfo.numItems||0,numItemsComplete=progressInfo.numItemsComplete||0,progressInfo=progressInfo.totalPercentComplete||0;this.itemProgressBarForeground.style.width=progressInfo+"%",this.progressDescription.innerHTML=globalize.translate("DownloadNumItems",nu