jellyfin-web/dashboard-ui/scripts/mysyncsettings.js
2018-09-12 19:26:21 +02:00

1 line
1.5 KiB
JavaScript

define(["appSettings","apphost","emby-checkbox","emby-select","emby-input"],function(appSettings,appHost){"use strict";function loadForm(page,user){page.querySelector("#txtSyncPath").value=appSettings.syncPath()||"",page.querySelector("#chkWifi").checked=appSettings.syncOnlyOnWifi(),page.querySelector(".selectAudioBitrate").value=appSettings.maxStaticMusicBitrate()||""}function saveUser(page){var syncPath=page.querySelector("#txtSyncPath").value;appSettings.syncPath(syncPath),appSettings.syncOnlyOnWifi(page.querySelector("#chkWifi").checked),appSettings.maxStaticMusicBitrate(page.querySelector(".selectAudioBitrate").value||null),require(["localsync"],function(localSync){localSync.sync()})}return function(view,params){view.querySelector("form").addEventListener("submit",function(e){return saveUser(view),e.preventDefault(),!1}),view.querySelector("#btnSelectSyncPath").addEventListener("click",function(){require(["nativedirectorychooser"],function(){NativeDirectoryChooser.chooseDirectory().then(function(path){path&&(view.querySelector("#txtSyncPath").value=path)})})}),view.addEventListener("viewshow",function(){var page=this,userId=getParameterByName("userId")||Dashboard.getCurrentUserId();ApiClient.getUser(userId).then(function(user){loadForm(page,user)}),appHost.supports("customsyncpath")?page.querySelector(".fldSyncPath").classList.remove("hide"):page.querySelector(".fldSyncPath").classList.add("hide")}),view.addEventListener("viewbeforehide",function(){saveUser(this)})}});