It\'s not possible to observe or setup {brand} until the connection is repaired. Please try taking the following steps:
Wait for a while to see if the connection can be repaired automatically.{ConnectionInfo}
Check your network connection and repair it if it\'s not working.
Check your {brand}. It needs to be turned on with network cable plugged in properly. Turn on a socket manually to see if it\'s working.
Reset your {brand} by turning it off and on again (this will reset all devices connected to it). Wait at least half a minute to allow the {brand} to start up properly before trying to access it again.
If none of the steps above solve the problem, please consult the {brand} User Manual ({downloadItHere}) or {contactOurSupportDepartment}.
WarningChanges to network settings may result in {brand} becoming unavailable at the current address. See the {brand} User Manual for ways to find the {brand} at its new location.
'};netio.RELEASE_DIR="./r-9df5e99/";$.extend(netio,{url:{DEFAULT:"./cgi/kshell.cgi",UPDATE:"./tgi/upgrade.tgi",MANUAL:"http://www.koukaam.se/netio/manual",SUPPORT:"http://www.koukaam.se/netio/support",FIRMWARE:"http://www.koukaam.se/netio/firmware"},company:{name:"Koukaam",url:"http://www.koukaam.se"},codes:{SESSION_INIT_FAILED:5,BYE:110,REBOOT:120,CONNECTION_TIMEOUT:130,SUCCESS:250,INVALID_PARAMETER:501,UNKNOWN_COMMAND:502,INVALID_LOGIN:503,ALREADY_LOGGED_IN:504,FORBIDDEN:505,TOO_MANY_RECORDS:508,INVALID_SESSION_ID:509,TIME_MUST_DIFFER:550},
format:{TIME:"H:i:s",DATE:"Y-m-d",SHORT_TIME:"H:i",NETIO_DATETIME:"Y/m/d,H:i:s"},daylightSummerPrefil:{dstBeginDate:"2013-03-31",dstBeginTime:"02:00:00",dstEndDate:"2013-10-27",dstEndTime:"02:00:00"},isLocalStorageSupported:function(){try{return"localStorage"in window&&window.localStorage!==null}catch(a){return!1}}(),languages:[[2,"cs","\u010cesky"],[1,"de","Deutsch"],[0,"en","English"],[4,"es","Espa\u00f1ol"],[3,"it","Italiano"]],permission:{VIEW_OUTLET_STATUS:"O",CHANGE_OUTLET_STATUS:"C",VIEW_OUTLET_SETTINGS:"V",
CHANGE_OUTLET_SETTINGS:"M",VIEW_SETTINGS:"S",MANAGE_NONBREAKING_SETTINGS:"N",MANAGE_ADVANCED_SETTINGS:"A",MANAGE_USERS:"U",FIRMWARE_UPDATE_RESET:"F"},prompt:{TURN_OFF_ALL_OUTLETS:1,TURN_OFF_OUTLET:2,DELETE_USER:4},MAXIMUM_USER_COUNT:5,DELAY_AFTER_FW_UPLOAD:1E4,DELAY_BEFORE_FW_UPLOAD:1E4,CORE_RESTART_TIME:17E3,SESSION_TIMEOUT:6E5,IMAGE_DIR:"img/",CHANGE:0});$.extend(netio,{createCoreDatetime:function(a){return kufr.formatDate(netio.format.NETIO_DATETIME,a)},parseCoreDatetime:function(a){return kufr.parseDate(netio.format.NETIO_DATETIME,a)},createWebDatetime:function(a){return{date:kufr.formatDate(netio.format.DATE,a),time:kufr.formatDate(netio.format.TIME,a)}},parseWebDatetime:function(a,b){return kufr.parseDate(netio.format.DATE+" "+netio.format.TIME,a+" "+b)},coreToWebDatetime:function(a){return netio.createWebDatetime(netio.parseCoreDatetime(a))},
webToCoreDatetime:function(a,b){return netio.createCoreDatetime(netio.parseWebDatetime(a,b))},getQualifiedUrl:function(a){return kufr.getUrl(a,{model:netio.FULL_MODEL_NAME,lang:netio.languageManager.getLanguage()})},updateKufrTranslations:function(){$.extend(kufr.messages,{REQUEST_NOT_EXIST:netio.i18n("Request doesn't exist.",5),CONNECTION_LOST:netio.i18n("Connection closed.",6),REQUEST_TIMED_OUT:netio.i18n("Request timed out.",7),REQUEST_SENDING_FAILED:netio.i18n("Request sending failed.",8),LOADING:netio.i18n("Loading...",
16),SAVING:netio.i18n("Saving...",17),SAVED:netio.i18n("Saved.",18),UPLOAD_FAILED:netio.i18n("Upload failed.",19),UPLOADING:netio.i18n("Uploading...",20),UNEXPECTED_ERROR:netio.i18n("Unexpected error",55),VALUE_DECIMAL_BETWEEN:netio.i18n("Enter a value between {min} and {max} rounded to one decimal place.",262),VALUE_INVALID:netio.i18n("Value is invalid.",56),VALUE_EMAIL:netio.i18n("Enter an e-mail address.",58),VALUE_DATE:netio.i18n("Enter a date.",57),VALUE_TIME:netio.i18n("Enter a time.",66),VALUE_HOSTNAME:netio.i18n("Enter a hostname.",
60),VALUE_IP:netio.i18n("Enter an IP address.",61),VALUE_SUBNET:netio.i18n("Enter a subnet mask.",62),VALUE_NONEMPTY:netio.i18n("Enter a non-empty value.",63),VALUE_NATURAL:netio.i18n("Enter a positive integer.",290),VALUE_INTEGER:netio.i18n("Enter an integer.",64),VALUE_PORT:netio.i18n("Enter a port number (between 1 and 65535).",65),HIDE:netio.i18n("Hide",67),SHOW:netio.i18n("Show details",68)})}});$.extend(netio,{MODEL:"B",BRAND:"NETIO",FULL_MODEL_NAME:"230B"});netio.RemoteClock=kufr.util.Clock.extend({communicator:null,constructor:function(a){this.base({targets:a.targets});this.communicator=a.communicator},loadAndStart:function(){this.loadSystemTime(function(a){this.start(a)},this)},loadSystemTime:function(a,b){this.communicator.request("getTime").done(function(c){a.call(b,netio.parseCoreDatetime(c.datetime))})}});netio.Permissions=kufr.Object.extend({permissions:null,constructor:function(){this.permissions={}},has:function(a){return!!this.permissions[a]},set:function(a){if(typeof a=="string"){this.permissions={};for(var b=0,c=a.length;b([\s\S]*)<\/html>$/,"$1");return $.trim(a)}});netio.Switchboard=kufr.Object.extend({inUpdateMode:!1,mainComm:null,updateComm:null,request:function(){var a=this.inUpdateMode?this.updateComm:this.mainComm;return a.request.apply(a,arguments)},setMainComm:function(a){this.mainComm=a;a.setCreateParser(netio.Switchboard.createParser,netio.Switchboard)},setConnection:function(a){this.mainComm.setConnection(a)},switchToUpdateMode:function(){this.inUpdateMode=!0}},{createParser:function(a){return a.parseResult?new (netio.CodeParser.extend({parseResult:a.parseResult}))(a):
a.mapping?new netio.MappingParser(a):new netio.PlainParser($.extend({},a,{propName:a.plain||"raw"}))}});$(document).ready(function(){netio.requests={getCgiCompatibility:{request:"system cgicomp",mapping:["cgicomp"]},getDeviceName:{request:"alias",mapping:["deviceName"]},getDiscoverState:{request:"system discover",mapping:["discover"]},getDns:{request:"system dns",mapping:["dnsServer"]},getDst:{request:"system dst",mapping:["dstStatus","dstBegin","separator","dstEnd"]},getEmail:{request:"email message",mapping:["emailFrom","emailTo","emailSubject"]},getFwVersion:{request:"version",plain:"fwVersion"},
getKshellPort:{request:"system kshport",mapping:["kshellPort"]},getMac:{request:"system mac",plain:"mac"},getNetwork:{request:"system network",mapping:["webPort","kshellPort","ntpFromDhcp","networkMode","ipAddress","netMask","gateway","dnsServer"]},getNetworkLite:{request:"system eth",mapping:["networkMode","ipAddress","netMask","gateway"]},getNtp:{request:"system sntp",mapping:["ntpStatus","ntpServer"]},getOutletList:{request:"port elist",parser:new (netio.CodeParser.extend({parseResult:function(a){return $.trim(a).split(/[\r\n]+/).map(function(a,
c){var d=this.parseQuotedArguments(a)||[];return{outletId:c+1,name:d[0],enabled:d[1]=="1",interrupted:d[1]=="i",timerOn:d[4]=="timer",timerMode:d[7],timerStart:d[8],timerStop:d[9],timerDays:d[10],watchdogOn:d[2]=="Y",watchdogIp:d[3],pingInterval:d[5],pingTimeout:d[6]}},this)}}))},getOutletBase:{request:"port setup {outletId}",mapping:["name","mode","interruptDelay","powerOnState"]},getOutletMode:{request:"port mode {outletId}",mapping:["mode"]},getOutletTimer:{request:"port timer {outletId} dt",mapping:["timerStatus",
"onTime","offTime","weekSchedule"]},getOutletWatchdog:{request:"port wd {outletId}",mapping:["enable","address","pingTimeout","ponDelay","pingInterval","resetCount","enablePowerOff","sendEmail"]},getSerialTunnel:{request:"tunnel",mapping:["enable","port","speed","parity","parityIgnore","enableIpFilter","ipAddress","netMask"]},getSmtp:{request:"email server",mapping:["smtpServer"]},getSmtpAuth:{request:"email auth",mapping:["enableAuth","method","smtpUsername"]},getSwitchDelay:{request:"system swdelay",
mapping:["switchDelay"]},getTime:{request:"system time",plain:"datetime"},getTimezone:{request:"system timezone",mapping:["tzOffset"]},getUptime:{request:"uptime",parser:new (netio.MappingParser.extend({parseResult:function(a){var b=this.parseQuotedArguments(a),c={};this.mapping.forEach(function(a,e){c[a]=b[e*2]});return c}}))({mapping:["years","days","hours","minutes","seconds"]})},getCurrentUser:{request:"user get",parser:new (netio.MappingParser.extend({parseSuccess:function(a){var b=/^(-?\d+)\s+.*/.exec(a);
return!b||parseInt(b[1],10)<0?{code:netio.codes.FORBIDDEN,error:"FORBIDDEN"}:{data:this.parseResult(a)}}}))({mapping:["id","username","privileges","userVar"]})},getUserList:{request:"user list",parser:new (netio.MappingParser.extend({parseResult:function(a){return a.split("\n").map(this.base,this)}}))({mapping:["id","username","privileges","data"]})},getWebPort:{request:"system webport",mapping:["webPort"]},setCgiCompatibility:"system cgicomp {cgicomp}",setDeviceName:"alias {deviceName}",setDiscoverState:"system discover {discover}",
setDns:"system dns {dnsServer}",setDstBegin:"system dst begin {dstBegin}",setDstEnd:"system dst end {dstEnd}",setDst:"system dst {dstStatus}",setEmail:"email message {emailFrom} {emailTo} {emailSubject}",setKshellPort:"system kshport {kshellPort}",setNetwork:function(a){return"system network {webPort} {kshellPort} {ntpFromDhcp} {networkMode}"+(a.networkMode=="dhcp"?"":" {ipAddress} {netMask} {gateway} {dnsServer}")},setNetworkLite:function(a){return"system eth {networkMode}"+(a.networkMode=="dhcp"?
"":" {ipAddress} {netMask} {gateway}")},setNtp:function(a){return"system sntp {ntpStatus}"+(a.ntpStatus=="enable"?" {ntpServer}":"")},setOutletBase:"port setup {outletId} {name} {mode} {interruptDelay} {powerOnState}",setSmtp:"email server {smtpServer}",setSmtpAuth:function(a){return a.enableAuth=="enable"?"email auth enable {method} {smtpUsername} {smtpPassword}":"email auth disable"},setOutletMode:"port mode {outletId} {mode}",setOutletModes:"port list {modes}",setOutletTimer:"port timer {outletId} {timeFormat} {timerStatus} {onTime} {offTime} {weekSchedule}",
setOutletWatchdog:"port wd {outletId} {enable} {address} {pingTimeout} {ponDelay} {pingInterval} {resetCount} {enablePowerOff} {sendEmail}",setSerialTunnel:function(a){return a.enable?"tunnel enable {port} {speed} {parity} {parityIgnore} {enableIpFilter}"+(a.enableIpFilter=="enable"?" {ipAddress} {netMask}":""):"tunnel disable"},setSwitchDelay:"system swdelay {switchDelay}",setTime:"system time {datetime}",setTimezone:"system timezone {tzOffset}",setUser:"user update {id} {username} {privileges} {userVar}",
setUserPassword:"user passwd {id} {oldPass} {pass}",setWebPort:"system webport {webPort}",addUser:{request:"user add {username} {privileges} {userVar} {pass}",parseResult:function(a){var b=/(\d+)\s*$/.exec(a);return{raw:a,id:b?b[1]:null}}},deleteUser:"user delete {id}",disableOutletTimer:"port {outletId} manual",factoryReset:"system reset",login:{request:"login {username} {password}",successCodes:[netio.codes.SUCCESS,netio.codes.ALREADY_LOGGED_IN]},encryptedLogin:{request:"clogin {username} {hash}",
successCodes:[netio.codes.SUCCESS,netio.codes.ALREADY_LOGGED_IN]},logout:{request:"quit",successCodes:[netio.codes.BYE]},noop:"noop",resetOutlet:"port {outletId} int",toggleOutletWatchdog:"port wd {outletId} {enable}",toggleOutlet:"port {outletId} {mode}",sendTestEmail:"email test",switchToUpdateMode:"system update"}});netio.Dialog=kufr.controller.Controller.extend({detailsText:null,stopAskingCheckbox:null,stopAskingLabel:null,constructor:function(a){this.base(a);this.model.details===""&&this.detailsText.hide();this.hasStopAskingCheckbox()&&(a=kufr.id(),this.stopAskingCheckbox.attr("id",a),this.stopAskingLabel.attr("for",a))},hasStopAskingCheckbox:function(){return!!this.stopAskingCheckbox},resolveDialog:function(a){this.fireEvent(a?"confirm":"cancel",{stopAsking:a!==void 0&&this.hasStopAskingCheckbox()&&!!this.stopAskingCheckbox.attr("checked")})},
onCancelButtonClick:function(){this.resolveDialog(!1);return!1},onConfirmButtonClick:function(){this.resolveDialog(!0);return!1},onOverlayClick:function(a){if(a.currentTarget===a.target)return this.resolveDialog(),!1}});netio.FormController=kufr.controller.FormController.extend({handleLoadError:function(a){var b={message:netio.i18n("Loading failed.",10),isError:!0};switch(a.code){case netio.codes.UNKNOWN_COMMAND:case netio.codes.INVALID_PARAMETER:b.details=netio.i18n("Some of the requests sent to {brand} were invalid.",{brand:netio.BRAND},11);break;case netio.codes.FORBIDDEN:b.details=netio.i18n("You are not authorized to view some of the requested data.",12);break;default:return this.base(a)}this.form.setInfo(b);
return a.details.data||{}},handleSaveError:function(a){var b={message:netio.i18n("Saving failed.",13),isError:!0};switch(a.code){case netio.codes.UNKNOWN_COMMAND:b.details=netio.i18n("Some of the requests sent to {brand} were invalid.",{brand:netio.BRAND},11);break;case netio.codes.INVALID_PARAMETER:b.details=netio.i18n("The form contains at least one invalid value.",14);this.setFormLocked(!1);break;case netio.codes.FORBIDDEN:b.details=netio.i18n("You are not authorized to make some of the requested changes.",
15);break;default:return this.base(a)}this.setFormLocked(!1);this.form.setInfo(b);return!0}});netio.LoginViewport=netio.FormController.extend({storageId:null,template:netio.tpl.LoginViewport,constructor:function(a){var b={itemId:"",commConfig:{save:"encryptedLogin",saveTransform:function(b){b.hash=hex_md5(b.username+b.password+a.loginHash);return b}},indicateSuccess:!1,saveSubmitText:netio.i18n("Sign in",31)};this.base($.extend(b,a));this.usernameField=this.form.getField("username");this.on({load:function(){this.usernameField.focus();this.usernameField.select()},context:this})},handleSaveError:function(a){return a.code==
netio.codes.INVALID_LOGIN?(netio.storage.set(this.storageId,{storeCredentials:!1}),this.form.setInfo({message:netio.i18n("Invalid username or password.",32),isError:!0}),this.setFormLocked(!1),this.model.password="",this.usernameField.focus(),this.usernameField.select(),!0):this.base(a)},performLoad:function(a,b,c){b.call(c,netio.storage.get(this.storageId))},performSave:function(a,b,c){this.base(a,function(){a=$.extend({},a);a.storeCredentials||(delete a.username,delete a.password);netio.storage.set(this.storageId,
a);b.apply(c||window,arguments)},this)}});netio.GuiViewport=kufr.controller.CardContainer.extend({template:netio.tpl.GuiViewport,systemClock:null,navigation:null,language:null,constructor:function(a){var b={templateData:{company:netio.company.name,companyUrl:netio.company.url,manualUrl:netio.getQualifiedUrl(netio.url.MANUAL),firmwareUrl:netio.getQualifiedUrl(netio.url.FIRMWARE),supportUrl:netio.getQualifiedUrl(netio.url.SUPPORT)},itemId:"",items:[]};netio.user.permissions.has(netio.permission.VIEW_OUTLET_STATUS)&&b.items.push(new netio.Outlets({itemId:"outlets",
isDefaultItem:!0,outletCount:4,defaultPeriod:10,resetPeriod:2}));if(netio.user.permissions.has(netio.permission.VIEW_SETTINGS)){b.items.push(new netio.DateTime({itemId:"datetime"}),new netio.Email({itemId:"email"}),new netio.Network({itemId:"network"}));netio.MODEL=="CS"&&b.items.push(new netio.SerialTunnel({itemId:"tunnel"}));var c=new netio.System({itemId:"system"});c.on("save",this.loadSystemInfoData,this);b.items.push(c)}netio.user.permissions.has(netio.permission.MANAGE_USERS)&&b.items.push(new netio.Users({itemId:"users"}));
netio.user.permissions.has(netio.permission.FIRMWARE_UPDATE_RESET)&&b.items.push(new netio.Firmware({itemId:"firmware"}));this.base($.extend(b,a));this.initSystemInfo()},initLocale:function(){var a=this.language;netio.languageManager.index.each(function(b){var c=netio.languageManager.locale==b.id,d=$("").addClass("icon");$("").attr("href","#").addClass("option").addClass("lang-"+b.id).toggleClass("selected",c).click($.proxy(function(){c||this.fireEvent("requestLanguageChange",b.id);return!1},
this)).append($("").text(b.name)).prepend(d).appendTo(a)},this);a.toggleClass("no-choice",netio.languageManager.index.toArray().length<2);this.model.language=netio.languageManager.getLanguageName()},initSystemInfo:function(){netio.systemClock.addTarget({model:this.model,property:"systemDate",format:netio.format.DATE});netio.systemClock.addTarget({model:this.model,property:"systemTime",format:netio.format.TIME});this.loadSystemInfoData();this.initLocale()},loadSystemInfoData:function(){this.request("getDeviceName",
function(a){this.model.deviceName=a.deviceName},this);this.model.username=netio.user.username}});netio.DisconnectScreen=kufr.controller.Controller.extend({template:netio.tpl.DisconnectScreen,errorDetails:null,simpleErrorDesc:null,complexErrorDesc:null,showDetailsLink:null,pingerInfo:null,pinger:null,constructor:function(a){var b=netio.getQualifiedUrl(netio.url.MANUAL),c=netio.getQualifiedUrl(netio.url.SUPPORT),b={templateData:{downloadItHere:kufr.sprintf('%s',b,netio.i18n("download it here",21)),contactOurSupportDepartment:kufr.sprintf('%s',c,netio.i18n("contact our support department",
22))},model:{ConnectionInfo:netio.i18n("Reconnecting",121)}};this.base($.extend(b,a));this.initDetails();this.initPinger()},initDetails:function(){if($.isPlainObject(this.errorDetails))this.complexErrorDesc.hide(),this.simpleErrorDesc.hide(),$.each(this.errorDetails,$.proxy(function(a,b){var c=new kufr.controller.Controller({template:netio.tpl.DisconnectErrorItem,model:{name:a,value:b}});this.complexErrorDesc.append(c.getDom());c.activate()},this));else{this.complexErrorDesc.hide();if(this.errorDetails)this.model.simpleErrorDescription=
this.errorDetails;this.showDetailsLink.hide()}},initPinger:function(){var a=0,b=window.setInterval($.proxy(function(){this.pingerInfo.removeClass("reconnecting-"+a);a=a%3+1;this.pingerInfo.addClass("reconnecting-"+a)},this),1E3);this.pinger=new kufr.util.Pinger({communicator:this.getCommunicator(),period:10});this.pinger.on({success:function(){window.clearTimeout(b);this.pinger.stop();this.fireEvent("reconnected")},finish:function(){window.clearTimeout(b);this.pingerInfo.addClass("failed");this.model.ConnectionInfo=
netio.i18n("Automatic reconnection failed.",23)},context:this});this.pinger.start(3)},onShowDetailsClick:function(){this.handles.showDetailsLink.hide();this.complexErrorDesc.show();return!1}});netio.Outlets=kufr.controller.AutoContainer.extend({template:netio.tpl.Outlets,outletCount:0,defaultPeriod:0,resetPeriod:0,outletStore:null,listNavNode:null,resetButton:null,toggleButton:null,constructor:function(a){var b={items:[new netio.OutletList({itemId:"list",outletCount:a.outletCount}),new netio.OutletSettings({hideClass:"invisible",itemId:"settings"})]};this.base($.extend(b,a));this.outletList=this.getComponent("list");this.outletSettings=this.getComponent("settings");this.outletStore=new kufr.data.RefreshingStore({communicator:this.getCommunicator(),
loadRequest:"getOutletList"});this.outletStore.setEventParent(this);this.outletList.propagateEvents("control");this.outletList.on({activate:function(){this.outletStore.doWhenLoaded(function(a){this.outletList.setData(a);this.setData(a)},this)},requestSettingsClose:function(){this.outletSettings.isVisible&&this.listNavNode.activate()},context:this});this.outletSettings.on("save",function(){this.outletStore.load()},this);this.outletStore.on("load",function(a,b){this.outletList.setData(b);this.setData(b)},
this);this.on("control",function(){this.outletStore.load()},this);$(document).keyup($.proxy(function(a){a=a.keyCode||a.which;if(this.outletSettings.isVisible()&&a==27)return this.listNavNode.activate(),!1},this));netio.activityMonitor.on({here:this.updateOutletStorePeriod,idle:this.updateOutletStorePeriod,context:this});this.canChangeStatus=netio.user.permissions.has(netio.permission.CHANGE_OUTLET_STATUS)},disableAllTimers:function(a,b){var c=[];$.each(this.data.data,function(a,b){b.timerOn&&c.push(b.outletId)});
var d=new kufr.util.MultiTrigger(c.length,a,b);c.forEach(function(a){this.request("disableOutletTimer",{outletId:a},d.trigger,d)},this)},getOutletIdPattern:function(a){for(var b=[],c=1;c<=a;c++)b.push("^"+c+"$");return RegExp(b.join("|"))},onResetButtonClick:function(){netio.promptManager.prompt({group:netio.prompt.TURN_OFF_ALL_OUTLETS,title:netio.i18n("Do you really want to reset all outlets?",274),details:netio.i18n("This will turn off all timers.",275),confirm:netio.i18n("Reset",276),callback:function(){this.setOutletModes("i")},
context:this});return!1},onToggleButtonClick:function(){this.data.enabled?netio.promptManager.prompt({group:netio.prompt.TURN_OFF_ALL_OUTLETS,title:netio.i18n("Do you really want to turn off all outlets?",277),details:netio.i18n("This will turn off all timers.",278),confirm:netio.i18n("Turn Off",279),callback:function(){this.setOutletModes("0")},context:this}):this.setOutletModes("1");return!1},setData:function(a){var b=!1,c=!1,d=this.data&&this.data.interrupted;$.each(a,$.proxy(function(a,d){b=b||
d.enabled;c=c||d.interrupted},this));this.data={data:a,enabled:b,interrupted:c};this.toggleButton.toggleClass("on",this.data.enabled);this.model.toggleClickHint=this.data.enabled?netio.i18n("Turn off all outlets",42):netio.i18n("Turn on all outlets",43);this.resetButton.toggleClass("on",this.data.interrupted);this.resetButton.attr("disabled",!this.canChangeStatus||!b&&!this.data.interrupted);this.data.interrupted!=d&&(this.toggleButton.attr("disabled",!this.canChangeStatus||this.data.interrupted),
this.updateOutletStorePeriod())},setNavigationNode:function(a){if(this.navigationNode=a){this.navigationNode.on({activate:this.updateOutletStorePeriod,deactivate:this.updateOutletStorePeriod,context:this});var b=this.config,c=new kufr.nav.NavigationNode({nodeId:"list",isDefaultNode:!0,listeners:{update:function(){this.outletSettings.setVisible(!1);this.outletList.selectOutlet(null)},context:this}}),b=new kufr.nav.PatternNavigationNode({pattern:this.getOutletIdPattern(b.outletCount),nodeId:"settings",
listeners:{update:function(a){a=a.currentTarget;this.outletSettings.setOutletId(a.currentSection);this.outletSettings.setVisible(!0);this.outletList.selectOutlet(a.currentSection)},context:this}});this.listNavNode=c;a.addChild(c);a.addChild(b);this.outletList.setNavigationNode(c);this.outletSettings.setNavigationNode(b)}else this.outletList.setNavigationNode(null),this.outletSettings.setNavigationNode(null)},setCommunicator:function(a){this.base(a);this.outletStore.setCommunicator(a)},setOutletModes:function(a){this.disableAllTimers(function(){this.request("setOutletModes",
{modes:kufr.repeatString(a,this.outletCount)},function(){this.fireEvent("control")},this)},this)},updateOutletStorePeriod:function(){var a=0,b=!this.outletStore.isActive();netio.activityMonitor.isHere()&&this.navigationNode.isActive()&&(a=this.data&&this.data.interrupted?this.resetPeriod:this.defaultPeriod);this.outletStore.setPeriod(a);b&&a&&this.outletStore.load()}});netio.OutletList=kufr.controller.AutoContainer.extend({template:netio.tpl.OutletList,constructor:function(a){var b={items:this.createItems(a.outletCount)};this.base($.extend(b,a))},createItems:function(a){for(var b=[],c=1;c<=a;c++)b.push(new netio.OutletListItem({itemId:c}));return b},selectOutlet:function(a){this.items.each(function(b){b.setSelected(b.itemId==a)})},setData:function(a){this.items.each(function(b,c){b.setData(a[c])})}});netio.OutletSettings=kufr.controller.CardContainer.extend({template:netio.tpl.OutletSettings,navigation:null,constructor:function(a){var b={items:[new netio.OutletTimer({itemId:"timer",isDefaultItem:!0}),new netio.OutletWatchdog({itemId:"watchdog"}),new netio.OutletGeneral({itemId:"general"})]};this.base($.extend(b,a));this.items.each(function(a){a.propagateEvents("save")},this)},setOutletId:function(a){this.items.each(function(b){b.setOutletId(a)});this.model.outletId=a;this.activeChild&&(this.activeChild.deactivate(),
this.activeChild.activate())}});netio.OutletListItem=kufr.controller.Controller.extend({template:netio.tpl.OutletListItem,toggleButton:null,resetButton:null,settingsClickHint:null,timerInfo:null,timerToggleButton:null,watchdogInfo:null,wdToggleButton:null,outletId:null,constructor:function(a){this.base(a);this.resetButton.attr("title",netio.i18n("Reset",34));this.propagateEvents(["control","requestSettingsClose"]);this.model.outletId=this.outletId;(this.canChangeStatus=netio.user.permissions.has(netio.permission.CHANGE_OUTLET_STATUS))||
this.settingsClickHint.hide()},announceControl:function(){this.fireEvent("control")},canViewSettings:function(){return netio.user.permissions.has(netio.permission.VIEW_OUTLET_SETTINGS)},createDatetimeInterval:function(a,b){var c=netio.createWebDatetime(a),d=netio.createWebDatetime(b);return c.date===d.date?this.emphasize(c.date)+" "+this.createTimeInterval(a,b):netio.i18n("From",183)+": "+this.emphasize(c.date+" "+this.createShortTime(a))+" "+netio.i18n("To",184)+": "+this.emphasize(d.date+
" "+this.createShortTime(b))},createShortTime:function(a){return kufr.formatDate(netio.format.SHORT_TIME,a)},createTimeInterval:function(a,b){var c=this.createShortTime(a),d=this.createShortTime(b);c!==d?(a=c,b=d):(a=netio.createWebDatetime(a).time,b=netio.createWebDatetime(b).time);return this.emphasize(a)+" - "+this.emphasize(b)},emphasize:function(a){return""+a+""},isTimerInfoValid:function(){var a=this.model;switch(a.timerMode){case "d":return!0;case "w":return a.timerDays!=="0000000";
case "o":return netio.parseCoreDatetime(a.timerStop).getTime()>kufr.now();default:return!1}},isWatchdogInfoValid:function(){return this.model.watchdogIp!=="0.0.0.0"},getWeekDaysAbbr:function(){return[netio.i18n("Mon",176),netio.i18n("Tue",177),netio.i18n("Wed",178),netio.i18n("Thu",179),netio.i18n("Fri",180),netio.i18n("Sat",181),netio.i18n("Sun",182)]},onOutletListItemClick:function(){this.getDom().hasClass("selected")?this.fireEvent("requestSettingsClose"):this.openSettings();return!1},onResetButtonClick:function(){netio.promptManager.prompt({group:netio.prompt.TURN_OFF_OUTLET,
title:netio.i18n("Do you really want to reset {outletName}?",{outletName:this.model.name},268),details:this.model.timerOn?netio.i18n("This will turn off the timer.",269):void 0,confirm:netio.i18n("Reset",270),callback:function(){this.request("resetOutlet",this.model,this.announceControl,this)},context:this});return!1},onTimerToggleButtonClick:function(){this.isTimerInfoValid()?this.request("setOutletMode",{outletId:this.model.outletId,mode:this.model.timerOn?"manual":"timer"},this.announceControl,
this):this.openSettings("timer");return!1},onToggleButtonClick:function(){var a={outletId:this.model.outletId,mode:this.model.enabled?"0":"1"},b=$.proxy(function(){this.request("toggleOutlet",a,this.announceControl,this)},this),c=$.proxy(function(){this.model.timerOn?this.request("disableOutletTimer",a,b):b()},this);this.model.enabled?netio.promptManager.prompt({group:netio.prompt.TURN_OFF_OUTLET,title:netio.i18n("Do you really want to turn off {outletName}?",{outletName:this.model.name},271),details:this.model.timerOn?
netio.i18n("This will turn off the timer.",272):void 0,confirm:netio.i18n("Turn Off",273),callback:c}):c();return!1},onWdToggleButtonClick:function(){this.isWatchdogInfoValid()?this.request("toggleOutletWatchdog",{outletId:this.model.outletId,enable:this.model.watchdogOn?"disable":"enable"},this.announceControl,this):this.openSettings("watchdog");return!1},openSettings:function(a){if(this.canViewSettings()){var b=this.navigationNode.navigationManager.getPath(),c=this.navigationNode.getLevel();b[c]=
this.model.outletId;a&&(b[c+1]=a);this.navigationNode.setPath(b,{isAbsolute:!0})}},setData:function(a){$.extend(this.model,a);this.model.outletId=a.outletId;this.model.name=a.name;this.toggleButton.attr("disabled",!this.canChangeStatus||a.interrupted);this.toggleButton.toggleClass("on",a.enabled);this.model.powerClickHint=a.enabled?netio.i18n("Turn off",35):netio.i18n("Turn on",36);this.resetButton.toggleClass("on",a.interrupted);this.resetButton.attr("disabled",!this.canChangeStatus||!a.enabled&&
!a.interrupted);this.updateTimerInfo();this.updateWatchdogInfo()},updateTimerInfo:function(){var a=this.model;this.timerToggleButton.toggleClass("on",a.timerOn);this.timerInfo.detachChildren();if(this.isTimerInfoValid()){var b="",c=netio.parseCoreDatetime(a.timerStart),d=netio.parseCoreDatetime(a.timerStop);if(a.timerMode==="o")b+=this.createDatetimeInterval(c,d);else{if(a.timerMode==="d"||a.timerMode==="w"&&a.timerDays==="1111111")b+=this.emphasize(netio.i18n("Daily",251));else{var e=[];this.getWeekDaysAbbr().forEach(function(b,
c){a.timerDays[c]==="1"&&e.push(this.emphasize(b))},this);b+=e.join(", ")}b+=" "+this.createTimeInterval(c,d)}this.model.timerInfo="";this.timerInfo.append($(""+b+""));this.model.timerClickHint=a.timerOn?netio.i18n("Click to disable timer.",252):netio.i18n("Click to enable timer.",253)}else this.model.timerInfo=netio.i18n("Timer configuration is invalid.",254),this.model.timerClickHint=netio.i18n("Click to open settings.",165)},updateWatchdogInfo:function(){var a=this.model;this.wdToggleButton.toggleClass("on",
a.watchdogOn);this.watchdogInfo.detachChildren();if(this.isWatchdogInfoValid()){this.model.watchdogInfo="";var b=this.emphasize(a.watchdogIp)+" "+netio.i18n("Every {interval}s (timeout {timeout}s)",{interval:this.emphasize(a.pingInterval),timeout:this.emphasize(a.pingTimeout)},256);this.watchdogInfo.append($(""+b+""));this.model.watchdogClickHint=a.watchdogOn?netio.i18n("Click to disable watchdog.",257):netio.i18n("Click to enable watchdog.",258)}else this.model.watchdogInfo=netio.i18n("Watchdog configuration is invalid.",
259),this.model.watchdogClickHint=netio.i18n("Click to open settings.",165)},setSelected:function(a){this.getDom().toggleClass("selected",a)}});netio.OutletFormController=netio.FormController.extend({setOutletId:function(a){this.outletId=a},save:function(a){this.base($.extend({},a,{outletId:this.outletId}))},load:function(a){this.base($.extend({},a,{outletId:this.outletId}))}});netio.OutletGeneral=netio.OutletFormController.extend({template:netio.tpl.OutletGeneral,constructor:function(a){this.base($.extend({commConfig:{load:"getOutletBase",loadTransform:function(a){return $.extend(a,{powerOnState:a.powerOnState=="1"})},save:"setOutletBase",saveTransform:function(a){return $.extend(a,{mode:"unchange",powerOnState:a.powerOnState?"1":"0"})}}},a))}});netio.OutletTimer=netio.OutletFormController.extend({template:netio.tpl.OutletTimer,constructor:function(a){var b=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];this.base($.extend({commConfig:{load:["getOutletTimer","getOutletMode"],loadTransform:function(a){var d=netio.coreToWebDatetime(a.onTime),e=netio.coreToWebDatetime(a.offTime),g=a.timerStatus=="daily",f={timerStatus:g?"weekly":a.timerStatus,onceFromDate:"",onceFromTime:"",onceToDate:"",onceToTime:"",weeklyFromTime:"",weeklyToTime:""},h="0000000";
a.timerStatus=="once"?$.extend(f,{onceFromDate:d.date,onceFromTime:d.time,onceToDate:e.date,onceToTime:e.time}):(h=g?"1111111":a.weekSchedule,$.extend(f,{weeklyFromTime:d.time,weeklyToTime:e.time}));b.forEach(function(a,b){f["weeklyDays"+a]=h.charAt(b)=="1"});return f},save:["setOutletTimer","setOutletMode"],saveTransform:function(a){var d=$.extend({mode:"timer"},a),e=netio.webToCoreDatetime;$.extend(d,a.timerStatus=="once"?{timeFormat:"dt",onTime:e(a.onceFromDate,a.onceFromTime),offTime:e(a.onceToDate,
a.onceToTime)}:{timeFormat:"t",onTime:a.weeklyFromTime,offTime:a.weeklyToTime});d.weekSchedule=b.map(function(b){return a["weeklyDays"+b]?"1":"0"}).join("");return d}}},a))},handleSaveError:function(a){return a.code==netio.codes.TIME_MUST_DIFFER?(this.form.setInfo({message:netio.i18n("The difference of times must be at least 60 seconds.",44),isError:!0}),this.setFormLocked(!1),!0):this.base(a)}});netio.OutletWatchdog=netio.OutletFormController.extend({template:netio.tpl.OutletWatchdog,constructor:function(a){var b={commConfig:{load:"getOutletWatchdog",loadTransform:function(a){var b=a.resetCount!=0;return $.extend(a,{enableResetLimit:b,resetCount:b?a.resetCount:"",enablePowerOff:a.enablePowerOff=="enable",sendEmail:a.sendEmail=="enable"})},save:"setOutletWatchdog",saveTransform:function(a){return $.extend(a,{resetCount:a.enableResetLimit?a.resetCount:0,enablePowerOff:a.enablePowerOff?"enable":
"disable",sendEmail:a.sendEmail?"enable":"disable"})}},model:{resets:netio.i18n("resets","Turn the watchdog off after X resets",232)}};this.base($.extend(b,a))}});netio.Firmware=kufr.controller.UploadFormController.extend({actionUrl:netio.url.UPDATE,template:netio.tpl.Firmware,constructor:function(a){var b={commConfig:{load:"getFwVersion"},form:{vTypes:{UpgradeFile:{check:/^.+\.bin$/,hint:netio.i18n("Select a file with {brand} firmware (firmware.bin).",{brand:netio.BRAND},59)}}},saveSubmitText:netio.i18n("Upgrading...",25)};this.base($.extend(!0,b,a));this.form.on("beforeSubmit",function(){if(this.getCommunicator().inUpdateMode)return!0;netio.app.suspend();
this.setFormLocked(!0,netio.i18n("Restarting...",27));this.request("switchToUpdateMode",function(){this.getCommunicator().switchToUpdateMode();setTimeout($.proxy(function(){this.setFormLocked(!1);this.form.submitForm()},this),netio.DELAY_BEFORE_FW_UPLOAD)},this);return!1},this);this.on("save",function(a,b){this.setFormLocked(!0,netio.i18n("Restarting...",27),/is Starting/.test(b.response)?{message:netio.i18n("Upgraded.",28)}:{isError:!0,message:netio.i18n("Firmware upgrade failed.",29),details:netio.i18n("The uploaded file was rejected and the current firmware remains unchanged.",
30)});setTimeout(kufr.nav.LocationManager.reload,netio.DELAY_AFTER_FW_UPLOAD)},this)},handleLoadError:function(a){var b={message:netio.i18n("Loading failed.",10),isError:!0};switch(a.code){case netio.codes.UNKNOWN_COMMAND:case netio.codes.INVALID_PARAMETER:b.details=netio.i18n("Some of the requests sent to {brand} were invalid.",11);break;case netio.codes.FORBIDDEN:b.details=netio.i18n("You are not authorized to view some of the requested data.",12);break;default:return this.base(a)}this.form.setInfo(b);
return a.details.data||{}}});netio.System=netio.FormController.extend({template:netio.tpl.System,serverStartDate:null,uptimeRefresh:100,constructor:function(a){this.base($.extend({commConfig:{load:["getDeviceName","getUptime","getFwVersion","getSwitchDelay","getMac","getCgiCompatibility"],loadTransform:function(a){var c=0,d=parseInt(a.switchDelay,10),e;for(e in kufr.TIME_UNITS)c+=a[e]*kufr.TIME_UNITS[e];return $.extend(a,{cgicomp:a.cgicomp=="enable",switchDelay:d/10,serverStartDate:kufr.now()-c})},save:["setDeviceName","setSwitchDelay",
"setCgiCompatibility"],saveTransform:function(a){return $.extend(a,{cgicomp:a.cgicomp?"enable":"disable",switchDelay:a.switchDelay*10})}}},a));this.on("load",function(a,c){this.serverStartDate=c.serverStartDate;this.updateInterval&&window.clearTimeout(this.updateInterval);this.displayUptime();this.updateInterval=setInterval($.proxy(this.displayUptime,this),this.uptimeRefresh)},this)},displayUptime:function(){var a=kufr.timeDifference(this.serverStartDate);this.model.uptime=a.years?netio.i18n("{years} years {days} days {hours} hours",
a,229):a.days?netio.i18n("{days} days {hours} hours {minutes} minutes",a,230):netio.i18n("{hours} hours {minutes} minutes {seconds} sec",a,231)},onFactoryResetButtonClick:function(a){$(a.currentTarget).attr("disabled",!0);this.request("factoryReset",function(){netio.app.showGui()},this)},setNavigationNode:function(a){this.base(a);if(this.navigationNode)this.navigationNode.on({deactivate:function(){if(this.updateInterval)clearInterval(this.updateInterval),this.updateInterval=null},context:this})}});netio.SerialTunnel=netio.OutletFormController.extend({template:netio.tpl.SerialTunnel,constructor:function(a){var b={templateData:{parityChar1:this.generateOption(35),parityChar2:this.generateOption(42),parityChar3:this.generateOption(63),parityChar4:this.generateOption(248)},commConfig:{load:"getSerialTunnel",loadTransform:function(a){return $.extend(a,{enable:a.enable=="enable",enableIpFilter:a.enableIpFilter=="enable",enableParityIgnore:a.parityIgnore!="0"})},save:"setSerialTunnel",saveTransform:function(a){return $.extend(a,
{enableIpFilter:a.enableIpFilter?"enable":"disable",parityIgnore:a.enableParityIgnore?a.parityIgnore:"0"})}}};this.base($.extend(b,a))},generateOption:function(a){return kufr.sprintf("%s (%s)",a,String.fromCharCode(a))}});netio.Network=netio.FormController.extend({template:netio.tpl.Network,loadedData:null,constructor:function(a){this.base($.extend(!0,{commConfig:{load:["getNetwork","getDiscoverState"],loadTransform:function(a){return $.extend(a,{discover:a.discover=="enable",ntpFromDhcp:a.ntpFromDhcp=="enable"})},save:["setDiscoverState","setNetwork"],saveTransform:function(a){return $.extend(a,{discover:a.discover?"enable":"disable",ntpFromDhcp:a.ntpFromDhcp?"enable":"disable"})}}},a));this.on("load",$.proxy(function(a,
c){this.loadedData=c},this))},handleSaveError:function(a,b){return a.code==netio.codes.REBOOT?b.networkMode=="manual"&&this.loadedData.ipAddress!=b.ipAddress?(netio.app.suspend(),this.form.setInfo(netio.i18n("{brand} should be available at {ipAddress} shortly.",{brand:netio.BRAND,ipAddress:''+b.ipAddress+""},288)),!0):b.networkMode=="dhcp"&&this.loadedData.networkMode!=b.networkMode?(netio.app.suspend(),this.form.setInfo(netio.i18n("{brand} switched to DHCP mode.",
{brand:netio.BRAND},289)),!0):this.base(a):this.base(a)}});netio.Email=netio.FormController.extend({template:netio.tpl.Email,testButton:null,constructor:function(a){this.base($.extend(!0,{commConfig:{load:["getSmtp","getEmail","getSmtpAuth"],loadTransform:function(a){return $.extend(a,{enableAuth:a.enableAuth=="enable",smtpPassword:""})},save:["setSmtp","setEmail","setSmtpAuth"],saveTransform:function(a){return $.extend(a,{enableAuth:a.enableAuth?"enable":"disable"})}}},a))},onTestButtonClick:function(){var a=this.testButton;a.attr("disabled",!0);this.request("sendTestEmail",
function(){var b=$("").addClass("success").insertAfter(this.testButton).text(netio.i18n("Test e-mail has been sent. Please check your mailbox.",24));window.setTimeout(function(){a.attr("disabled",!1);b.remove()},5E3)},this);return!1}});netio.DateTime=netio.FormController.extend({template:netio.tpl.DateTime,constructor:function(a){this.base($.extend(!0,{commConfig:{load:["getNtp","getTimezone","getTime","getDst"],loadTransform:function(a){$.extend(a,netio.daylightSummerPrefil);if(a.dstBegin){var c=netio.coreToWebDatetime(a.dstBegin);$.extend(a,{dstBeginDate:c.date,dstBeginTime:c.time})}a.dstEnd&&(c=netio.coreToWebDatetime(a.dstEnd),$.extend(a,{dstEndDate:c.date,dstEndTime:c.time}));a.enableDst=a.dstStatus=="enabled";return $.extend(a,
netio.coreToWebDatetime(a.datetime))},save:function(a){var c=["setNtp","setDst"];a.enableNtp?c.push("setTimezone"):c.push("setTime");a.enableDst&&c.push("setDstBegin","setDstEnd");return c},saveTransform:function(a){var c=netio.webToCoreDatetime;return $.extend({},a,{dstStatus:a.enableDst?"enable":"disable",datetime:c(a.date,a.time),dstBegin:c(a.dstBeginDate,a.dstBeginTime),dstEnd:c(a.dstEndDate,a.dstEndTime),enableNtp:a.ntpStatus=="enable"})}}},a));this.on({save:function(){clearTimeout(this.lastReloadTimer);
this.lastReloadTimer=setTimeout(function(){netio.systemClock.loadAndStart()},netio.CORE_RESTART_TIME)},context:this});this.initForm()},initForm:function(){this.localClock=new kufr.util.Clock([{model:this.model,property:"date",format:netio.format.DATE},{model:this.model,property:"time",format:netio.format.TIME}]);this.synchroField=this.form.getField("synchronize");this.synchroField.on("change",this.handleSynchroFieldChange,this)},handleSynchroFieldChange:function(){if(this.synchroField.isDisabled)this.localClock.stop();
else{var a=!!this.model.synchronize;this.form.setFieldsReadOnly(a,["date","time"]);this.localClock[a?"start":"stop"]()}}});netio.Users=kufr.controller.AutoContainer.extend({template:netio.tpl.Users,createNavNode:null,userStore:null,containerEl:null,constructor:function(a){this.userStore=new kufr.data.CollectionStore({loadRequest:"getUserList"});this.userStore.setEventParent(this);var b={items:[new netio.UserList({itemId:"list"}),new netio.UserSettings({itemId:"settings",userStore:this.userStore})]};this.base($.extend(b,a));this.userList=this.getComponent("list");this.userSettings=this.getComponent("settings");this.userStore.on("load",
function(a,b){this.userList.setData(b);var e=this.userStore.getItem(this.selectedUser);this.selectUser(e&&e.username,!0)},this);this.userList.on({createPressed:function(){this.createNavNode.activate()},userDelete:this.loadUsers,context:this});this.userSettings.on({save:function(a,b,e){this.selectedUser=b.id||e.id;this.loadUsers()},context:this})},getUserId:function(a){return(a=this.userStore.find("username",a))&&a.id||-1},loadUsers:function(a,b){$.isFunction(a)?this.userStore.load(a,b):this.userStore.load()},
selectUser:function(a,b){var c=this.getUserId(a),d={repair:!0};if(c<0&&a!==!1)var e=this.userStore.getItemAt(0),a=e&&e.username,c=e&&e.id;if(c!==this.selectedUser||b)this.selectedUser=c,c<0?(this.userList.selectUser(null),this.userSettings.setUserId(null),this.navigationNode.getChild("create").activate(d)):this.userStore.doWhenLoaded(function(){this.userList.selectUser(c);this.userSettings.setUserId(c);this.navigationNode.getChild("edit").setPath([a],d)},this)},setCommunicator:function(a){this.base(a);
this.userStore.setCommunicator(a)},setNavigationNode:function(a){this.base(a);if(a)this.createNavNode=new kufr.nav.NavigationNode({nodeId:"create",listeners:{update:function(){this.selectUser(!1)},context:this}}),a.addChild(this.createNavNode),a.addChild(new kufr.nav.NavigationNode({nodeId:"edit",isDefaultNode:!0,children:[new kufr.nav.PatternNavigationNode({pattern:/.+/})],listeners:{update:function(a,c){this.userStore.doWhenLoaded(function(){this.selectUser(c[0])},this)},context:this}})),a.on({activate:this.loadUsers,
context:this})}});netio.UserList=kufr.controller.AutoContainer.extend({template:netio.tpl.UserList,createButton:null,deleteUser:function(a){this.request({request:"deleteUser",data:{id:a},callback:function(){this.fireEvent("userDelete",a)},handler:function(a){if(a.code==netio.codes.INVALID_PARAMETER)return!0;return!1},context:this})},getSelectedComponent:function(){return this.findComponent(function(a){return a.isSelected()})},onCreateUserClick:function(a){$(a.currentTarget).blur();this.fireEvent("createPressed");return!1},
selectUser:function(a){this.items.each(function(b){b.setSelected(b.itemId==a)});this.setCreateDisabled(a===null||this.items.getCount()>=netio.MAXIMUM_USER_COUNT)},setCreateDisabled:function(a){this.createButton.attr("disabled",a)},setData:function(a){var b=[];a.forEach(function(a){var d=new netio.UserListItem({allowDelete:parseInt(a.id,10)!==0,itemId:a.id,username:a.username});d.on("deletePressed",function(){netio.promptManager.prompt({group:netio.prompt.DELETE_USER,title:netio.i18n("Do you really want to delete user {username}?",
{username:a.username},280),confirm:netio.i18n("Delete",281),callback:function(){this.deleteUser(a.id)},context:this})},this);b.push(d)},this);this.setItems(b);this.setCreateDisabled(b.length>=netio.MAXIMUM_USER_COUNT)}});netio.UserListItem=kufr.controller.Controller.extend({template:netio.tpl.UserListItem,constructor:function(a){this.base(a);this.setUsername(a.username);a.allowDelete||this.handles.deleteButton.hide()},isSelected:function(){return this.getDom().hasClass("selected")},onDeleteButtonClick:function(a){this.fireEvent("deletePressed");$(a.target).blur();return!1},setUsername:function(a){this.model.username=a},setSelected:function(a){this.getDom().toggleClass("selected",a)}});netio.UserSettings=netio.FormController.extend({template:netio.tpl.UserSettings,advancedPrivileges:null,createMode:!1,privilegesRadio:null,privilegeCheckboxNames:null,simplePrivileges:null,simpleToggler:null,userId:null,usernameField:null,userStore:null,constructor:function(a){var b={loadOnRender:!1,templateData:{showMore:kufr.sprintf('%s',netio.i18n("more","show more details",45)),showLess:kufr.sprintf('%s',
netio.i18n("less","show less details",46))},commConfig:{save:function(a){return a.id?a.pass?["setUser","setUserPassword"]:["setUser"]:"addUser"},saveTransform:$.proxy(function(a){a=$.extend({},a);a.privileges=a.privileges||this.createPrivilegeString(a);if(this.userId!==null)a.id=this.userId;return a},this)},form:{vTypes:{username:{check:$.proxy(function(a){var b=this.userStore,c=b.getItem(this.userId),c=a==(c&&c.username);return a!=""&&(c||!b.find("username",a))},this),getHint:function(a){return a==
""?netio.i18n("Username must not be empty.",47):netio.i18n("User with that username already exists.",48)}},pass:{check:$.proxy(function(a){return!this.createMode&&this.model.oldPass==""||a!=""},this),hint:netio.i18n("New password must not be empty.",49)},passConfirm:{check:$.proxy(function(a){return a===this.model.pass},this),hint:netio.i18n("Passwords do not match.",50)}}}};this.base($.extend(b,a));this.usernameField=this.form.getField("username");this.on("load",function(a,b){this.createMode=!b.id;
this.handles.oldPass.toggle(!this.createMode);this.form.setSubmitText(this.createMode?netio.i18n("Create User",203):netio.i18n("Save Changes",228));this.setPrivilegesMode(!1)},this);this.privilegesRadio=this.form.getField("privileges");this.privilegeCheckboxNames=[];$.each(netio.permission,$.proxy(function(a,b){this.privilegeCheckboxNames.push("privilege-"+b)},this));var c=kufr.createExclusiveProxy();$.each(netio.permission,$.proxy(function(a,b){this.form.getField("privilege-"+b).on("change",c(function(){var a=
this.findSimpleModeValue(this.createCurrentPrivilegeString());this.simpleToggler.toggleClass("forbidden",a===null);this.model.privilegesDummy=a||""},this))},this));this.form.getField("privilegesDummy").on("change",c(function(){var a=this.model.privilegesDummy;a&&($.extend(this.model,this.parsePrivilegeString(a)),this.simpleToggler.toggleClass("forbidden",!a))},this))},createCurrentPrivilegeString:function(){return this.createPrivilegeString(kufr.copyProperties(this.model,this.privilegeCheckboxNames))},
createPrivilegeString:function(a){var b="";$.each(netio.permission,function(c,d){b+=a["privilege-"+d]?d:""});return b},findSimpleModeValue:function(a){var b=null,c=a.split("");this.privilegesRadio.getAllowedValues().forEach(function(a){if(c.length==a.length){var e=a;c.forEach(function(a){e=e.replace(a,"")},this);if(e=="")return b=a,!1}},this);return b},handleSaveError:function(a){return a.code==netio.codes.TOO_MANY_RECORDS?(this.form.setInfo({isError:!0,message:netio.i18n("Cannot create more users.",
53),details:kufr.fillString(netio.i18n("Maximum of {n} user accounts reached.",54),{n:netio.MAXIMUM_USER_COUNT})}),!0):this.base(a)},load:function(a){this.base($.extend({},a,{id:this.userId}))},onAdvancedPrivClick:function(){this.setPrivilegesMode(!0,!0);return!1},onSimplePrivClick:function(){this.setPrivilegesMode(!1,!0);return!1},parsePrivilegeString:function(a){var b={},c={};a.split("").forEach(function(a){b[a]=!0});$.each(netio.permission,function(a,e){c["privilege-"+e]=!!b[e]});return c},performLoad:function(a,
b,c){var a=this.userStore.getItem(a.id)||{id:"",privileges:this.privilegesRadio.getAllowedValues()[1],username:"",userVar:0},d=this.parsePrivilegeString(a.privileges);b.call(c,$.extend(a,{oldPass:"",pass:"",passConfirm:""},d))},setUserId:function(a){this.userId=a;this.load()},setPrivilegesMode:function(a,b){var c=this.findSimpleModeValue(this.createCurrentPrivilegeString());!a&&c===null&&(a=!0,b=!1);b&&(c=a?this.parsePrivilegeString(this.model.privileges):{privileges:c},$.extend(this.model,c));if(a)this.model.privilegesDummy=
this.findSimpleModeValue(this.createCurrentPrivilegeString())||"";this.form.setFieldsDisabled(a,"privileges");this.form.setFieldsDisabled(!a,"privilegesDummy");this.form.setFieldsDisabled(!a,this.privilegeCheckboxNames);this.advancedPrivileges.toggleClass("hidden",!a);this.simplePrivileges.toggleClass("hidden",a)}});netio.PromptManager=kufr.Object.extend({suppressIndex:0,getSuppressIndex:function(){return this.suppressIndex},isSuppressed:function(a){return!!(a&this.suppressIndex)},prompt:function(a){a=$.extend({group:0,context:window},a);this.isSuppressed(a.group)?a.callback.call(a.context):this.showDialog($.extend({},a,{stopAsking:$.proxy(function(){this.suppress(a.group)},this)}))},notify:function(a){this.prompt($.extend({template:netio.tpl.NoticeDialog,confirm:netio.i18n("OK")},a))},reset:function(){this.suppressIndex=
0;this.fireEvent("change")},setSuppressIndex:function(a){this.suppressIndex=a},showDialog:function(a){var a=$.extend({template:netio.tpl.ConfirmationDialog,details:"",confirm:netio.i18n("Confirm",282),cancel:netio.i18n("Cancel",283),stopAsking:$.noop,context:window},a),b=$("