define("firewall_url_filter","underscore jquery knockout set service".split(" "),function(g,c,i,b,e){function a(){var n=this;var k=e.getUrlFilterList();var l=[{columnType:"checkbox",rowText:"index",width:"30%"},{headerTextTrans:"url",rowText:"url",width:"70%"}];n.rules=i.observableArray(k.urlFilterRules);n.gridTemplate=new i.simpleGrid.viewModel({data:n.rules(),idName:"index",columns:l,tmplType:"list",pageSize:10});n.clear=f;n.callback=j;n.deleteRule=o;n.addRule=m;function j(p){if(p.result!="success"){errorOverlay()}else{n.clear();d(n);successOverlay();c("#urlFilters").translate()}}function m(){if(n.rules().length>=b.urlFilterMax){showAlert({msg:"url_filter_max",params:b.urlFilterMax});return false}var q=[];for(var p=0;p=b.portForwardMax){showAlert({msg:"rules_max",params:b.portForwardMax});return}if(q.checkExist()){showAlert("rule_exist");return}showLoading();var t={};t.portMapEnable=q.portMapEnable();t.sourcePort=q.sourcePort();t.destIpAddress=q.destIpAddress();t.destPort=q.destPort();t.protocol=q.selectedMode();t.comment=q.comment();f.setPortMap(t,q.callback)}function n(){var u={sourcePort:q.sourcePort(),destIpAddress:q.destIpAddress(),destPort:q.destPort(),protocol:transProtocolValue(q.selectedMode())};var w;var v=q.rules();for(var t=0;t=a.portForwardMax){showAlert({msg:"rules_max",params:a.portForwardMax});return}if(q.checkExist()){showAlert("rule_exist");return}showLoading();var t={};t.comment=q.comment();t.protocol=q.selectedMode();t.portEnd=q.portEnd();t.portStart=q.portStart();t.ipAddress=q.ipAddress();f.setPortForward(t,q.callback)}function n(){q.ipAddress("");q.portStart("");q.portEnd("");q.selectedMode("TCP&UDP");q.comment("")}function m(t){if(t.result=="success"){n();c(q);successOverlay()}else{errorOverlay()}}function l(){var u={ipAddress:q.ipAddress(),portRange:q.portStart()+" - "+q.portEnd(),protocol:transProtocolValue(q.selectedMode())};var w;var t=q.rules();for(var v=0;v=b.portForwardMax){showAlert({msg:"rules_max",params:b.portForwardMax});return}if(q.checkExist()){showAlert("rule_exist");return}}else{var x=q.ipType()=="ipv4"?"IPv4":"IPv6";var w=k.filter(q.rules(),function(y){return y.ipType==x});if(w.length>=b.portForwardMax){showAlert({msg:"rules_max_v4v6",params:[x,b.portForwardMax]});return}if(q.checkExist()){showAlert({msg:"rule_exist_v4v6",params:x});return}}showConfirm("confirm_data_effect",function(){showLoading();var y={};y.macAddress=q.macAddress();if(q.ipv6Support()&&q.ipType()!="ipv6"){y.destIpAddress=q.destIpAddress();y.sourceIpAddress=q.sourceIpAddress()}else{y.destIpAddress=q.destIpv6Address();y.sourceIpAddress=q.sourceIpv6Address()}y.ipType=q.ipType();y.comment=q.comment();y.protocol=q.selectedMode();y.action=q.portFilterAction();y.sourcePortEnd=q.sourcePortEnd();y.sourcePortStart=q.sourcePortStart();y.destPortEnd=q.destPortEnd();y.destPortStart=q.destPortStart();h.setPortFilter(y,q.callback)})}function t(){showLoading();var w={};w.defaultPolicy=q.defaultPolicy();w.portFilterEnable=q.portFilterEnable();h.setPortFilterBasic(w,q.callback)}function s(){q.comment("");q.selectedMode("None");q.sourcePortEnd("0");q.sourcePortStart("0");q.destPortEnd("0");q.destPortStart("0");q.sourceIpv6Address("");q.sourceIpAddress("");q.destIpv6Address("");q.destIpAddress("");q.macAddress("");clearValidateMsg()}function n(){q.macAddress(q.macAddress().toUpperCase());var w=q.ipType().toUpperCase();var x={macAddress:q.macAddress(),destIpAddress:w=="IPV4"?q.destIpAddress():q.destIpv6Address(),sourceIpAddress:w=="IPV4"?q.sourceIpAddress():q.sourceIpv6Address(),destPortRange:q.destPortStart()=="0"?"":q.destPortStart()+" - "+q.destPortEnd(),sourcePortRange:q.sourcePortStart()=="0"?"":q.sourcePortStart()+" - "+q.sourcePortEnd(),action:q.portFilterAction()=="Drop"?"filter_drop":"filter_accept",protocol:transProtocolValue(q.selectedMode()),ipType:w};var A;var z=q.rules();for(var y=0;y0&&r!=""});var n=k.any(["#txtDestPortStart","#txtDestPortEnd","#txtSourcePortStart","#txtSourcePortEnd"],function(r){return g(r).val()!="0"});return m||n});return{init:f}});define("firewall_parental_control","underscore jquery knockout set service".split(" "),function(u,g,d,s,v){var j=10;var h=null;var b={MAIN:0,MANAGE:1,RULE:2};function r(){var S=this;var Q=v.getHostNameList({}).devices;S.currentPage=d.observable(b.MAIN);S.pages=b;S.childGroupList=d.observable([]);S.childGroupMac=d.computed(function(){return u.map(S.childGroupList(),function(U){return U.mac})});S.currentUserInChildGroup=d.observable(true);S.fetchChildGroupList=F;S.fetchChildGroupList();S.manageHandler=E;function E(){S.currentPage(b.MANAGE);S.fetchAttachedDevices()}S.attachedDevices=d.observable([]);S.fetchAttachedDevices=N;S.backToMainHandler=P;d.computed(function(){S.attachedDevices();S.childGroupList();g("#pc_children_group_form").translate()}).extend({notify:"always",throttle:300});function J(U,V){showLoading();v.addChildGroup(V,function(W){S.fetchChildGroupList(function(){S.fetchAttachedDevices(function(){hideLoading();if(U){v.logout({},function(){window.location="index.html"})}})})},function(W){errorOverlay()})}S.removeChildGroupHandler=O;S.addChildGroupHandler=H;S.dealElement=n;S.cancelEditHostNameHandler=G;S.saveHostNameHandler=z;S.editHostNameHandler=I;S.selectedIds=d.observableArray([]);S.siteList=d.observable([]);S.disableAdd=d.computed(function(){return S.siteList().length==j});d.computed(function(){S.siteList();S.selectedIds();setTimeout(function(){renderCheckbox()},100);g("#pc_site_white_list_form").translate()});S.openAddSitePopoverHandler=D;S.checkboxClickHandler=M;S.fetchSiteWhiteList=L;function K(U){showConfirm("confirm_data_delete",function(){showLoading();v.removeSiteWhite({ids:U},function(V){S.fetchSiteWhiteList(function(){successOverlay()})},function(V){S.fetchSiteWhiteList(function(){errorOverlay()})})})}S.removeAllWhiteSite=B;S.removeSelectedWhiteSite=T;S.removeWhiteSite=R;S.saveSiteWhite=x;S.notSave=d.observable(false);S.fetchTimeLimited=o;S.bindEvent=y;S.saveTimeLimitedHandler=w;var A=false;S.openRulePage=C;function C(){if(S.currentPage()==b.RULE){return}S.currentPage(b.RULE);S.currentUserInChildGroup(v.checkCurrentUserInChildGroup().result);t();if(!A){if(!S.currentUserInChildGroup()){S.bindEvent()}A=true}showLoading();S.fetchTimeLimited();S.fetchSiteWhiteList(function(){hideLoading()})}function F(U){v.childGroupList({},function(V){S.currentUserInChildGroup(v.checkCurrentUserInChildGroup(V.devices).result);S.childGroupList([]);u.map(V.devices,function(X,W){X.idx=W;X.hostname=e.getHostName(X.hostname,X.mac,Q)});S.childGroupList(V.devices);if(u.isFunction(U)){U.apply(this)}})}function N(U){S.attachedDevices([]);var V=0;var W=[];v.getAttachedCableDevices({},function(X){V++;var Y=u.map(X.attachedDevices,function(Z){Z.idx=u.uniqueId("wireless_");Z.hostName=e.getHostName(Z.hostName,Z.macAddress,Q);Z.inChildGroup=u.contains(S.childGroupMac(),Z.macAddress);return Z});if(V!=1){S.attachedDevices(u.flatten([W,Y]));if(u.isFunction(U)){U.apply(this)}}else{W=Y}});v.getCurrentlyAttachedDevicesInfo({},function(X){V++;var Y=u.map(X.attachedDevices,function(Z){Z.idx=u.uniqueId("wireless_");Z.hostName=e.getHostName(Z.hostName,Z.macAddress,Q);Z.inChildGroup=u.contains(S.childGroupMac(),Z.macAddress);return Z});if(V!=1){S.attachedDevices(u.flatten([W,Y]));if(u.isFunction(U)){U.apply(this)}}else{W=Y}})}function P(){S.currentPage(b.MAIN)}function O(U){showLoading();v.removeChildGroup(U,function(V){S.fetchChildGroupList(function(){S.fetchAttachedDevices(function(){hideLoading()})})},function(V){errorOverlay()})}function H(U){var V=v.getCurretnMAC();if(V!=U.macAddress){J(false,U)}else{showConfirm("parental_add_self",function(){J(true,U)})}}function G(U){S.dealElement(false,U.idx)}function z(X){var V=g("#hostname_input_"+X.idx);var U=g.trim(V.val());if(U.indexOf(" ")==0||U.lastIndexOf(" ")==(U.length-1)||/[\*\+\$\[&:,;<>'"\\`\]¥]{1,32}/.test(U)){showAlert("modify_hostname_invalid");return false}else{if(U==""){g(".promptErrorLabel","#confirm-message-container").text(g.i18n.prop("required"));var W=V.closest("td").addClass("has-error");addTimeout(function(){W.removeClass("has-error")},5000);showAlert("required");return false}}showLoading();X.hostname=U;v.editHostName(X,function(){v.getHostNameList({},function(Y){Q=Y.devices;S.fetchChildGroupList(function(){hideLoading()});S.fetchAttachedDevices()})},function(){errorOverlay()})}function I(U){g("#hostname_input_"+U.idx).val(U.hostname);S.dealElement(true,U.idx);return false}function D(){var U=g("#addNewSiteTmpl").html();popover.open({target:g("#openAddSiteBtn"),html:U,width:"300px",validation:m})}function M(V,U){addTimeout(function(){S.selectedIds(k())},100)}function L(U){v.getSiteWhiteList({},function(V){S.selectedIds([]);S.siteList(V.siteList);u.isFunction(U)&&U.apply(this)},function(){S.siteList([]);u.isFunction(U)&&U.apply(this)})}function B(){K(q())}function T(){K(k())}function R(V,U){K([V.id])}function x(W,V){popover.hide();var U=u.find(S.siteList(),function(X){return X.site==V});if(U){showAlert("pc_link_exist",function(){setTimeout(function(){popover.show()},200)});return false}showLoading();v.saveSiteWhite({name:W,site:V},function(){S.fetchSiteWhiteList(function(){popover.close();successOverlay()})},function(){S.fetchSiteWhiteList(function(){errorOverlay();popover.show()})})}function y(){g("td:not('.col-head')","#pc_time_limited_tbody").addClass("cursorhand").die().click(function(){S.notSave(true);g(this).toggleClass("active")}).hover(function(){var W=g(this);var U=W.data("week");var V=W.data("hour");g("tr:nth-child("+(U+1)+") td:first-child","#pc_time_limited_tbody").addClass("time_td_hover");g("#col_"+V).addClass("time_td_hover");if(W.not(".active")){W.addClass("time_td_hover")}},function(){var W=g(this);var U=W.data("week");var V=W.data("hour");g("tr:nth-child("+(U+1)+") td:first-child","#pc_time_limited_tbody").removeClass("time_td_hover");g("#col_"+V).removeClass("time_td_hover");W.removeClass("time_td_hover")})}function w(){showLoading();var U=a();var V=f(U);v.saveTimeLimited({time:V},function(){S.notSave(false);successOverlay()},function(){errorOverlay()})}}function n(x,w){if(x==false){g("#edit_btn_"+w+",#hostname_txt_"+w).show();g("#save_btn_"+w+",#cancel_btn_"+w+",#hostname_input_"+w).hide()}else{g("#edit_btn_"+w+",#hostname_txt_"+w).hide();g("#save_btn_"+w+",#cancel_btn_"+w+",#hostname_input_"+w).show()}}function o(){v.getTimeLimited({},function(x){for(var y in x){for(var w=0;w6){if(j==false){j=true;showAlert("ussd_operation_timeout")}}k++}else{if(E.rj45_state=="working"){hideLoading();y();window.clearInterval(p)}else{if(E.rj45_state=="dead"){hideLoading();D();window.clearInterval(p)}else{if(E.rj45_state=="idle"){hideLoading();if(A.currentMode()=="DHCP"&&F.ethwan_mode=="DHCP"){j==false&&A.dhcpNoticeShow(true);A.dhcpNotice("dyn_fail");A.dhcpNoticeText(e.i18n.prop("dyn_fail"))}if(A.currentMode()=="STATIC"&&F.ethwan_mode=="STATIC"){j==false&&A.staticNoticeShow(true);A.staticNotice("static_fail");A.staticNoticeText(e.i18n.prop("static_fail"))}if(A.currentMode()=="PPPOE"&&F.ethwan_mode=="PPPOE"){j==false&&A.pppoeNoticeShow(true);A.pppoeNotice("pppoe_fail");A.pppoeNoticeText(e.i18n.prop("pppoe_fail"))}if(A.currentMode()=="AUTO"&&F.ethwan_mode=="AUTO"){j==false&&A.autoNoticeShow(true);A.autoNotice("auto_fail");A.autoNoticeText(e.i18n.prop("auto_fail"))}window.clearInterval(p)}else{hideLoading();window.clearInterval(p)}}}}}function y(){if(A.currentMode()==F.ethwan_mode){if(A.currentMode()=="AUTO"){A.autoNoticeShow(true);A.autoNotice("auto_success");A.autoNoticeText(e.i18n.prop("auto_success"))}else{if(A.currentMode()=="PPPOE"){A.pppoeNoticeShow(true);A.pppoeNotice("pppoe_success");A.pppoeNoticeText(e.i18n.prop("pppoe_success"))}else{if(A.currentMode()=="STATIC"){A.staticNoticeShow(true);A.staticNotice("static_success");A.staticNoticeText(e.i18n.prop("static_success"))}else{if(A.currentMode()=="DHCP"){A.dhcpNoticeShow(true);A.dhcpNotice("dyn_success");A.dhcpNoticeText(e.i18n.prop("dyn_success"))}}}}}}function D(){if(E.rj45_state!="dead"){if(A.currentMode()=="AUTO"&&A.autoNotice()=="pppoe_msg"){A.autoNoticeShow(false)}else{if(A.currentMode()=="PPPOE"&&A.pppoeNotice()=="pppoe_msg"){A.pppoeNoticeShow(false)}else{if(A.currentMode()=="STATIC"&&A.staticNotice()=="pppoe_msg"){A.staticNoticeShow(false)}else{if(A.currentMode()=="DHCP"&&A.dhcpNotice()=="pppoe_msg"){A.dhcpNoticeShow(false)}}}}}else{A.dhcpNotice("pppoe_msg");A.dhcpNoticeText(e.i18n.prop("pppoe_msg"));A.staticNotice("pppoe_msg");A.staticNoticeText(e.i18n.prop("pppoe_msg"));A.pppoeNotice("pppoe_msg");A.pppoeNoticeText(e.i18n.prop("pppoe_msg"));A.autoNotice("pppoe_msg");A.autoNoticeText(e.i18n.prop("pppoe_msg"));if(A.currentMode()=="AUTO"){A.autoNoticeShow(true)}else{if(A.currentMode()=="PPPOE"){A.pppoeNoticeShow(true)}else{if(A.currentMode()=="STATIC"){A.staticNoticeShow(true)}else{if(A.currentMode()=="DHCP"){A.dhcpNoticeShow(true)}}}}}}function z(){if(k<1){k++}else{if(E.rj45_state!="working"&&E.rj45_state!="connect"){A.dhcpNoticeShow(false);A.staticNoticeShow(false);A.pppoeNoticeShow(false);A.autoNoticeShow(false);window.clearInterval(p);successOverlay()}else{if(k>6){if(j==false){j=true;showAlert("ussd_operation_timeout")}window.clearInterval(p)}else{if(k<7){k++}else{hideLoading();window.clearInterval(p)}}}}}function u(){A.dhcpNoticeShow(false);A.staticNoticeShow(false);A.pppoeNoticeShow(false);A.autoNoticeShow(false);if(E.rj45_state=="dead"){showAlert("pppoe_msg");return}var G={};if(e("#pppoe_mode").val()=="PPPOE"){G=e.extend({},{goformId:"WAN_GATEWAYMODE_PPPOE",pppoe_username:A.user(),pppoe_cc:A.password()})}else{if(e("#pppoe_mode").val()=="AUTO"){G=e.extend({},{goformId:"WAN_GATEWAYMODE_AUTO",pppoe_username:A.autoUser(),pppoe_cc:A.autoPassword()})}else{if(e("#pppoe_mode").val()=="STATIC"){if(A.ipAddress()==A.defaultGateway()){showAlert("ip_gate_not_same");return}if(n(A.ipAddress(),E.lan_ipaddr,E.lan_netmask)){showAlert("ip_innergate_not_same");return}G=e.extend({},{goformId:"WAN_GATEWAYMODE_STATIC",static_wan_ipaddr:A.ipAddress(),static_wan_netmask:A.subnetMask(),static_wan_gateway:A.defaultGateway(),static_wan_primary_dns:A.primaryDNS(),static_wan_secondary_dns:A.secondaryDNS(),WAN_MODE:"STATIC"})}else{G=e.extend({},{goformId:"WAN_GATEWAYMODE_DHCP"})}}}G.action_link="connect";G.dial_mode=A.pppMode();showLoading("waiting");s.setPppoeDialMode(G,function(H){if(H.result){A.currentMode(e("#pppoe_mode").val());E=s.getPppoeParams();k=0;j=false;x("connect");e("#pppoeApply").translate()}else{errorOverlay("pppoe_message_send_fail")}})}function v(){A.dhcpNoticeShow(false);A.staticNoticeShow(false);A.pppoeNoticeShow(false);A.autoNoticeShow(false);if(E.rj45_state=="dead"){showAlert("pppoe_msg");return}var G={dial_mode:A.pppMode(),action_link:"disconnect"};if(E.ethwan_mode=="PPPOE"){G=e.extend(G,{goformId:"WAN_GATEWAYMODE_PPPOE",pppoe_username:E.pppoe_username,pppoe_cc:E.pppoe_cc})}else{if(E.ethwan_mode=="AUTO"){G=e.extend(G,{goformId:"WAN_GATEWAYMODE_AUTO",pppoe_username:E.pppoe_username,pppoe_cc:E.pppoe_cc})}else{if(E.ethwan_mode=="STATIC"){G=e.extend(G,{goformId:"WAN_GATEWAYMODE_STATIC",static_wan_ipaddr:E.static_wan_ipaddr,static_wan_netmask:E.static_wan_netmask,static_wan_gateway:E.static_wan_gateway,static_wan_primary_dns:E.static_wan_primary_dns,static_wan_secondary_dns:E.static_wan_secondary_dns,WAN_MODE:"STATIC"})}else{G=e.extend(G,{goformId:"WAN_GATEWAYMODE_DHCP"})}}}showLoading("waiting");s.setPppoeDialMode(G,function(H){if(H.result){k=0;j=false;x("disconnect");e("#pppoeApply").translate()}else{errorOverlay("pppoe_message_send_fail")}})}function w(){C();return true}function t(){C()}}function h(u){var t=e("#container");a.cleanNode(t[0]);a.applyBindings(u,t[0])}function b(){var t=new c();h(t);e("#pppoeApply").translate();e("#pppoeForm").validate({submitHandler:function(){t.save()},rules:{txtPin:"wps_pin_check",txtIpAddress:"dmz_ip_check",txtSubnetMask:{ipv4:true,subnetmask_check:true},txtDefaultGateway:{ipv4:true,gateway_check:true},txtPrimaryDNS:{ipv4:true,dns_check:true},txtSecondaryDNS:{ipv4:true,dns_check:true}}})}function l(t){if("0.0.0.0"==t||"255.255.255.255"==t){return false}return true}function n(z,v,u){if(!z||!v||!u){return false}if(z==v){return true}var y=[],x=[],t=[];addr1=z.split(".");addr2=v.split(".");t=u.split(".");for(var w=0;w5){var v=z.split("||");for(var B=0;B5){var v=x.split("||");for(var B=0;B10){var w=v.split("||");for(var B=0;B0){N.selectedAutoProfile=d.observable(I.autoApnConfigs[0].profileName)}else{N.selectedAutoProfile=d.observable()}if(s.EMPTY_APN_SUPPORT==false){h("#apn_ipv4_apn").addClass("required");h("#apn_ipv6_apn").addClass("required")}else{h("#apn_ipv4_apn").removeClass("required");h("#apn_ipv6_apn").removeClass("required")}N.disableProfile=d.observable(false);N.addApnHide=d.observable(true);N.defaultCfg=d.observable(true);N.predeterminedCfg=d.observable(true);N.selectedAuthentication=d.observable(I.authMode);N.selectedAuthenticationV6=d.observable(I.authModeV6);N.transApnV6=d.observable("apn");N.transDnsModeV6=d.observable("apn_dns_mode");N.transDns1V6=d.observable("apn_dns1");N.transDns2V6=d.observable("apn_dns2");N.transAuthV6=d.observable("apn_authentication");N.transUserNameV6=d.observable("apn_user_name");N.transPasswordV6=d.observable("apn_password");N.transApn=d.observable(s.IPV4_AND_V6_SUPPORT?"apn_ipv4_apn":"apn");N.transDnsMode=d.observable(s.IPV4_AND_V6_SUPPORT?"apn_dns_mode_ipv4":"apn_dns_mode");N.transDns1=d.observable(s.IPV4_AND_V6_SUPPORT?"apn_dns1_ipv4":"apn_dns1");N.transDns2=d.observable(s.IPV4_AND_V6_SUPPORT?"apn_dns2_ipv4":"apn_dns2");N.transAuth=d.observable(s.IPV4_AND_V6_SUPPORT?"apn_authentication_ipv4":"apn_authentication");N.transUserName=d.observable(s.IPV4_AND_V6_SUPPORT?"apn_user_name_ipv4":"apn_user_name");N.transPassword=d.observable(s.IPV4_AND_V6_SUPPORT?"apn_password_ipv4":"apn_password");N.setDefaultVisible=d.observable(!a());N.tmp1=d.computed(function(){if(N.selectedPdpType()=="IPv6"){N.transApnV6("apn");N.transDnsModeV6("apn_dns_mode");N.transDns1V6("apn_dns1");N.transDns2V6("apn_dns2");N.transAuthV6("apn_authentication");N.transUserNameV6("apn_user_name");N.transPasswordV6("apn_password")}else{if(s.IPV4_AND_V6_SUPPORT&&N.selectedPdpType()=="IPv4v6"){N.transApn("apn_ipv4_apn");N.transDnsMode("apn_dns_mode_ipv4");N.transDns1("apn_dns1_ipv4");N.transDns2("apn_dns2_ipv4");N.transAuth("apn_authentication_ipv4");N.transUserName("apn_user_name_ipv4");N.transPassword("apn_password_ipv4");N.transApnV6("apn_ipv6_apn");N.transDnsModeV6("apn_dns_mode_ipv6");N.transDns1V6("apn_dns1_ipv6");N.transDns2V6("apn_dns2_ipv6");N.transAuthV6("apn_authentication_ipv6");N.transUserNameV6("apn_user_name_ipv6");N.transPasswordV6("apn_password_ipv6")}else{if(N.selectedPdpType()=="IP"||N.selectedPdpType()=="IPv4"){N.transApn("apn");N.transDnsMode("apn_dns_mode");N.transDns1("apn_dns1");N.transDns2("apn_dns2");N.transAuth("apn_authentication");N.transUserName("apn_user_name");N.transPassword("apn_password")}else{N.transApn("apn");N.transDnsMode("apn_dns_mode");N.transDns1("apn_dns1");N.transDns2("apn_dns2");N.transAuth("apn_authentication");N.transUserName("apn_user_name");N.transPassword("apn_password")}}}h("#apn_setting_form").translate()});N.autoApnChecked=d.computed(function(){return N.apnMode()=="auto"});N.hasCapacity=d.computed(function(){if(N.profiles().length0}});N.showPasswordHandler=function(){var Q=h("#showPassword:checked");if(Q&&Q.length==0){N.showPassword(true)}else{N.showPassword(false)}};N.autoProfileChangeHandler=L;N.profileChangeHandler=P;N.setUIData=H;function v(){var Q=A();if(N.apnMode()!="auto"){if(N.selectedProfile()!=N.defApn()){N.defaultCfg(false)}else{N.defaultCfg(true)}}else{if(N.selectedAutoProfile()!=N.defApn()){N.defaultCfg(false)}else{N.defaultCfg(true)}}if(Q>=s.defaultApnSize){N.predeterminedCfg(false)}else{N.predeterminedCfg(true)}}N.setDefaultAct=w;N.apnModeChangeHandler=B;function K(){var R=0;if(N.apnMode()!="auto"){R=A();N.selectedProfile(h("#profile").val())}else{R=G();N.selectedAutoProfile(h("#autoProfile").val())}var Q=N.getSelectedManualProfile();u.setDefaultApn({index:R,apnMode:N.apnMode(),pdpType:Q.pdpType,profileName:Q.profileName,wanApn:Q.wanApn,authMode:Q.authMode,username:Q.username,password:Q.password,dnsMode:s.SHOW_APN_DNS?Q.dnsMode:"auto",dns1:s.SHOW_APN_DNS?Q.dns1:"",dns2:s.SHOW_APN_DNS?Q.dns2:""},function(S){if(S.result){addTimeout(function(){b(true);N.apnModeChangeHandler();successOverlay()},500)}else{errorOverlay()}},function(S){errorOverlay()})}N.getSelectedManualProfile=M;function G(){var Q=h("#autoProfile option");for(var R=0;R=s.maxApnNumber){showInfo({msg:"apn_profile_full",params:[s.maxApnNumber]});return false}if(Q){showInfo("apn_save_profile_exist");return false}var R=u.getStatusInfo();if(R.connectStatus!="ppp_connected"){x()}else{showConfirm("apn_diconneted_network_confirm",function(){showLoading("disconnecting");u.disconnect({},function(S){if(S.result){s.connect_flag=true;x()}else{errorOverlay()}})})}}}function M(){var R={};var Q=h("#profile").val();if(typeof N.selectedProfile()=="undefined"){N.selectedProfile(Q)}var T=l[Q];var S=g[Q];if(T&&!S){h.extend(R,T)}else{if(T&&S){if(!!T.pdpType){h.extend(R,S);h.extend(R,T)}else{h.extend(R,T);h.extend(R,S)}}}return R}function B(R,Q){if(N.apnMode()!="auto"){N.profileChangeHandler()}else{if(N.showAutoApnDetail()){N.autoProfileChangeHandler()}}return true}function w(){if(!N.selectedProfile()){showAlert("apn_no_select_alert");return false}var R=u.getConnectionInfo().connectStatus;if(R=="ppp_connecting"){showAlert({msg:"apn_cant_modify_status",params:[h.i18n.prop("connecting").toLowerCase()]});return false}else{if(R=="ppp_disconnecting"){showAlert({msg:"apn_cant_modify_status",params:[h.i18n.prop("disconnecting").toLowerCase()]});return false}else{if(R=="ppp_connected"){showAlert({msg:"apn_cant_modify_status",params:[h.i18n.prop("connected").toLowerCase()]});return false}}}if(N.apnMode()=="auto"||N.predeterminedCfg()){showLoading("waiting");K()}else{if(h("#apn_setting_form").valid()==false){h(".error:first","#apn_setting_form").focus()}else{var Q=false;h.each(N.profiles(),function(S,T){if(T.value==N.profileName()){Q=true}});if(Q&&N.selectedProfile()!=N.profileName()){showInfo("apn_save_profile_exist");return false}C(true)}}}function H(Q){clearValidateMsg("#apn_setting_form");if(!Q){return}N.selectedPdpType(Q.pdpType||"IP");N.selectedPdpTypeTmp(Q.pdpType||"IP");N.profileName(Q.profileName);N.apn(Q.wanApn);N.dnsMode(Q.dnsMode!="manual"?"auto":"manual");N.dns1(Q.dns1);N.dns2(Q.dns2);N.username(Q.username);N.password(Q.password);N.selectedAuthentication(Q.authMode||"none");N.apnV6(Q.wanApnV6);N.dnsModeV6(Q.dnsModeV6!="manual"?"auto":"manual");N.dns1V6(Q.dns1V6);N.dns2V6(Q.dns2V6);N.usernameV6(Q.usernameV6);N.passwordV6(Q.passwordV6);N.selectedAuthenticationV6(Q.authModeV6||"none")}function P(S,R){N.pdpTypeNote(true);if(N.apnMode()!="manual"){return true}var Q=N.getSelectedManualProfile();N.setUIData(Q);v();return true}function L(S,R){if(N.apnMode()!="auto"){return true}var Q=c[N.selectedAutoProfile()];N.setUIData(Q);v();return true}function z(){if(N.pdpTypeNote()){showAlert({msg:"apn_pdptype_change_note",params:[O.lanDomain,O.ipAddress]})}if(N.apnMode()!="auto"&&!N.disableProfile()){if((s.IPV4_AND_V6_SUPPORT&&N.selectedPdpTypeTmp()!="IPv4v6"&&N.selectedPdpType()!="IPv4v6")||!s.IPV4_AND_V6_SUPPORT){if(N.selectedPdpTypeTmp()=="IPv6"){N.apn(N.apnV6());N.dnsMode(N.dnsModeV6());N.dns1(N.dns1V6());N.dns2(N.dns2V6());N.username(N.usernameV6());N.password(N.passwordV6());N.selectedAuthentication(N.selectedAuthenticationV6())}else{if(N.selectedPdpType()=="IPv6"){N.apnV6(N.apn());N.dnsModeV6(N.dnsMode());N.dns1V6(N.dns1());N.dns2V6(N.dns2());N.usernameV6(N.username());N.passwordV6(N.password());N.selectedAuthenticationV6(N.selectedAuthentication())}}}}N.selectedPdpTypeTmp(N.selectedPdpType())}}function a(){var v=u.getConnectionInfo();return v.connectStatus=="ppp_connected"}function k(){l={};g={};c={}}function n(w){var v=h("#container");d.cleanNode(v[0]);d.applyBindings(w,v[0])}function b(w){k();var v=new o();n(v);if(!w){addInterval(function(){v.setDefaultVisible(!a())},1000)}h("#apn_setting_form").validate({submitHandler:function(){v.saveAct()},rules:{profile_name:"apn_profile_name_check",apn_ipv4_apn:"apn_check",apn_dns1_ipv4:"ipv4",apn_dns2_ipv4:"ipv4",apn_ipv6_apn:"apn_check",apn_dns1_ipv6:"ipv6",apn_dns2_ipv6:"ipv6",apn_user_name_ipv4:"ppp_username_check",apn_secretcode_ipv4:"ppp_secretcode_check",apn_user_name_ipv6:"ppp_username_check",apn_secretcode_ipv6:"ppp_secretcode_check"}})}return{init:b}});