jellyfin-web/dashboard-ui/scripts/camerauploadsettings.js

1 line
1.3 KiB
JavaScript
Raw Normal View History

2017-01-27 20:16:59 -07:00
define(["appSettings","emby-checkbox"],function(appSettings){"use strict";function loadForm(page,user){var uploadServers=appSettings.cameraUploadServers();page.querySelector(".uploadServerList").innerHTML=ConnectionManager.getSavedServers().map(function(s){var checkedHtml=uploadServers.indexOf(s.Id)==-1?"":" checked",html='<label><input type="checkbox" is="emby-checkbox"'+checkedHtml+' class="chkUploadServer" data-id="'+s.Id+'"/><span>'+s.Name+"</span></label>";return html}).join(""),Dashboard.hideLoadingMsg()}function saveUser(page){for(var chkUploadServer=page.querySelectorAll(".chkUploadServer"),cameraUploadServers=[],i=0,length=chkUploadServer.length;i<length;i++)chkUploadServer[i].checked&&cameraUploadServers.push(chkUploadServer[i].getAttribute("data-id"));appSettings.cameraUploadServers(cameraUploadServers),window.MainActivity&&MainActivity.authorizeStorage(),Dashboard.hideLoadingMsg()}return function(view,params){view.querySelector("form").addEventListener("submit",function(e){return Dashboard.showLoadingMsg(),saveUser(view),e.preventDefault(),!1}),view.addEventListener("viewshow",function(){var page=this;Dashboard.showLoadingMsg();var userId=params.userId||Dashboard.getCurrentUserId();ApiClient.getUser(userId).then(function(user){loadForm(page,user)})}),view.addEventListener("viewbeforehide",function(){saveUser(this)})}});