define(["loading","connectionManager","appRouter","appSettings","emby-scroller","emby-input","material-icons","emby-button"],function(loading,connectionManager,appRouter,appSettings){"use strict";return function(view,params){view.querySelector("form").addEventListener("submit",function(e){var address=this.querySelector(".txtServerHost").value,port=this.querySelector(".txtServerPort").value;return port&&(address=function(string,charToRemove){for(;string.charAt(string.length-1)===charToRemove;)string=string.substring(0,string.length-1);return string}(address,"/"),address+=":"+port),loading.show(),connectionManager.connectToAddress(address,{enableAutoLogin:appSettings.enableAutoLogin()}).then(function(result){loading.hide(),appRouter.handleConnectionResult(result,view)}),e.preventDefault(),!1}),view.querySelector(".buttonCancel").addEventListener("click",function(e){appRouter.back()}),view.addEventListener("viewshow",function(e){view.querySelector(".txtServerHost").value="",view.querySelector(".txtServerPort").value="8096"})}});