SHARE
TWEET

Untitled

a guest Dec 4th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var basicS=new Object;var scannedSsids=[[],[],[],[],[]];var toggleReload=false;var currentLanIp;var googleDns=["8.8.8.8","8.8.4.4"];var openDns=["208.67.222.222","208.67.220.220"];var openDnsFS=["208.67.222.123","208.67.220.123"];var quad9DNS=["9.9.9.9","149.112.112.112"];var ncDns=["178.32.31.41","106.187.47.17","176.58.118.172"];var onDns=["66.244.95.20","95.211.32.162","95.142.171.235"];var ncTlds=[".bit"];var onTlds=[".glue",".parody",".dyn",".bbs",".free",".fur",".geek",".gopher",".indy",".ing",".null",".oss",".micro"];var wanMacLoc="wan";function saveChanges(){errorList=proofreadAll();if(errorList.length>0){errorString=errorList.join("\n")+"\n\n"+UI.ErrChanges;alert(errorString)}else{var uci=uciOriginal.clone();var uciCompare=uciOriginal.clone();var doReboot=!isBridge(uciOriginal)&&document.getElementById("global_bridge").checked;if(doReboot){setControlsEnabled(false,true,basicS.WaitRb)}else{setControlsEnabled(false,true,UI.WaitSettings)}var preCommands="";if(wifiDevG==""&&wirelessDriver!=""){wifiDevG=wirelessDriver=="broadcom"?"wl0":"radio0";preCommands=preCommands+"uci set wireless."+wifiDevG+"=wifi-device\n";preCommands=preCommands+"uci set wireless."+wifiDevG+".type="+wirelessDriver+"\n";preCommands=preCommands+"uci commit\n";uci.set("wireless",wifiDevG,"","wifi-device");uci.set("wireless",wifiDevG,"type",wirelessDriver);if(wirelessDriver=="mac80211"){uci.set("wireless",wifiDevG,"hwmode","11g")}}var wifiDelIndex=0;var allWirelessInterfaceSections=uci.getAllSectionsOfType("wireless","wifi-iface");for(wifiDelIndex=0;wifiDelIndex<allWirelessInterfaceSections.length;wifiDelIndex++){var delSection=allWirelessInterfaceSections[wifiDelIndex];if(uci.get("wireless",delSection,"")=="wifi-iface"){uci.removeSection("wireless",delSection);uciCompare.removeSection("wireless",delSection);preCommands=preCommands+"uci del wireless."+delSection+"\n"}}preCommands=preCommands+"uci commit \n";if(wifiDevG!=""){uci.remove("wireless",wifiDevG,"disabled")}if(wifiDevA!=""){uci.remove("wireless",wifiDevA,"disabled")}var txPowerSet=function(sel_id,txt_id,dev){if(getSelectedValue(sel_id)=="max"){uci.remove("wireless",dev,"txpower")}else{uci.set("wireless",dev,"txpower",document.getElementById(txt_id).value)}};var channels=getSelectedWifiChannels();if(channels["G"]!=""){uci.set("wireless",wifiDevG,"channel",channels["G"]);if(document.getElementById("wifi_channel_width_container").style.display=="block"||document.getElementById("bridge_channel_width_container").style.display=="block"){uci.set("wireless",wifiDevG,"htmode",getSelectedValue("wifi_channel_width"))}txPowerSet("wifi_max_txpower","wifi_txpower",wifiDevG)}if(channels["A"]!=""){uci.set("wireless",wifiDevA,"channel",channels["A"]);uci.set("wireless",wifiDevA,"htmode",getSelectedValue("wifi_channel_width_5ghz"));txPowerSet("wifi_max_txpower_5ghz","wifi_txpower_5ghz",wifiDevA)}currentLanIp="";var adjustIpCommands="";var bridgeEnabledCommands="";preCommands=preCommands+"\nuci -q del network.bridgecfg\nuci commit\n";uci.removeSection("network","bridgecfg");uciCompare.removeSection("network","bridgecfg");preCommands=preCommands+"\nuci -q del network.wwan\nuci commit\n";uci.removeSection("network","wwan");uciCompare.removeSection("network","wwan");uci.set("dhcp","lan","ignore","0");var lanzone=uci.getAllSectionsOfType("firewall","zone");for(x=0;x<lanzone.length;x++){var name=uci.get("firewall",lanzone[x],"name");if(name=="lan"){uci.remove("firewall",lanzone[x],"network");uci.createListOption("firewall",lanzone[x],"network",true);uci.set("firewall",lanzone[x],"network",["lan"])}}if(document.getElementById("global_gateway").checked){var wifiGSelected=true;var wifiASelected=false;var dualBandSelected=false;if(document.getElementById("wifi_hwmode_container").style.display=="block"){uci.set("wireless",wifiDevG,"hwmode","11g");wifiASelected=getSelectedValue("wifi_hwmode_5ghz")=="disabled"?false:true;wifiGSelected=getSelectedValue("wifi_hwmode")=="disabled"?false:true;dualBandSelected=wifiGSelected==true&&wifiASelected==true}currentLanIp=document.getElementById("lan_ip").value;if(getSelectedValue("wan_protocol")=="none"){preCommands=preCommands+"\nuci -q del network.wan\nuci commit\n";uci.removeSection("network","wan");uciCompare.removeSection("network","wan")}else{preCommands=preCommands+"\nuci set network.wan=interface\n";uci.remove("network","wan","type");if(getSelectedValue("wan_protocol").match(/wireless/)){uci.remove("network","wan","ifname");uci.set("network","wan","type","bridge")}else if(singleEthernetIsWan()){uci.set("network","wan","ifname",defaultLanIf)}else if(getSelectedValue("wan_protocol").match(/3g/)){uci.remove("network","wan","ifname")}else if(getSelectedValue("wan_protocol").match(/qmi/)){uci.remove("network","wan","ifname")}else if(getSelectedValue("wan_protocol").match(/ncm/)){uci.remove("network","wan","ifname")}else if(getSelectedValue("wan_protocol").match(/mbim/)){uci.remove("network","wan","ifname")}else if(getSelectedValue("wan_protocol").match(/cdc/)){uci.set("network","wan","ifname",cdcif)}else{uci.set("network","wan","ifname",defaultWanIf)}}if(document.getElementById("wan_port_to_lan_container").style.display!="none"&&getSelectedValue("wan_port_to_lan")=="bridge"){uci.set("network","lan","ifname",defaultLanIf+" "+defaultWanIf)}else if(singleEthernetIsWan()){uci.remove("network","lan","ifname");uci.set("network","lan","ifname",wirelessIfs.length>0?wirelessIfs[0]:"")}else{uci.set("network","lan","ifname",defaultLanIf)}currentModes=getSelectedValue("wifi_mode");var guestGSelected=wifiGSelected&&(getSelectedValue("wifi_guest_mode")=="dual"||getSelectedValue("wifi_guest_mode")=="24ghz");var guestASelected=wifiASelected&&(getSelectedValue("wifi_guest_mode")=="dual"||getSelectedValue("wifi_guest_mode")=="5ghz");var apcfg="";var ap2cfg="";var apgncfg="";var apgn2cfg="";var othercfg="";if(currentModes.match(/ap/)){var macConflict=[];macConflict.push(currentLanMac,defaultWanMac,currentWanMac,document.getElementById("wan_mac").value);macConflict=macConflict.concat(currentWirelessMacs);if(wifiGSelected){apcfg="ap_g";uci.set("wireless",apcfg,"","wifi-iface");uci.set("wireless",apcfg,"device",wifiDevG);uci.set("wireless",apcfg,"mode","ap");uci.set("wireless",apcfg,"network","lan");uci.set("wireless",apcfg,"disassoc_low_ack","0");preCommands=preCommands+"uci set wireless."+apcfg+"='wifi-iface' \n";if(guestGSelected){apgncfg="ap_gn_g";uci.set("wireless",apgncfg,"","wifi-iface");uci.set("wireless",apgncfg,"device",wifiDevG);uci.set("wireless",apgncfg,"mode","ap");uci.set("wireless",apgncfg,"network","lan");uci.set("wireless",apgncfg,"disassoc_low_ack","0");uci.set("wireless",apgncfg,"is_guest_network","1");if(!distribTarget.match(/ramips/)){var mac=document.getElementById("wifi_guest_mac_g").value;if(mac==""){do{if(distribTarget.match(/mvebu/)){wmacIdx=wirelessIfs.indexOf(wifiDevG.replace("radio","wlan"));ref=currentWirelessMacs[wmacIdx];mac=getRandomMacWithMask(true,true,ref,"fd:ff:ff:ff:ff:f0")}else{mac=getRandomMac(true,true)}}while(macConflict.join(",").toLowerCase().split(",").indexOf(mac.toLowerCase())!=-1)}macConflict.push(mac);uci.set("wireless",apgncfg,"macaddr",mac)}preCommands=preCommands+"uci set wireless."+apgncfg+"='wifi-iface' \n"}}if(wifiASelected){apacfg="ap_a";uci.set("wireless",apacfg,"","wifi-iface");uci.set("wireless",apacfg,"device",wifiDevA);uci.set("wireless",apacfg,"mode","ap");uci.set("wireless",apacfg,"network","lan");uci.set("wireless",apacfg,"disassoc_low_ack","0");preCommands=preCommands+"uci set wireless."+apacfg+"='wifi-iface' \n";if(guestASelected){apgnacfg="ap_gn_a";uci.set("wireless",apgnacfg,"","wifi-iface");uci.set("wireless",apgnacfg,"device",wifiDevA);uci.set("wireless",apgnacfg,"mode","ap");uci.set("wireless",apgnacfg,"network","lan");uci.set("wireless",apgnacfg,"disassoc_low_ack","0");uci.set("wireless",apgnacfg,"is_guest_network","1");var mac=document.getElementById("wifi_guest_mac_a").value;if(mac==""){do{if(distribTarget.match(/mvebu/)){wmacIdx=wirelessIfs.indexOf(wifiDevA.replace("radio","wlan"));ref=currentWirelessMacs[wmacIdx];mac=getRandomMacWithMask(true,true,ref,"fd:ff:ff:ff:ff:f0")}else{mac=getRandomMac(true,true)}}while(macConflict.join(",").toLowerCase().split(",").indexOf(mac.toLowerCase())!=-1)}macConflict.push(mac);uci.set("wireless",apgnacfg,"macaddr",mac);preCommands=preCommands+"uci set wireless."+apgnacfg+"='wifi-iface' \n"}if(dualBandSelected){ap2cfg=apacfg;if(guestASelected){apgn2cfg=apgnacfg}}else{apcfg=apacfg;if(guestASelected){apgncfg=apgnacfg}}}if(currentModes=="ap+wds"){var wdsData=getTableDataArray(document.getElementById("wifi_wds_mac_table_container").firstChild,1,0);var wdsList=[];var wIndex=0;for(wIndex=0;wIndex<wdsData.length;wIndex++){wdsList.push(wdsData[wIndex][0])}if(wirelessDriver=="broadcom"){var encryption=getSelectedValue("wifi_encryption1");var key=encryption=="none"?"":encryption=="wep"?document.getElementById("wifi_wep1").value:document.getElementById("wifi_pass1").value;var ssid=document.getElementById("wifi_ssid1").value;var wIndex=0;for(wIndex=0;wIndex<wdsList.length;wIndex++){var sectionIndex=wIndex+3;var section="cfg"+sectionIndex;uci.set("wireless",section,"","wifi-iface");uci.set("wireless",section,"device",wifiDevG);uci.set("wireless",section,"network","lan");uci.set("wireless",section,"mode","wds");uci.set("wireless",section,"ssid",ssid);uci.set("wireless",section,"bssid",wdsList[wIndex].toLowerCase());uci.set("wireless",section,"encryption",encryption);if(encryption!="none"){uci.set("wireless",section,"key",key)}preCommands=preCommands+"\nuci set wireless."+section+"=wifi-iface\n"}}else{var wdsCfgs=[apcfg];if(dualBandSelected){wdsCfgs.push(ap2cfg)}var wci;for(wci=0;wci<wdsCfgs.length;wci++){wcfg=wdsCfgs[wci];uci.set("wireless",wcfg,"wds","1")}}}}if((currentModes.match(/\+/)||!currentModes.match(/ap/))&&currentModes!="disabled"&&currentModes!="ap+wds"){var otherCfgDev=wifiDevG;var wimode=getSelectedValue("wifi_mode");var fixedChannels=scannedSsids[0].length>0&&wimode.match(/sta/);if(fixedChannels){var ssidIndex=getSelectedValue("wifi_list_ssid2");fixedChannels=ssidIndex!="custom";if(fixedChannels){otherCfgDev=scannedSsids[4][parseInt(ssidIndex)]=="A"?wifiDevA:wifiDevG}}if(!fixedChannels){if(dualBandSelected){otherCfgDev=getSelectedValue("wifi_client_band")=="5"?wifiDevA:wifiDevG}else{otherCfgDev=wifiASelected?wifiDevA:wifiDevG}}otherMode=currentModes.replace(/\+?ap\+?/,"");othercfg=otherMode+"cfg";uci.set("wireless",othercfg,"","wifi-iface");uci.set("wireless",othercfg,"device",otherCfgDev);uci.set("wireless",othercfg,"mode",otherMode);uci.set("wireless",othercfg,"network",getSelectedValue("wan_protocol").match(/wireless/)?"wan":"lan");if(wirelessDriver=="mac80211"&&document.getElementById("wan_use_mac").checked&&wimode.match(/sta/)&&getSelectedValue("wan_protocol").match(/wireless/)){uci.set("wireless",othercfg,"macaddr",document.getElementById("wan_mac").value)}preCommands=preCommands+"uci set wireless."+othercfg+"='wifi-iface' \n"}preCommands=preCommands+"uci commit \n";macFilterEnabled=getSelectedValue("mac_filter_enabled")=="enabled";var macTable=document.getElementById("mac_table_container").firstChild;var macList=getTableDataArray(macTable,true,false);var policy=getSelectedValue("mac_filter_policy");var macListStr=macList.join(" ");if(wirelessDriver=="broadcom"){if(!macFilterEnabled||macListStr==""){uci.remove("wireless",wifiDevG,policyOption);uci.remove("wireless",wifiDevG,"maclist")}else{uci.set("wireless",wifiDevG,policyOption,policy);uci.set("wireless",wifiDevG,"maclist",macListStr)}}else{for(wsecIndex=0;wsecIndex<allWirelessInterfaceSections.length;wsecIndex++){var sectionType=uci.get("wireless",allWirelessInterfaceSections[wsecIndex],"");if(!macFilterEnabled||macListStr==""||sectionType!="wifi-iface"){uci.remove("wireless",allWirelessInterfaceSections[wsecIndex],policyOption);uci.remove("wireless",allWirelessInterfaceSections[wsecIndex],"maclist")}else{uci.set("wireless",allWirelessInterfaceSections[wsecIndex],policyOption,policy);uci.set("wireless",allWirelessInterfaceSections[wsecIndex],"maclist",macListStr)}}}var useAltRoot=document.getElementById("lan_dns_altroot").checked;var dnsmasqSection=uciOriginal.getAllSectionsOfType("dhcp","dnsmasq").shift();var currentAltServers=uci.remove("dhcp",dnsmasqSection,"server");var currentRebindServers=uci.remove("dhcp",dnsmasqSection,"rebind_domain");var altServerDefs=getAltServerDefs(currentAltServers,currentRebindServers,useAltRoot);if(altServerDefs[0].length>0){uci.createListOption("dhcp",dnsmasqSection,"server",true);uci.createListOption("dhcp",dnsmasqSection,"rebind_domain",true);uci.set("dhcp",dnsmasqSection,"server",altServerDefs[0]);uci.set("dhcp",dnsmasqSection,"rebind_domain",altServerDefs[1])}var firewallDefaultSections=uciOriginal.getAllSectionsOfType("firewall","defaults");var forceDNS=document.getElementById("lan_dns_force").checked?"1":"";uciOriginal.set("firewall",firewallDefaultSections[0],"force_router_dns",forceDNS);uci.set("firewall",firewallDefaultSections[0],"force_router_dns",forceDNS);var fdCommand=forceDNS=="1"?"\nuci set firewall.@defaults[0].force_router_dns=1 \n":"\nuci -q del firewall.@defaults[0].force_router_dns \n";preCommands=preCommands+fdCommand;var pingSection=getPingSection();var isPingDrop=document.getElementById("drop_wan_ping").checked?"DROP":"ACCEPT";uciOriginal.set("firewall",pingSection,"target",isPingDrop);uci.set("firewall",pingSection,"target",isPingDrop);var dhcpSection=getDhcpSection(uciOriginal);var newMask=document.getElementById("lan_mask").value;var newIp=document.getElementById("lan_ip").value;var routerIpEnd=parseInt(newIp.split(".")[3]);var oldStart=parseInt(uciOriginal.get("dhcp",dhcpSection,"start"));var oldEnd=oldStart+parseInt(uciOriginal.get("dhcp",dhcpSection,"limit"))-1;if(!rangeInSubnet(newMask,newIp,oldStart,oldEnd)||routerIpEnd>=oldStart&&routerIpEnd<=oldEnd){var newRange=getSubnetRange(newMask,newIp);var newStart;var newEnd;if(routerIpEnd-newRange[0]>newRange[1]-routerIpEnd){newStart=newRange[0];newEnd=routerIpEnd-1}else{newStart=routerIpEnd+1;newEnd=newRange[1]}uci.set("dhcp",dhcpSection,"start",newStart);uci.set("dhcp",dhcpSection,"limit",newEnd+1-newStart)}ppoeReconnectIds=["wan_pppoe_reconnect_pings","wan_pppoe_interval"];wifiSsidId=wifiGSelected?"wifi_ssid1":"wifi_ssid1a";wifiGuestSsidId=wifiGSelected?"wifi_guest_ssid1":"wifi_guest_ssid1a";inputIds=["wan_protocol","wan_pppoe_user","wan_pppoe_pass","wan_pppoe_max_idle",ppoeReconnectIds,"wan_static_ip","wan_static_mask","wan_static_gateway","wan_mac","wan_mtu","lan_ip","lan_mask","lan_gateway",wifiSsidId,"wifi_hidden","wifi_isolate","wifi_encryption1","wifi_pass1","wifi_wep1",wifiGuestSsidId,"wifi_guest_hidden","wifi_guest_isolate","wifi_guest_encryption1","wifi_guest_pass1","wifi_guest_wep1","wifi_server1","wifi_port1","wifi_pass2","wifi_wep2","wan_3g_device","wan_3g_user","wan_3g_pass","wan_3g_apn","wan_3g_pincode","wan_3g_service","wan_3g_isp"];options=["proto","username","password","demand","keepalive","ipaddr","netmask","gateway","macaddr","mtu","ipaddr","netmask","gateway","ssid","hidden","isolate","encryption","key","key","ssid","hidden","isolate","encryption","key","key","auth_server","auth_port","key","key","device","username","password","apn","pincode","service","mobile_isp"];var sv=setVariableFromValue;var svm=setVariableFromModifiedValue;var svcat=setVariableFromConcatenation;var svcond=setVariableConditionally;setFunctions=[sv,sv,sv,svm,svcat,sv,sv,sv,svcond,svcond,sv,sv,sv,sv,svcond,svcond,sv,sv,sv,sv,svcond,svcond,sv,sv,sv,sv,sv,sv,sv,sv,sv,sv,sv,sv,sv,sv];var f=false;var t=true;var minutesToSeconds=function(value){return value*60};var lowerCase=function(value){return value.toLowerCase()};var ifCustomMac=function(value){return document.getElementById("wan_use_mac").checked==true||defaultWanMac!=currentWanMac};var ifCustomMtu=function(value){return document.getElementById("wan_use_mtu").checked==true&&document.getElementById("wan_mtu").value!=1500};var ifHiddenChecked=function(value){return getSelectedValue("wifi_hidden")=="disabled"?1:0};var ifIsolateChecked=function(value){return getSelectedValue("wifi_isolate")=="enabled"?1:0};var ifGuestHiddenChecked=function(value){return getSelectedValue("wifi_guest_hidden")=="disabled"?1:0};var ifGuestIsolateChecked=function(value){return getSelectedValue("wifi_guest_isolate")=="enabled"?1:0};var demandParams=[f,minutesToSeconds];var macParams=[ifCustomMac,f,document.getElementById("wan_mac").value.toLowerCase()];var mtuParams=[ifCustomMtu,t,""];var hiddenParams=[ifHiddenChecked,f,"1"];var isolateParams=[ifIsolateChecked,f,"1"];var guestHiddenParams=[ifGuestHiddenChecked,f,"1"];var guestIsolateParams=[ifGuestIsolateChecked,f,"1"];additionalParams=[f,f,f,demandParams,f,f,f,f,macParams,mtuParams,f,f,f,f,hiddenParams,isolateParams,f,f,f,f,guestHiddenParams,guestIsolateParams,f,f,f,f,f,f,f,f,f,f,f,f,f,f];pppoeReconnectVisibilityIds=["wan_pppoe_reconnect_pings_container","wan_pppoe_interval_container"];multipleVisibilityIds=[pppoeReconnectVisibilityIds];wirelessSections=[apcfg,apcfg,apcfg,apcfg,apcfg,apcfg,apgncfg,apgncfg,apgncfg,apgncfg,apgncfg,apgncfg,apcfg,apcfg,othercfg,othercfg];visibilityIds=[];pkgs=[];sections=[];var idIndex;for(idIndex=0;idIndex<inputIds.length;idIndex++){if(isArray(inputIds[idIndex])){visibilityIds.push(multipleVisibilityIds.shift())}else{visibilityIds.push(inputIds[idIndex]+"_container")}if(idIndex==8){pkgs.push("network");sections.push(wanMacLoc);uci.remove("network",wanMacLoc,options[idIndex])}else if(idIndex<10||idIndex>28){pkgs.push("network");sections.push("wan");uci.remove("network","wan",options[idIndex])}else if(idIndex<13){pkgs.push("network");sections.push("lan");uci.remove("network","lan",options[idIndex])}else{pkgs.push("wireless");sections.push(wirelessSections.shift())}}setVariables(inputIds,visibilityIds,uci,pkgs,sections,options,setFunctions,additionalParams);if(apgncfg&&uci.get("wireless",apgncfg,"ssid")==""){uci.set("wireless",apgncfg,"disabled","1")}if(getSelectedValue("wifi_mode")!="disabled"){var ssid2="";var enc2="";if(document.getElementById("wifi_ssid2_container").style.display!="none"){ssid2=document.getElementById("wifi_ssid2").value;enc2=getSelectedValue("wifi_encryption2")}else if(document.getElementById("wifi_custom_ssid2_container").style.display!="none"){ssid2=document.getElementById("wifi_custom_ssid2").value;enc2=getSelectedValue("wifi_encryption2")}else if(document.getElementById("wifi_list_ssid2_container").style.display!="none"){ssid2=scannedSsids[0][parseInt(getSelectedValue("wifi_list_ssid2"))];enc2=scannedSsids[1][parseInt(getSelectedValue("wifi_list_ssid2"))]}if(ssid2!=""){uci.set("wireless",othercfg,"ssid",ssid2);uci.set("wireless",othercfg,"encryption",enc2)}if(ap2cfg!=""){var dup_sec_options=function(pkg,fromcfg,tocfg,optlist){var opti;for(opti=0;opti<optlist.length;opti++){uci.set(pkg,tocfg,optlist[opti],uci.get("wireless",fromcfg,optlist[opti]))}};var ssid=document.getElementById("wifi_ssid1a").value;uci.set("wireless",ap2cfg,"ssid",ssid);ssid||uci.set("wireless",ap2cfg,"disabled","1");dup_sec_options("wireless",apcfg,ap2cfg,["hidden","isolate","encryption","key","auth_server","auth_port"])}if(apgn2cfg!=""){var dup_sec_options=function(pkg,fromcfg,tocfg,optlist){var opti;for(opti=0;opti<optlist.length;opti++){uci.set(pkg,tocfg,optlist[opti],uci.get("wireless",fromcfg,optlist[opti]))}};var ssid=document.getElementById("wifi_guest_ssid1a").value;uci.set("wireless",apgn2cfg,"ssid",ssid);ssid||uci.set("wireless",apgn2cfg,"disabled","1");dup_sec_options("wireless",apgncfg,apgn2cfg,["hidden","isolate","encryption","key"])}}if(getSelectedValue("wan_protocol")=="none"){uci.removeSection("network","wan")}else{uci.set("network","wan","proto",getSelectedValue("wan_protocol").replace(/_.*$/g,""));uci.set("network","wan","ipv6","0")}if(uci.get("network","lan","proto")===""){uci.set("network","lan","proto","static")}if((isBcm94704||isRamips)&&uci.get("network","wan","type")!="bridge"){if(uci.get("network","wan","macaddr")==""){uci.set("network","wan","macaddr",defaultWanMac.toLowerCase())}}if(getSelectedValue("wan_protocol",document)=="pppoe"){uci.set("network","wan","defaultroute","1")}else{uci.remove("network","wan","defaultroute")}var bridgeCommandList=[];bridgeCommandList.push("/etc/init.d/dnsmasq enable");bridgeCommandList.push("uci set gargoyle.connection.dhcp=200");bridgeCommandList.push("uci set gargoyle.firewall.portforwarding=100");bridgeCommandList.push("uci set gargoyle.firewall.restriction=125");bridgeCommandList.push("uci set gargoyle.firewall.quotas=175");bridgeCommandList.push("uci set qos_gargoyle.global.network=wan");bridgeCommandList.push("uci commit");bridgeEnabledCommands="\n"+bridgeCommandList.join("\n")+"\n"}else{var bridgeDev=wifiDevG;if(document.getElementById("bridge_hwmode_container").style.display!="none"){var hwMode=getSelectedValue("bridge_hwmode");var hwMatchMode=!String(hwMode).match(/11g/);bridgeDev=hwMatchMode==true?wifiDevA:wifiDevG;if(wifiDevG==bridgeDev){uci.set("wireless",wifiDevG,"hwmode","11g")}else if(wifiDevA==bridgeDev){uci.set("wireless",wifiDevA,"hwmode","11a")}}if(document.getElementById("bridge_wan_port_to_lan_container").style.display!="none"&&getSelectedValue("bridge_wan_port_to_lan")=="bridge"){uci.set("network","lan","ifname",defaultLanIf+" "+defaultWanIf)}else{uci.set("network","lan","ifname",defaultLanIf)}currentLanIp=document.getElementById("bridge_ip").value;preCommands=preCommands+"\nuci -q del network.wan\nuci commit\n";uci.removeSection("network","wan");uciCompare.removeSection("network","wan");uci.set("network","lan","ipaddr",document.getElementById("bridge_ip").value);uci.set("network","lan","netmask",document.getElementById("bridge_mask").value);uci.set("network","lan","gateway",document.getElementById("bridge_gateway").value);uci.set("network","lan","dns",document.getElementById("bridge_gateway").value);if(getSelectedValue("bridge_mode")=="client_bridge"){preCommands=preCommands+"\nuci set network.bridgecfg=interface\nuci set network.wwan=interface\n";uci.set("network","bridgecfg","proto","relay");uci.set("network","bridgecfg","network","lan wwan");uci.set("network","wwan","proto","dhcp");uci.set("dhcp","lan","ignore","1");var lanzone=uci.getAllSectionsOfType("firewall","zone");for(x=0;x<lanzone.length;x++){var name=uci.get("firewall",lanzone[x],"name");if(name=="lan"){uci.remove("firewall",lanzone[x],"network");uci.createListOption("firewall",lanzone[x],"network",true);uci.set("firewall",lanzone[x],"network",["lan","wwan"])}}}var ssid="";var encryption="";if(document.getElementById("bridge_ssid_container").style.display!="none"){ssid=document.getElementById("bridge_ssid").value;encryption=getSelectedValue("bridge_encryption")}else if(document.getElementById("bridge_custom_ssid_container").style.display!="none"){ssid=document.getElementById("bridge_custom_ssid").value;encryption=getSelectedValue("bridge_encryption")}else if(document.getElementById("bridge_list_ssid_container").style.display!="none"){ssid=scannedSsids[0][parseInt(getSelectedValue("bridge_list_ssid"))];encryption=scannedSsids[1][parseInt(getSelectedValue("bridge_list_ssid"))]}var key=encryption=="none"?"":encryption=="wep"?document.getElementById("bridge_wep").value:document.getElementById("bridge_pass").value;if(getSelectedValue("bridge_mode")=="client_bridge"){uci.set("wireless","cfg2","","wifi-iface");uci.set("wireless","cfg2","device",bridgeDev);uci.set("wireless","cfg2","network","wwan");uci.set("wireless","cfg2","mode","sta");uci.set("wireless","cfg2","client_bridge","1");uci.set("wireless","cfg2","ssid",ssid);uci.set("wireless","cfg2","encryption",encryption);if(encryption!="none"){uci.set("wireless","cfg2","key",key)}preCommands=preCommands+"\nuci set wireless.cfg2=wifi-iface\n";if(getSelectedValue("bridge_repeater")=="enabled"&&document.getElementById("bridge_repeater_container").style.display!="none"){var apSsid=document.getElementById("bridge_broadcast_ssid").value;uci.set("wireless","cfg3","","wifi-iface");uci.set("wireless","cfg3","device",bridgeDev);uci.set("wireless","cfg3","network","lan");uci.set("wireless","cfg3","mode","ap");uci.set("wireless","cfg3","ssid",apSsid);uci.set("wireless","cfg3","encryption",encryption);if(encryption!="none"){uci.set("wireless","cfg3","key",key)}preCommands=preCommands+"\nuci set wireless.cfg3=wifi-iface\n"}}else{var wdsData=getTableDataArray(document.getElementById("bridge_wds_mac_table_container").firstChild);var wdsList=[];var wIndex=0;for(wIndex=0;wIndex<wdsData.length;wIndex++){wdsList.push(wdsData[wIndex][0].toLowerCase())}if(wirelessDriver=="broadcom"){uci.set("wireless","cfg2","","wifi-iface");uci.set("wireless","cfg2","device",bridgeDev);uci.set("wireless","cfg2","network","lan");uci.set("wireless","cfg2","mode","ap");uci.set("wireless","cfg2","ssid",ssid);uci.set("wireless","cfg2","encryption",encryption);if(encryption!="none"){uci.set("wireless","cfg2","key",key)}preCommands=preCommands+"\nuci set wireless.cfg2=wifi-iface\n";for(wIndex=0;wIndex<wdsList.length;wIndex++){var sectionIndex=wIndex+3;var section="cfg"+sectionIndex;uci.set("wireless",section,"","wifi-iface");uci.set("wireless",section,"device",bridgeDev);uci.set("wireless",section,"network","lan");uci.set("wireless",section,"mode","wds");uci.set("wireless",section,"ssid",ssid);uci.set("wireless",section,"bssid",wdsList[wIndex].toLowerCase());uci.set("wireless",section,"encryption",encryption);if(encryption!="none"){uci.set("wireless",section,"key",key)}preCommands=preCommands+"\nuci set wireless."+section+"=wifi-iface\n"}}else{var cfg="cfg2";if(getSelectedValue("bridge_repeater")=="enabled"){uci.set("wireless",cfg,"","wifi-iface");uci.set("wireless",cfg,"device",bridgeDev);uci.set("wireless",cfg,"network","lan");uci.set("wireless",cfg,"mode","ap");uci.set("wireless",cfg,"wds","1");uci.set("wireless",cfg,"encryption",encryption);if(encryption!="none"){uci.set("wireless",cfg,"key",key)}uci.set("wireless",cfg,"ssid",document.getElementById("bridge_broadcast_ssid").value);preCommands=preCommands+"\nuci set wireless."+cfg+"=wifi-iface\n";cfg="cfg3"}uci.set("wireless",cfg,"","wifi-iface");uci.set("wireless",cfg,"device",bridgeDev);uci.set("wireless",cfg,"network","lan");uci.set("wireless",cfg,"mode","sta");uci.set("wireless",cfg,"wds","1");uci.set("wireless",cfg,"ssid",ssid);uci.set("wireless",cfg,"encryption",encryption);if(encryption!="none"){uci.set("wireless",cfg,"key",key)}preCommands=preCommands+"\nuci set wireless."+cfg+"=wifi-iface\n"}}preCommands=preCommands+"\nuci commit\n";var bridgeCommandList=[];bridgeCommandList.push("/etc/init.d/dnsmasq disable");bridgeCommandList.push("/etc/init.d/miniupnpd disable");bridgeCommandList.push("uci -q del gargoyle.connection.dhcp");bridgeCommandList.push("uci -q del gargoyle.firewall.portforwarding");bridgeCommandList.push("uci -q del gargoyle.firewall.restriction");bridgeCommandList.push("uci -q del gargoyle.firewall.quotas");bridgeCommandList.push("uci -q del gargoyle.firewall.portforwarding");bridgeCommandList.push("uci set qos_gargoyle.global.network=lan");bridgeCommandList.push("uci commit");bridgeEnabledCommands="\n"+bridgeCommandList.join("\n")+"\n"}if(document.getElementById("wireless_country_container").style.display=="block"){for(x=0;x<uciWirelessDevs.length;x++){uci.set("wireless",uciWirelessDevs[x],"country",document.getElementById("wireless_country").value)}}uci.remove("network","wan","dns");var lanGateway=uci.get("network","lan","gateway");lanGateway=lanGateway==""?uci.get("network","lan","ipaddr"):lanGateway;var dns=lanGateway;var dnsSource=getSelectedValue("lan_dns_source");var notBridge=document.getElementById("global_gateway").checked;if(dnsSource!="isp"){var dnsList=[];if(dnsSource=="google"&&notBridge){dnsList=googleDns}else if(dnsSource=="opendns"&&notBridge){dnsList=openDns}else if(dnsSource=="opendnsfs"&&notBridge){dnsList=openDnsFS}else if(dnsSource=="quad9"&&notBridge){dnsList=quad9DNS}else{var dnsData=getTableDataArray(document.getElementById("lan_dns_table_container").firstChild);var dnsIndex=0;for(dnsIndex=0;dnsIndex<dnsData.length;dnsIndex++){dnsList.push(dnsData[dnsIndex][0])}}dns=dnsList.length>0?dnsList.join(" "):dns;if(notBridge&&uci.get("network","wan","")!=""&&dns!=lanGateway){uci.set("network","wan","dns",dns);uci.set("network","wan","peerdns","0")}}else if(notBridge&&uci.get("network","wan","")!=""){uci.remove("network","wan","peerdns")}uci.set("network","lan","dns",dns);var oldLanIp=uciOriginal.get("network","lan","ipaddr");if(oldLanIp!=currentLanIp&&oldLanIp!=""&&currentLanIp!=""){adjustIpCommands="\nsh /usr/lib/gargoyle/update_router_ip.sh "+oldLanIp+"  "+currentLanIp}var commands=uci.getScriptCommands(uciCompare);var restartNetworkCommand=(wirelessDriver=="broadcom"?"\niwconfig wl0 txpower 31\n":"")+"sh /usr/lib/gargoyle/restart_network.sh ;\n";if(doReboot){restartNetworkCommand="\nsh /usr/lib/gargoyle/reboot.sh ;\n"}var regenerateCacheCommand="\nrm -rf /tmp/cached_basic_vars ;\n/usr/lib/gargoyle/cache_basic_vars.sh >/dev/null 2>/dev/null\n";commands=preCommands+commands+adjustIpCommands+bridgeEnabledCommands+restartNetworkCommand+regenerateCacheCommand;var param=getParameterDefinition("commands",commands)+"&"+getParameterDefinition("hash",document.cookie.replace(/^.*hash=/,"").replace(/[\t ;]+.*$/,""));var stateChangeFunction=function(req){if(req.readyState==4){if(oldLanIp==currentLanIp&&!doReboot){uciOriginal=uci.clone();resetData();setControlsEnabled(true)}}};runAjax("POST","utility/run_commands.sh",param,stateChangeFunction);if(oldLanIp!=currentLanIp||doReboot){currentProtocol=location.href.match(/^https:/)?"https":"http";testLocation=currentProtocol+"://"+currentLanIp+":"+window.location.port+"/utility/reboot_test.sh";testReboot=function(){toggleReload=true;setTimeout("testReboot()",5*1e3);document.getElementById("reboot_test").src=testLocation};setTimeout("testReboot()",25*1e3);setTimeout("reloadPage()",240*1e3)}}}function reloadPage(){if(toggleReload){var reloadState=document.getElementById("reboot_test").readyState;if(typeof reloadState=="undefined"||reloadState==null||reloadState=="complete"){toggleReload=false;document.getElementById("reboot_test").src="";currentProtocol=location.href.match(/^https:/)?"https":"http";window.location=currentProtocol+"://"+currentLanIp+":"+window.location.port+window.location.pathname}}}function generateWepKey(length){var keyIndex=0;var key="";var hex=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];while(keyIndex<length){next=hex[Math.floor(Math.random()*16)];key=key+next;keyIndex++}return key}function setToWepKey(id,length){document.getElementById(id).value=generateWepKey(length);proofreadWep(document.getElementById(id))}function proofreadAll(){var vlr1=function(text){return validateLengthRange(text,1,999)};var vlr8=function(text){return validateLengthRange(text,8,999)};var vip=validateIP;var vnm=validateNetMask;var vm=validateMac;var vn=validateNumeric;var vw=validateWep;var vtp=function(text){return validateNumericRange(text,0,getMaxTxPower("G"))};var vtpa=function(text){return validateNumericRange(text,0,getMaxTxPower("A"))};var testWds=function(tableContainerId,selectId,wdsValue){var error=null;if(getSelectedValue(selectId)==wdsValue&&wirelessDriver!="mac80211"){var wdsData=getTableDataArray(document.getElementById(tableContainerId).firstChild);error=wdsData.length>0?null:basicS.WDSMAC}return error};var errors=[];if(document.getElementById("global_gateway").checked){var inputIds=["wan_pppoe_user","wan_pppoe_pass","wan_pppoe_max_idle","wan_pppoe_reconnect_pings","wan_pppoe_interval","wan_static_ip","wan_static_mask","wan_static_gateway","wan_mac","wan_mtu","lan_ip","lan_mask","lan_gateway","wifi_txpower","wifi_txpower_5ghz","wifi_ssid1","wifi_pass1","wifi_wep1","wifi_guest_pass1","wifi_guest_wep1","wifi_server1","wifi_port1","wifi_ssid2","wifi_pass2","wifi_wep2","wan_3g_device","wan_3g_apn"];var functions=[vlr1,vlr1,vn,vn,vn,vip,vnm,vip,vm,vn,vip,vnm,vip,vtp,vtpa,vlr1,vlr8,vw,vlr8,vw,vip,vn,vlr1,vlr8,vw,vlr1,vlr1];var optInputIds=["wifi_ssid1a","wifi_guest_ssid1","wifi_guest_ssid1a"];for(index in optInputIds){var input=optInputIds[index];if(document.getElementById(input+"_container").style.display=="block"){inputIds.push(input);functions.push(vlr1)}}var returnCodes=new Array;var visibilityIds=new Array;var idIndex;for(idIndex=0;idIndex<inputIds.length;idIndex++){returnCodes.push(0);var id=inputIds[idIndex];var container=id+"_container";visibilityIds.push(container)}var labelIds=new Array;for(idIndex=0;idIndex<inputIds.length;idIndex++){labelIds.push(inputIds[idIndex]+"_label")}errors=proofreadFields(inputIds,labelIds,functions,returnCodes,visibilityIds);var wdsError=testWds("wifi_wds_mac_table_container","wifi_mode","ap+wds");if(wdsError!=null){errors.push(wdsError)}}else{var inputIds=["bridge_ip","bridge_mask","bridge_gateway","bridge_txpower","bridge_ssid","bridge_pass","bridge_wep","bridge_broadcast_ssid"];var functions=[vip,vnm,vip,vtp,vlr1,vlr8,vw,vlr1];var returnCodes=[];var visibilityIds=[];var labelIds=[];var idIndex=0;for(idIndex=0;idIndex<inputIds.length;idIndex++){returnCodes.push(0);visibilityIds.push(inputIds[idIndex]+"_container");labelIds.push(inputIds[idIndex]+"_label")}errors=proofreadFields(inputIds,labelIds,functions,returnCodes,visibilityIds);var wdsError=testWds("bridge_wds_mac_table_container","bridge_mode","wds");if(wdsError!=null){errors.push(wdsError)}}return errors}function setGlobalVisibility(){if(getSelectedValue("wan_protocol").match(/wireless/)){currentMode=getSelectedValue("wifi_mode");if(!isb43){setAllowableSelections("wifi_mode",["sta","ap+sta"],[basicS.Clnt,basicS.Clnt+"+AP"]);setSelectedValue("wifi_mode",currentMode.match(/ap/)?"ap+sta":"sta")}else{setAllowableSelections("wifi_mode",["sta"],[basicS.Clnt]);setSelectedValue("wifi_mode","sta")}}else{currentMode=getSelectedValue("wifi_mode");setAllowableSelections("wifi_mode",["ap","ap+wds","adhoc","disabled"],[basicS.AcPt+" (AP)","AP+WDS","Ad Hoc",UI.Disabled]);if(wirelessDriver==""){removeOptionFromSelectElementByValue("wifi_mode","ap",document);removeOptionFromSelectElementByValue("wifi_mode","ap+wds",document);removeOptionFromSelectElementByValue("wifi_mode","adhoc",document)}if(currentMode=="ap+sta"||currentMode=="sta"){setSelectedValue("wifi_mode","ap")}else{setSelectedValue("wifi_mode",currentMode)}}var proto1=["dhcp_wired","pppoe_wired","static_wired"];var proto2=["DHCP ("+basicS.Wird+")","PPPoE ("+basicS.Wird+")",basicS.StIP+" ("+basicS.Wird+")"];if(wirelessDriver){proto1.push("dhcp_wireless","static_wireless");proto2.push("DHCP ("+basicS.Wrlss+")",basicS.StIP+" ("+basicS.Wrlss+")")}if(hasUSB){proto1.push("3g");proto2.push(basicS.Mo3g)}if(hasQMI){proto1.push("qmi");proto2.push(basicS.Mo3gQMI)}if(hasNCM){proto1.push("ncm");proto2.push(basicS.Mo3gNCM)}if(hasMBIM){proto1.push("mbim");proto2.push(basicS.Mo3gMBIM)}if(cdcif!=""){proto1.push("dhcp_cdc");proto2.push(basicS.Mo3gHiLink)}proto1.push("none");proto2.push(UI.Disabled);setAllowableSelections("wan_protocol",proto1,proto2);setVisibility(["wan_port_to_lan_container"],(getSelectedValue("wan_protocol")=="none"||getSelectedValue("wan_protocol").match(/wireless/)||getSelectedValue("wan_protocol").match(/3g/)||getSelectedValue("wan_protocol").match(/ncm/)||getSelectedValue("wan_protocol").match(/qmi/)||getSelectedValue("wan_protocol").match(/mbim/))&&!singleEthernetPort()?[1]:[0]);setWanVisibility();setWifiVisibility()}function setWanVisibility(){var wanIds=["wan_dhcp_ip_container","wan_dhcp_expires_container","wan_pppoe_user_container","wan_pppoe_pass_container","wan_pppoe_reconnect_mode_container","wan_pppoe_max_idle_container","wan_pppoe_reconnect_pings_container","wan_pppoe_interval_container","wan_static_ip_container","wan_static_mask_container","wan_static_gateway_container","wan_mac_container","wan_mtu_container","wan_ping_container","lan_gateway_container","wan_3g_device_container","wan_3g_user_container","wan_3g_pass_container","wan_3g_apn_container","wan_3g_pincode_container","wan_3g_service_container","wan_3g_isp_container"];var maxIdleIndex=5;var notWifi=getSelectedValue("wan_protocol").match(/wireless/)?0:1;var dhcpVisability=[1,1,0,0,0,0,0,0,0,0,0,1,notWifi,1,0,0,0,0,0,0,0,0];var pppoeVisability=[0,0,1,1,1,1,1,1,0,0,0,notWifi,notWifi,1,0,0,0,0,0,0,0,0];var staticVisability=[0,0,0,0,0,0,0,0,1,1,1,1,notWifi,1,0,0,0,0,0,0,0,0];var disabledVisability=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0];var tgVisability=[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,1];var qmiVisability=[0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,1,1,1,0,1];var wanVisibilities=new Array;wanVisibilities["dhcp"]=dhcpVisability;wanVisibilities["pppoe"]=pppoeVisability;wanVisibilities["static"]=staticVisability;wanVisibilities["none"]=disabledVisability;wanVisibilities["3g"]=tgVisability;wanVisibilities["qmi"]=qmiVisability;wanVisibilities["ncm"]=qmiVisability;wanVisibilities["mbim"]=qmiVisability;var selectedVisibility=wanVisibilities[getSelectedValue("wan_protocol").replace(/_.*$/g,"")];selectedVisibility[maxIdleIndex]=selectedVisibility[maxIdleIndex]==1&&document.getElementById("wan_pppoe_reconnect_mode").value=="demand"?1:0;selectedVisibility[maxIdleIndex+1]=selectedVisibility[maxIdleIndex+1]==1&&document.getElementById("wan_pppoe_reconnect_mode").value=="keepalive"?1:0;selectedVisibility[maxIdleIndex+2]=selectedVisibility[maxIdleIndex+2]==1&&document.getElementById("wan_pppoe_reconnect_mode").value=="keepalive"?1:0;setVisibility(wanIds,selectedVisibility);showApn()}function setWifiVisibility(){var wifiMode=getSelectedValue("wifi_mode");if(wifiMode=="ap+wds"){setAllowableSelections("wifi_encryption1",["none","psk2","psk","wep"],[basicS.None,"WPA2 PSK","WPA PSK","WEP"])}else{setAllowableSelections("wifi_encryption1",["none","psk2","psk","wep","wpa","wpa2"],[basicS.None,"WPA2 PSK","WPA PSK","WEP","WPA RADIUS","WPA2 RADIUS"])}if(wifiMode=="adhoc"){setAllowableSelections("wifi_encryption2",["none","wep"],[basicS.None,"WEP"]);document.getElementById("wifi_ssid2_label").firstChild.data="SSID:"}else{document.getElementById("wifi_ssid2_label").firstChild.data=basicS.Join+":";setAllowableSelections("wifi_encryption2",["none","psk2","psk","wep"],[basicS.None,"WPA2 PSK","WPA PSK","WEP"])}if(GwifiN==false){setAllowableSelections("wifi_hwmode",["disabled","11g"],[UI.Disabled,"B+G"])}else{setAllowableSelections("wifi_hwmode",["disabled","11gn","11g"],[UI.Disabled,"B+G+N","B+G"])}if(AwifiN==false&&uciOriginal.get("wireless",wifiDevA,"hwmode")==""){setAllowableSelections("wifi_hwmode_5ghz",["disabled"],[UI.Disabled])}else if(AwifiN==false){setAllowableSelections("wifi_hwmode_5ghz",["disabled","11a"],[UI.Disabled,"A"])}else if(AwifiAC==true){setAllowableSelections("wifi_hwmode_5ghz",["disabled","11anac","11an","11a"],[UI.Disabled,"A+N+AC","A+N","A"])}else{setAllowableSelections("wifi_hwmode_5ghz",["disabled","11an","11a"],[UI.Disabled,"A+N","A"])}var wifiIds=["internal_divider1","wifi_hwmode_container","wifi_channel_width_container","wifi_txpower_container","wifi_hwmode_5ghz_container","wifi_channel_width_5ghz_container","wifi_txpower_5ghz_container","mac_enabled_container","mac_filter_container","wireless_country_container","wifi_ssid1_container","wifi_ssid1a_container","wifi_channel1_container","wifi_fixed_channel1_container","wifi_channel1_5ghz_container","wifi_hidden_container","wifi_isolate_container","wifi_encryption1_container","wifi_pass1_container","wifi_wep1_container","wifi_server1_container","wifi_port1_container","internal_divider3","wifi_guest_ssid1_container","wifi_guest_ssid1a_container","wifi_guest_hidden_container","wifi_guest_isolate_container","wifi_guest_encryption1_container","wifi_guest_pass1_container","wifi_guest_wep1_container","wifi_guest_mode_container","wifi_mac_container","wifi_wds_container","internal_divider2","wifi_list_ssid2_container","wifi_custom_ssid2_container","wifi_ssid2_container","wifi_channel2_container","wifi_fixed_channel2_container","wifi_channel2_5ghz_container","wifi_client_band_container","wifi_encryption2_container","wifi_fixed_encryption2_container","wifi_pass2_container","wifi_wep2_container"];var ae=wifiDevA!=""?1:0;var g=getSelectedValue("wifi_hwmode")=="disabled"?0:1;var a=getSelectedValue("wifi_hwmode_5ghz")=="disabled"?0:1;var gw=g&&getSelectedValue("wifi_hwmode")!="11g";var aw=a&&getSelectedValue("wifi_hwmode_5ghz")!="11a";var mf=getSelectedValue("mac_filter_enabled")=="enabled"?1:0;var e1=document.getElementById("wifi_encryption1").value;var p1=e1!="none"&&e1!="wep"?1:0;var w1=e1=="wep"?1:0;var r1=e1=="wpa"||e1=="wpa2"?1:0;var gns=wirelessDriver=="mac80211"&&!isb43;var gn=getSelectedValue("wifi_guest_mode")!="disabled"?1:0;var gng=getSelectedValue("wifi_guest_mode")=="24ghz"||getSelectedValue("wifi_guest_mode")=="dual"?1:0;var gna=getSelectedValue("wifi_guest_mode")=="5ghz"||getSelectedValue("wifi_guest_mode")=="dual"?1:0;var ge1=document.getElementById("wifi_guest_encryption1").value;var gp1=gn&&(ge1!="none"&&ge1!="wep")?1:0;var gw1=gn&&ge1=="wep"?1:0;var gr1=gn&&(ge1=="wpa"||ge1=="wpa2")?1:0;var e2=document.getElementById("wifi_fixed_encryption2").style.display!="none"?document.getElementById("wifi_fixed_encryption2").firstChild.data:getSelectedValue("wifi_encryption2");var b=(GwifiN?0:1)&&(AwifiN?0:1);var p2=e2.match(/psk/)||e2.match(/WPA/)?1:0;var w2=e2.match(/wep/)||e2.match(/WEP/)?1:0;var wc=checkWifiCountryVisibility();var wifiVisibilities=new Array;wifiVisibilities["ap"]=[1,1,gw,g,ae,aw,a,1,mf,wc,1,a,1,0,a,1,1,1,p1,w1,r1,r1,gns,gng,gna,gn,gn,gn,gp1,gw1,gns,0,0,0,0,0,0,0,0,0,0,0,0,0,0];wifiVisibilities["ap+wds"]=[1,1,gw,g,ae,aw,a,1,mf,wc,1,0,1,0,0,1,1,1,p1,w1,r1,r1,gns,gng,gna,gn,gn,gn,gp1,gw1,gns,b,b,0,0,0,0,0,0,0,0,0,0,0,0];wifiVisibilities["sta"]=[1,1,gw,g,ae,aw,a,1,mf,wc,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,g,0,a,0,1,0,p2,w2];wifiVisibilities["ap+sta"]=[1,1,gw,g,ae,aw,a,1,mf,wc,1,a,1,0,a,1,1,1,p1,w1,r1,r1,gns,gng,gna,gn,gn,gn,gp1,gw1,gns,0,0,1,0,0,1,g,0,a,a,1,0,p2,w2];wifiVisibilities["adhoc"]=[1,1,gw,g,ae,aw,a,1,mf,wc,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,g,0,a,0,1,0,p2,w2];wifiVisibilities["disabled"]=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];var wifiVisibility=wifiVisibilities[wifiMode];setVisibility(wifiIds,wifiVisibility);if(wifiMode.match(/sta/)){setSsidVisibility("wifi_list_ssid2")}if(wifiMode!="disabled"){setHwMode(document.getElementById("wifi_hwmode"))}}function setBridgeVisibility(){showIds=document.getElementById("global_gateway").checked?["wan_fieldset","lan_fieldset","wifi_fieldset"]:["bridge_fieldset"];hideIds=document.getElementById("global_gateway").checked?["bridge_fieldset"]:["wan_fieldset","lan_fieldset","wifi_fieldset"];var allIds=[hideIds,showIds];var statIndex;for(statIndex=0;statIndex<2;statIndex++){var ids=allIds[statIndex];var idIndex;for(idIndex=0;idIndex<ids.length;idIndex++){document.getElementById(ids[idIndex]).style.display=statIndex==0?"none":"block"}}if(singleEthernetPort()){document.getElementById("bridge_wan_port_to_lan_container").style.display="none"}else{document.getElementById("bridge_wan_port_to_lan_container").style.display="block"}if(document.getElementById("global_bridge").checked){var brenc=document.getElementById("bridge_fixed_encryption_container").style.display=="none"?getSelectedValue("bridge_encryption"):document.getElementById("bridge_fixed_encryption").firstChild.data;document.getElementById("bridge_pass_container").style.display=brenc.match(/psk/)||brenc.match(/WPA/)?"block":"none";document.getElementById("bridge_wep_container").style.display=brenc.match(/wep/)||brenc.match(/WEP/)?"block":"none";var bridgeMode=getSelectedValue("bridge_mode");var repeaterPossible=bridgeMode=="client_bridge"&&!isb43||bridgeMode=="wds"&&wirelessDriver=="mac80211";document.getElementById("bridge_repeater_container").style.display=repeaterPossible?"block":"none";document.getElementById("bridge_wifi_mac_container").style.display=bridgeMode=="wds"&&wirelessDriver!="mac80211"?"block":"none";document.getElementById("bridge_wds_container").style.display=bridgeMode=="wds"&&wirelessDriver!="mac80211"?"block":"none";document.getElementById("bridge_fixed_encryption_container").style.display="none";document.getElementById("bridge_fixed_channel_container").style.display="none";document.getElementById("bridge_broadcast_ssid_container").style.display=repeaterPossible&&getSelectedValue("bridge_repeater")=="enabled"?"block":"none";if(document.getElementById("bridge_broadcast_ssid").value==""){var ssid="";if(document.getElementById("bridge_ssid_container").style.display!="none"){ssid=document.getElementById("bridge_ssid").value}else if(document.getElementById("bridge_custom_ssid_container").style.display!="none"){ssid=document.getElementById("bridge_custom_ssid").value}else if(document.getElementById("bridge_list_ssid_container").style.display!="none"){ssid=scannedSsids[0][parseInt(getSelectedValue("bridge_list_ssid"))]}document.getElementById("bridge_broadcast_ssid").value=ssid}setSsidVisibility("bridge_list_ssid");document.getElementById("bridge_wireless_country_container").style.display=checkWifiCountryVisibility()?"block":"none";document.getElementById("bridge_note").innerHTML=bridgeMode=="wds"?basicS.BrNoteWDS:basicS.BrNoteClient}var allowedbridgemodes=[];var allowedbridgemodes2=[];if(dualBandWireless){if(GwifiN){allowedbridgemodes.push("B+G+N");allowedbridgemodes2.push("11gn")}allowedbridgemodes.push("B+G");allowedbridgemodes2.push("11g");if(AwifiAC){allowedbridgemodes.push("A+N+AC");allowedbridgemodes2.push("11anac")}if(AwifiN){allowedbridgemodes.push("A+N");allowedbridgemodes2.push("11an")}allowedbridgemodes.push("A");allowedbridgemodes2.push("11a")}else{if(GwifiN){allowedbridgemodes.push("B+G+N");allowedbridgemodes2.push("11gn")}allowedbridgemodes.push("B+G");allowedbridgemodes2.push("11g")}if(wirelessDriver==""){document.getElementById("global_bridge").disabled=true}setAllowableSelections("bridge_hwmode",allowedbridgemodes2,allowedbridgemodes);setHwMode(document.getElementById("bridge_hwmode"));setGlobalVisibility()}function localdate(ldate){var twod=function(num){var nstr=""+num;nstr=nstr.length==1?"0"+nstr:nstr;return nstr};var ldateStr="";var systemDateFormat=uciOriginal.get("gargoyle","global","dateformat");var y2=twod(ldate.getUTCFullYear()%100);var y4=ldate.getUTCFullYear();var m=twod(ldate.getUTCMonth()+1);var d=twod(ldate.getUTCDate());var h=" "+twod(ldate.getUTCHours())+":"+twod(ldate.getUTCMinutes())+" "+timezoneName;if(systemDateFormat=="iso"){ldateStr=y4+"/"+m+"/"+d+h}else if(systemDateFormat=="iso8601"){ldateStr=y4+"-"+m+"-"+d+h}else if(systemDateFormat=="hungary"){ldateStr=y4+"."+m+"."+d+h}else if(systemDateFormat=="australia"){ldateStr=d+"/"+m+"/"+y2+h}else if(systemDateFormat=="russia"){ldateStr=d+"."+m+"."+y4+h}else if(systemDateFormat=="argentina"){ldateStr=d+"/"+m+"/"+y4+h}else{ldateStr=m+"/"+d+"/"+y2+h}return ldateStr}function resetData(){wanMacLoc=uciOriginal.get("network","wan_dev","macaddr")!=""?"wan_dev":wanMacLoc;var removeChannels=[];var hwAmode="disabled";var hwGmode="disabled";if(wirelessDriver=="broadcom"){removeChannels.push("auto")}else if(wirelessDriver=="mac80211"){setAllowableSelections("bridge_channel",mac80211Channels["G"],mac80211Channels["G"],document);setAllowableSelections("wifi_channel1",mac80211Channels["G"],mac80211Channels["G"],document);setAllowableSelections("wifi_channel2",mac80211Channels["G"],mac80211Channels["G"],document);if(mac80211Channels["A"]!=null){setAllowableSelections("wifi_channel1_5ghz",mac80211Channels["A"],mac80211Channels["A"],document);setAllowableSelections("bridge_channel_5ghz",mac80211Channels["A"],mac80211Channels["A"],document)}}while(removeChannels.length>0){var rc=removeChannels.shift();removeOptionFromSelectElement("bridge_channel",rc,document);removeOptionFromSelectElement("wifi_channel1",rc,document);removeOptionFromSelectElement("wifi_channel2",rc,document)}if(leaseStart!=""){setElementEnabled(document.getElementById("dhcp_renew_button"),true);setElementEnabled(document.getElementById("dhcp_release_button"),true);var releaseDate=new Date;var leaseStartSeconds=parseInt(currentDateSeconds)-parseInt(uptime)+parseInt(leaseStart);releaseDate.setTime(leaseStartSeconds*1e3+parseInt(leaseLifetime)*1e3+timezoneOffset*1e3);setChildText("dhcp_expires",localdate(releaseDate));setChildText("dhcp_ip",currentWanIp)}else{setElementEnabled(document.getElementById("dhcp_renew_button"),true);setElementEnabled(document.getElementById("dhcp_release_button"),false)}setChildText("bridge_wifi_mac",currentWirelessMacs[0],null,null,null);setChildText("wifi_mac",currentWirelessMacs[0],null,null,null);var confIsBridge=isBridge(uciOriginal);var confIsGateway=!confIsBridge;document.getElementById("global_gateway").checked=confIsGateway;document.getElementById("global_bridge").checked=confIsBridge;document.getElementById("bridge_ip").value=uciOriginal.get("network","lan","ipaddr");document.getElementById("bridge_mask").value=uciOriginal.get("network","lan","netmask");document.getElementById("bridge_gateway").value=uciOriginal.get("network","lan","gateway");var bridgeWdsTableData=[];if(confIsBridge){var bridgeSection=getBridgeSection(uciOriginal);var mode=uciOriginal.get("wireless",bridgeSection,"client_bridge")=="1"?"client_bridge":"wds";setSelectedValue("bridge_mode",mode);document.getElementById("bridge_ssid").value=uciOriginal.get("wireless",bridgeSection,"ssid");var repeaterSection="";var testSections=uciOriginal.getAllSectionsOfType("wireless","wifi-iface");var testIndex=0;for(testIndex=0;testIndex<testSections.length&&(mode!="wds"||wirelessDriver=="mac80211")&&repeaterSection=="";testIndex++){var s=testSections[testIndex];repeaterSection=uciOriginal.get("wireless",s,"mode")=="ap"?s:""}setSelectedValue("bridge_repeater",repeaterSection==""?"disabled":"enabled");var encryption=uciOriginal.get("wireless",bridgeSection,"encryption");encryption=encryption==""?"none":encryption;setSelectedValue("bridge_encryption",encryption);document.getElementById("bridge_wep").value=encryption=="wep"?uciOriginal.get("wireless",bridgeSection,"key"):"";document.getElementById("bridge_pass").value=encryption!="wep"&&encryption!="none"?uciOriginal.get("wireless",bridgeSection,"key"):"";document.getElementById("bridge_broadcast_ssid").value=repeaterSection==""?uciOriginal.get("wireless",bridgeSection,"ssid"):uciOriginal.get("wireless",repeaterSection,"ssid");if(mode=="wds"){if(wirelessDriver=="broadcom"){var ifaceSections=uciOriginal.getAllSectionsOfType("wireless","wifi-iface");var ifIndex;for(ifIndex=0;ifIndex<ifaceSections.length;ifIndex++){if(uciOriginal.get("wireless",ifaceSections[ifIndex],"mode")=="wds"){var bssid=uciOriginal.get("wireless",ifaceSections[ifIndex],"bssid");bridgeWdsTableData.push([bssid.toUpperCase()])}}}}}else{setSelectedValue("bridge_mode","client_bridge");setSelectedValue("bridge_repeater","enabled");document.getElementById("bridge_ssid").value="Gargoyle";setSelectedValue("bridge_channel","5");setSelectedValue("bridge_encryption","none")}var bridgeWdsMacTable=createTable([""],bridgeWdsTableData,"bridge_wds_mac_table",true,false);var bridgeWdsTableContainer=document.getElementById("bridge_wds_mac_table_container");if(bridgeWdsTableContainer.firstChild!=null){bridgeWdsTableContainer.removeChild(bridgeWdsTableContainer.firstChild)}bridgeWdsTableContainer.appendChild(bridgeWdsMacTable);var wanIsWireless=false;var wifIndex=0;for(wifIndex=0;wifIndex<wirelessIfs.length;wifIndex++){wanIsWireless=uciOriginal.get("network","wan","ifname")==wirelessIfs[wifIndex]}if(isBcm94704&&!wanIsWireless&&uciOriginal.get("network",wanMacLoc,"macaddr")!=""){var currentMac=uciOriginal.get("network",wanMacLoc,"macaddr").toUpperCase();var currentStart=currentMac.substr(0,15);var currentEnd=currentMac.substr(15,2);var lanMacIndex=0;for(lanMacIndex=0;lanMacIndex<allLanMacs.length;lanMacIndex++){var nextMac=allLanMacs[lanMacIndex].toUpperCase();var nextStart=nextMac.substr(0,15);var nextEnd=nextMac.substr(15,2);if(nextStart==currentStart&&Math.abs(parseInt(nextEnd,16)-parseInt(currentEnd,16))==1){defaultWanMac=currentMac}}}var wp=uciOriginal.get("network","wan","proto");var wanUciIf=uciOriginal.get("network","wan","ifname");var wanType=uciOriginal.get("network","wan","type");var lanUciIf=uciOriginal.get("network","lan","ifname");var wanIsWifi=wanUciIf==""&&wanType=="bridge"&&(getWirelessMode(uciOriginal)=="sta"||getWirelessMode(uciOriginal)=="ap+sta");wp=wp==""?"none":wp;if(wp!="none"&&wp!="3g"&&wp!="qmi"&&wp!="ncm"&&wp!="mbim"){wp=wanIsWifi?wp+"_wireless":wp+"_wired"}if(wp=="dhcp_wired"&&wanUciIf!=defaultWanIf){wp="dhcp_cdc"}setSelectedValue("wan_protocol",wp);var wanToLanStatus=lanUciIf.indexOf(defaultWanIf)<0?"disable":"bridge";setSelectedValue("bridge_wan_port_to_lan",wanToLanStatus);setSelectedValue("wan_port_to_lan",wanToLanStatus);for(idIndex=0;idIndex<apns.length;idIndex++){addOptionToSelectElement("wan_3g_isp",apns[idIndex][0],apns[idIndex][0])}networkIds=["wan_pppoe_user","wan_pppoe_pass","wan_pppoe_max_idle","wan_pppoe_reconnect_pings","wan_pppoe_interval","wan_static_ip","wan_static_mask","wan_static_gateway","wan_use_mac","wan_mac","wan_use_mtu","wan_mtu","lan_ip","lan_mask","lan_gateway","wan_3g_device","wan_3g_user","wan_3g_pass","wan_3g_apn","wan_3g_pincode","wan_3g_service","wan_3g_isp"];networkPkgs=new Array;for(idIndex in networkIds){networkPkgs.push("network")}networkSections=["wan","wan","wan","wan","wan","wan","wan","wan",wanMacLoc,wanMacLoc,"wan","wan","lan","lan","lan","wan","wan","wan","wan","wan","wan","wan"];networkOptions=["username","password","demand","keepalive","keepalive","ipaddr","netmask","gateway","macaddr","macaddr","mtu","mtu","ipaddr","netmask","gateway","device","username","password","apn","pincode","service","mobile_isp"];pppoeDemandParams=[5*60,1/60];pppoeReconnectParams=[3,0];pppoeIntervalParams=[5,1];useMtuTest=function(v){return v==""||v==null||v==1500?false:true};useMacTest=function(v){v=v==null?"":v;return v==""||v.toLowerCase()==defaultWanMac.toLowerCase()?false:true};networkParams=["","",pppoeDemandParams,pppoeReconnectParams,pppoeIntervalParams,"10.1.1.10","255.255.255.0","127.0.0.1",useMacTest,defaultWanMac,useMtuTest,1500,"192.168.1.1","255.255.255.0","192.168.1.1","/dev/ttyUSB0","","","internet","","umts","custom"];var firewallDefaultSections=uciOriginal.getAllSectionsOfType("firewall","defaults");lv=loadValueFromVariable;lsv=loadSelectedValueFromVariable;lvm=loadValueFromVariableMultiple;lvi=loadValueFromVariableAtIndex;lc=loadChecked;networkFunctions=[lv,lv,lvm,lvi,lvi,lv,lv,lv,lc,lv,lc,lv,lv,lv,lv,lv,lv,lv,lv,lv,lv,lv];loadVariables(uciOriginal,networkIds,networkPkgs,networkSections,networkOptions,networkParams,networkFunctions);if(uciOriginal.get("network","wan","proto")==""){document.getElementById("wan_protocol").value="none"}enableAssociatedField(document.getElementById("wan_use_mac"),"wan_mac",defaultWanMac);enableAssociatedField(document.getElementById("wan_use_mtu"),"wan_mtu",1500);keepalive=uciOriginal.get("network","wan","keepalive");demand=uciOriginal.get("network","wan","demand");reconnect_mode=keepalive!=""||demand==""?"keepalive":"demand";document.getElementById("wan_pppoe_reconnect_mode").value=reconnect_mode;document.getElementById("lan_dns_force").checked=uciOriginal.get("firewall",firewallDefaultSections[0],"force_router_dns")=="1";document.getElementById("lan_dns_altroot").checked=uciOriginal.get("dhcp",uciOriginal.getAllSectionsOfType("dhcp","dnsmasq").shift(),"server")instanceof Array;document.getElementById("drop_wan_ping").checked=uciOriginal.get("firewall",getPingSection(),"target").toLowerCase()=="drop";var origDns=uciOriginal.get("network","lan","dns").split(/[\t ]+/);var routerIp=uciOriginal.get("network","lan","ipaddr");var routerGateway=uciOriginal.get("network","lan","gateway");var dIndex=0;var dnsTableData=[];for(dIndex=0;dIndex<origDns.length;dIndex++){var dip=origDns[dIndex];var isRouterIp=!confIsBridge&&dip==routerIp;var isBridgeGw=confIsBridge&&dip==routerGateway;if(!isRouterIp&&!isBridgeGw&&validateIP(dip)==0){dnsTableData.push([dip])}}var dnsType="custom";if(dnsTableData.length==0){dnsType="isp"}else if(dnsTableData.join(",")==openDns.join(",")||dnsTableData.join(",")==openDns.reverse().join(",")){dnsType="opendns"}else if(dnsTableData.join(",")==openDnsFS.join(",")||dnsTableData.join(",")==openDnsFS.reverse().join(",")){dnsType="opendnsfs"}else if(dnsTableData.join(",")==googleDns.join(",")||dnsTableData.join(",")==googleDns.reverse().join(",")){dnsType="google"}else if(dnsTableData.join(",")==quad9DNS.join(",")||dnsTableData.join(",")==quad9DNS.reverse().join(",")){dnsType="quad9"}setSelectedValue("lan_dns_source",dnsType);setDnsSource(document.getElementById("lan_dns_source"));var lanDnsTable=createTable([""],dnsType=="custom"?dnsTableData:[],"lan_dns_table",true,false);var lanDnsTableContainer=document.getElementById("lan_dns_table_container");if(lanDnsTableContainer.firstChild!=null){lanDnsTableContainer.removeChild(lanDnsTableContainer.firstChild)}lanDnsTableContainer.appendChild(lanDnsTable);var bridgeDnsTable=createTable([""],dnsType=="custom"?dnsTableData:[],"bridge_dns_table",true,false);var bridgeDnsTableContainer=document.getElementById("bridge_dns_table_container");if(bridgeDnsTableContainer.firstChild!=null){bridgeDnsTableContainer.removeChild(bridgeDnsTableContainer.firstChild)}bridgeDnsTableContainer.appendChild(bridgeDnsTable);var allWirelessSections=uciOriginal.getAllSectionsOfType("wireless","wifi-iface");var apcfg="";var ap2cfg="";var apgncfg="";var apgn2cfg="";var othercfg="";var otherdev="";var seci=0;for(seci=0;seci<allWirelessSections.length;seci++){var sec=allWirelessSections[seci];var secmode=uciOriginal.get("wireless",sec,"mode");var secdev=uciOriginal.get("wireless",sec,"device");var isguest=uciOriginal.get("wireless",sec,"is_guest_network");if(isguest=="1"){apgncfg=secmode=="ap"&&secdev!=wifiDevA&&apgncfg==""?sec:apgncfg;apgn2cfg=secmode=="ap"&&secdev==wifiDevA&&apgn2cfg==""?sec:apgn2cfg}else{apcfg=secmode=="ap"&&secdev!=wifiDevA&&apcfg==""?sec:apcfg;ap2cfg=secmode=="ap"&&secdev==wifiDevA&&ap2cfg==""?sec:ap2cfg;othercfg=secmode!="ap"&&secmode!="wds"&&othercfg==""?sec:othercfg;otherdev=secmode!="ap"&&secmode!="wds"&&otherdev==""?secdev:otherdev}}var apgcfg=apcfg;var apacfg=ap2cfg;var apgngcfg=apgncfg;var apgnacfg=apgn2cfg;apgncfg=apgncfg!=""||apgncfg==""&&apgn2cfg==""?apgncfg:apgn2cfg;var apcfgBand=apcfg!=""||ap2cfg!=""?"G":"";if(apgcfg==""&&apacfg!=""){apcfg=ap2cfg;ap2cfg="";apcfgBand="A"}if(GwifiN||AwifiN||AwifiAC){var hwGmode=uciOriginal.get("wireless",wifiDevG,"hwmode");hwGmode=hwGmode==""?"11g":hwGmode;setAllowableSelections("wifi_hwmode",["disabled","11gn","11g"],[UI.Disabled,"B+G+N","B+G"]);setSelectedValue("wifi_hwmode",hwGmode);if(dualBandWireless){if(AwifiAC){setAllowableSelections("wifi_hwmode_5ghz",["disabled","11anac","11an","11a"],[UI.Disabled,"A+N+AC","A+N","A"])}else if(AwifiN){setAllowableSelections("wifi_hwmode_5ghz",["disabled","11an","11a"],[UI.Disabled,"A+N","A"])}else{setAllowableSelections("wifi_hwmode_5ghz",["disabled","11a"],[UI.Disabled,"A"])}hwAmode=uciOriginal.get("wireless",wifiDevA,"hwmode");setSelectedValue("wifi_hwmode_5ghz",hwAmode)}dualMode=hwGmode!="disabled"&&hwAmode!="disabled";if(hwGmode=="disabled"){hwdualMode=hwAmode;if(dualMode==false){setAllowableSelections("wifi_hwmode",["disabled"],[UI.Disabled])}}else{hwdualMode=hwGmode;if(dualMode==false){setAllowableSelections("wifi_hwmode_5ghz",["disabled"],[UI.Disabled])}}setSelectedValue("bridge_hwmode",dualMode==true?hwGmode:hwdualMode);if(dualBandWireless&&otherdev!=""){setSelectedValue("wifi_client_band",otherdev==wifiDevA?"5":"2.4")}var htGMode=uciOriginal.get("wireless",wifiDevG,"htmode");var htAMode=uciOriginal.get("wireless",wifiDevA,"htmode");if(htGMode!="NONE"&&htGMode!=""&&(otherdev==""||otherdev==wifiDevG)){setSelectedValue("wifi_hwmode","11gn");setSelectedValue("bridge_hwmode","11gn")}else if((htGMode==""||htGMode=="NONE")&&(otherdev==""||otherdev==wifiDevG)){setSelectedValue("wifi_hwmode","11g");setSelectedValue("bridge_hwmode","11g")}else if(htGMode!=""&&htGMode!="NONE"&&otherdev!=wifiDevG){setSelectedValue("wifi_hwmode","11gn")}else if(htGMode==""||htGMode=="NONE"&&otherdev!=wifiDevG){setSelectedValue("wifi_hwmode","11g")}if(htAMode!="NONE"&&htAMode!=""&&(otherdev==""||otherdev==wifiDevA)){setSelectedValue("wifi_hwmode_5ghz","11an");setSelectedValue("bridge_hwmode","11an");if(/VHT/i.test(htAMode)){setSelectedValue("wifi_hwmode_5ghz","11anac");setSelectedValue("bridge_hwmode","11anac")}}else if((htAMode==""||htAMode=="NONE")&&(otherdev==""||otherdev==wifiDevA)){setSelectedValue("wifi_hwmode_5ghz","11a");setSelectedValue("bridge_hwmode","11a")}else if(htAMode!=""&&htAMode!="NONE"&&otherdev!=wifiDevA){setSelectedValue("wifi_hwmode_5ghz","11an");if(/VHT/i.test(htAMode)){setSelectedValue("wifi_hwmode_5ghz","11anac")}}else if(htAMode==""||htAMode=="NONE"&&otherdev!=wifiDevA){setSelectedValue("wifi_hwmode_5ghz","11a")}setSelectedValue("wifi_channel_width",htGMode);setSelectedValue("wifi_channel_width_5ghz",htAMode);setSelectedValue("bridge_channel_width",htGMode);setSelectedValue("bridge_channel_width_5ghz",htAMode);setChannelWidth(document.getElementById("wifi_channel_width"),"G");setChannelWidth(document.getElementById("wifi_channel_width_5ghz"),"A");document.getElementById("bridge_channel_width_container").style.display="block"}else{document.getElementById("bridge_channel_width_container").style.display="none";hwGmode=uciOriginal.get("wireless",wifiDevG,"hwmode");hwAmode=uciOriginal.get("wireless",wifiDevA,"hwmode");setSelectedValue("wifi_hwmode",hwGmode);setSelectedValue("wifi_hwmode_5ghz",hwAmode)}var wirelessIds=["wifi_channel1","wifi_channel2","wifi_channel1_5ghz","wifi_channel2_5ghz","wifi_ssid1","wifi_ssid1a","wifi_encryption1","wifi_pass1","wifi_wep1","wifi_guest_ssid1","wifi_guest_mac_g","wifi_guest_ssid1a","wifi_guest_mac_a","wifi_guest_encryption1","wifi_guest_pass1","wifi_guest_wep1","wifi_server1","wifi_port1","wifi_ssid2","wifi_encryption2","wifi_pass2","wifi_wep2"];var wirelessPkgs=new Array;var wIndex;for(wIndex=0;wIndex<wirelessIds.length;wIndex++){wirelessPkgs.push("wireless")}var default5ID=uciOriginal.get("wireless",apcfg,"ssid")?uciOriginal.get("wireless",apcfg,"ssid")+" 5GHz":"Gargoyle 5GHz";var defaultGuest5ID=apgncfg&&uciOriginal.get("wireless",apgncfg,"ssid")?uciOriginal.get("wireless",apgncfg,"ssid")+" 5GHz":"Guests 5GHz";var wirelessSections=[wifiDevG,wifiDevG,wifiDevA,wifiDevA,apgcfg,apacfg,apcfg,apcfg,apcfg,apgngcfg,apgngcfg,apgnacfg,apgnacfg,apgncfg,apgncfg,apgncfg,apcfg,apcfg,othercfg,othercfg,othercfg,othercfg];var wirelessOptions=["channel","channel","channel","channel","ssid","ssid","encryption","key","key","ssid","macaddr","ssid","macaddr","encryption","key","key","auth_server","auth_port","ssid","encryption","key","key"];var wirelessParams=["5","5","36","36","Gargoyle",default5ID,"none","","","Guests","",defaultGuest5ID,"","none","","","","","ExistingWireless","none","",""];var wirelessFunctions=[lsv,lsv,lsv,lsv,lv,lv,lsv,lv,lv,lv,lv,lv,lv,lsv,lv,lv,lv,lv,lv,lsv,lv,lv];loadVariables(uciOriginal,wirelessIds,wirelessPkgs,wirelessSections,wirelessOptions,wirelessParams,wirelessFunctions);setSelectedValue("wifi_hidden",uciOriginal.get("wireless",apcfg,"hidden")==1?"disabled":"enabled");setSelectedValue("wifi_isolate",uciOriginal.get("wireless",apcfg,"isolate")==1?"enabled":"disabled");var gmvalues=["disabled"];var gmnames=[UI.Disabled];if(hwGmode!="disabled"&&hwAmode!="disabled"){gmvalues.push("dual");gmnames.push(UI.Enabled);gmvalues.push("24ghz");gmnames.push(basicS.F24GHzOnly);gmvalues.push("5ghz");gmnames.push(basicS.F5GHzOnly)}else if(hwGmode=="disabled"){gmvalues.push("5ghz");gmnames.push(UI.Enabled)}else{gmvalues.push("24ghz");gmnames.push(UI.Enabled)}setAllowableSelections("wifi_guest_mode",gmvalues,gmnames);if(apgncfg!=""){if(dualMode==true&&apgngcfg==""){setSelectedValue("wifi_guest_mode","5ghz")}else if(dualMode==true&&apgnacfg==""){setSelectedValue("wifi_guest_mode","24ghz")}else{setSelectedText("wifi_guest_mode",UI.Enabled)}}else{setSelectedValue("wifi_guest_mode","disabled")}setSelectedValue("wifi_guest_hidden",uciOriginal.get("wireless",apgncfg,"hidden")==1?"disabled":"enabled");setSelectedValue("wifi_guest_isolate",!apgncfg||uciOriginal.get("wireless",apgncfg,"isolate")==1?"enabled":"disabled");var initTxPwr=function(sel_id,txt_id,dev,band){var txpwr=uciOriginal.get("wireless",dev,"txpower");var selMax=txpwr==""?"max":"custom";setSelectedValue(sel_id,selMax);if(selMax=="custom"){document.getElementById(txt_id).value=txpwr}updateTxPower(sel_id,txt_id,band)};initTxPwr("wifi_max_txpower","wifi_txpower",wifiDevG,"G");if(wifiDevA!=""){initTxPwr("wifi_max_txpower_5ghz","wifi_txpower_5ghz",wifiDevA,"A")}setSelectedValue("bridge_channel",uciOriginal.get("wireless",wifiDevG,"channel"));setSelectedValue("mac_filter_enabled","disabled");var macListStr="";var policy="";if(wirelessDriver=="broadcom"){policy=uciOriginal.get("wireless",wifiDevG,policyOption);macListStr=uciOriginal.get("wireless",wifiDevG,"maclist");setSelectedValue("mac_filter_enabled",(policy=="allow"||policy=="deny"||policy=="1"||policy=="2")&&macListStr!=""?"enabled":"disabled")}else{for(wsecIndex=0;wsecIndex<allWirelessSections.length&&getSelectedValue("mac_filter_enabled")=="disabled";wsecIndex++){macListStr=uciOriginal.get("wireless",allWirelessSections[wsecIndex],"maclist");if(macListStr!=""){policy=uciOriginal.get("wireless",allWirelessSections[wsecIndex],policyOption);setSelectedValue("mac_filter_enabled","enabled")}}}if(policy=="1"||policy=="deny"){setSelectedValue("mac_filter_policy","deny")}else{setSelectedValue("mac_filter_policy","allow")}macList=macListStr.split(/[;,\t ]+/);macTableData=[];if(macListStr.match(/:/)){for(macIndex=0;macIndex<macList.length;macIndex++){macTableData.push([macList[macIndex]])}}macTable=createTable([""],macTableData,"mac_table",true,false);tableContainer=document.getElementById("mac_table_container");if(tableContainer.firstChild!=null){tableContainer.removeChild(tableContainer.firstChild)}tableContainer.appendChild(macTable);encryptNum=1;while(encryptNum<=2){encMode=document.getElementById("wifi_encryption"+encryptNum).value;if(encMode=="wep"){document.getElementById("wifi_pass"+encryptNum).value=""}else if(encMode!="none"){document.getElementById("wifi_wep"+encryptNum).value=""}else{document.getElementById("wifi_pass"+encryptNum).value="";document.getElementById("wifi_wep"+encryptNum).value=""}encryptNum++}var wifiWdsData=[];if(apcfg!=""){var sectionIndex=0;for(sectionIndex=0;sectionIndex<allWirelessSections.length;sectionIndex++){if(wirelessDriver=="broadcom"){if(uciOriginal.get("wireless",allWirelessSections[sectionIndex],"mode")=="wds"){wifiWdsData.push([uciOriginal.get("wireless",allWirelessSections[sectionIndex],"bssid").toUpperCase()]);setSelectedValue("wifi_mode","ap+wds")}}}}var wifiWdsMacTable=createTable([""],wifiWdsData,"wifi_wds_mac_table",true,false);var wifiWdsTableContainer=document.getElementById("wifi_wds_mac_table_container");if(wifiWdsTableContainer.firstChild!=null){wifiWdsTableContainer.removeChild(wifiWdsTableContainer.firstChild)}wifiWdsTableContainer.appendChild(wifiWdsMacTable);var originalGmode=uciOriginal.get("wireless","ap_g");var originalAmode=uciOriginal.get("wireless","ap_a");if(originalGmode==""){setSelectedValue("wifi_hwmode","disabled")}if(originalAmode==""){setSelectedValue("wifi_hwmode_5ghz","disabled")}resetWirelessMode();proofreadAll();setBridgeVisibility();showApn();updateApnDetails()}function updateApnDetails(){mobile_isp=getSelectedValue("wan_3g_isp");if(mobile_isp=="custom"){setElementEnabled(document.getElementById("wan_3g_apn"),true,document.getElementById("wan_3g_apn").value);setElementEnabled(document.getElementById("wan_3g_user"),true,document.getElementById("wan_3g_user").value);setElementEnabled(document.getElementById("wan_3g_pass"),true,document.getElementById("wan_3g_pass").value)}else{for(apnIndex=0;apnIndex<apns.length;apnIndex++){if(mobile_isp==apns[apnIndex][0]){setElementEnabled(document.getElementById("wan_3g_apn"),false,apns[apnIndex][1]);setElementEnabled(document.getElementById("wan_3g_user"),false,apns[apnIndex][2]);setElementEnabled(document.getElementById("wan_3g_pass"),false,apns[apnIndex][3]);document.getElementById("wan_3g_pass").value=apns[apnIndex][3];break}}}}function setChannel(selectElement){var selectedValue=getSelectedValue(selectElement.id);if(selectElement.id.match("5ghz")){setSelectedValue("wifi_channel1_5ghz",selectedValue);setSelectedValue("wifi_channel2_5ghz",selectedValue);setSelectedValue("bridge_channel_5ghz",selectedValue);updateTxPower("wifi_max_txpower_5ghz","wifi_txpower_5ghz","A");dfsChan=selectedValue>=52&&selectedValue<=144?true:false;document.getElementById("wifi_channel1_5ghz_dfs").style.display=dfsChan==true?"block":"none";document.getElementById("wifi_channel2_5ghz_dfs").style.display=dfsChan==true?"block":"none";document.getElementById("bridge_channel_5ghz_dfs").style.display=dfsChan==true?"block":"none"}else{setSelectedValue("wifi_channel1",selectedValue);setSelectedValue("wifi_channel2",selectedValue);setSelectedValue("bridge_channel",selectedValue);updateTxPower("wifi_max_txpower","wifi_txpower","G")}}function resetWirelessMode(){setSelectedValue("wifi_mode",getWirelessMode(uciOriginal))}function validateWep(text){return validateHex(text)==0&&(text.length==10||text.length==26)?0:1}function proofreadWep(input){proofreadText(input,validateWep,0)}function addTextToSingleColumnTable(textId,tableContainerId,validator,preprocessor,validReturn,duplicatesAllowed,columnName){var val=document.getElementById(textId).value;if(validator(val)!=validReturn){alert(basicS.SpcEr1+" "+columnName+" "+basicS.SpcEr2)}else{val=preprocessor(val);var singleTable=document.getElementById(tableContainerId).firstChild;var singleTableData=getTableDataArray(singleTable,true,false);var inTable=false;var tabIndex=0;for(tabIndex=0;tabIndex<singleTableData.length;tabIndex++){var test=singleTableData[tabIndex];inTable=inTable||val==test[0]}if(inTable&&!duplicatesAllowed){alert(basicS.DplErr+" "+columnName)}else{addTableRow(singleTable,[val],true,false,null,null);document.getElementById(textId).value=""}}}function setDnsSource(selectEl){var dnsSrc=getSelectedValue(selectEl.id);var bridgeSrc=dnsSrc=="custom"?"custom":"gateway";var lanSrc=dnsSrc=="gateway"?"isp":dnsSrc;setSelectedValue("lan_dns_source",lanSrc);setSelectedValue("bridge_dns_source",bridgeSrc);document.getElementById("lan_dns_custom_container").style.display=dnsSrc=="custom"?"block":"none";document.getElementById("bridge_dns_custom_container").style.display=dnsSrc=="custom"?"block":"none"}function addDns(section){var textId="add_"+section+"_dns";addIp=document.getElementById(textId).value;addTextToSingleColumnTable(textId,"lan_dns_table_container",validateIP,function(str){return str},0,false,"IP");if(addIp!=""&&document.getElementById(textId).value==""){document.getElementById(textId).value=addIp;addTextToSingleColumnTable("add_"+section+"_dns","bridge_dns_table_container",validateIP,function(str){return str},0,false,"IP")}}function addMacToWds(section){var textId="add_"+section+"_wds_mac";var tableContainerId=section+"_wds_mac_table_container";addTextToSingleColumnTable(textId,tableContainerId,validateMac,function(str){return str.toUpperCase()},0,false,"MAC")}function addMacToFilter(){addTextToSingleColumnTable("add_mac","mac_table_container",validateMac,function(str){return str.toUpperCase()},0,false,"MAC")}function scanWifi(ssidField){setControlsEnabled(false,true,basicS.ScnWt);var param=getParameterDefinition("hash",document.cookie.replace(/^.*hash=/,"").replace(/[\t ;]+.*$/,""));var stateChangeFunction=function(req){if(req.readyState==4){scannedSsids=parseWifiScan(req.responseText);if(scannedSsids[0].length>0){var oldSsid=document.getElementById(ssidField).value;document.getElementById("wifi_custom_ssid2").value=oldSsid;document.getElementById("bridge_custom_ssid").value=oldSsid;var ssidDisplay=[];var ssidValue=[];var ssidIndex=0;for(ssidIndex=0;ssidIndex<scannedSsids[0].length;ssidIndex++){var ssid=scannedSsids[0][ssidIndex];var enc=scannedSsids[1][ssidIndex];var qual=scannedSsids[3][ssidIndex];enc=enc=="none"?"Open":enc.replace(/psk/g,"wpa").toUpperCase();if((GwifiN||AwifiN||AwifiAC)&&dualBandWireless){var ghz=scannedSsids[4][ssidIndex]=="A"?"5GHz":"2.4GHz";ssidDisplay.push(ssid+" ("+enc+", "+qual+"% Signal, "+ghz+")")}else{ssidDisplay.push(ssid+" ("+enc+", "+qual+"% "+basicS.Sgnl+")")}ssidValue.push(ssidIndex+"")}ssidDisplay.push(basicS.Other);ssidValue.push("custom");setAllowableSelections("wifi_list_ssid2",ssidValue,ssidDisplay);setAllowableSelections("bridge_list_ssid",ssidValue,ssidDisplay);var matchIndex=-1;var testIndex;var oldVal=document.getElementById(ssidField).value;for(testIndex=0;testIndex<scannedSsids[0].length&&matchIndex<0;testIndex++){matchIndex=scannedSsids[0][testIndex]==oldVal?testIndex:matchIndex}if(matchIndex<0){matchIndex=oldVal=="Gargoyle"||oldVal=="OpenWrt"||oldVal==""?"0":"custom"}setSelectedValue("wifi_list_ssid2",matchIndex+"");setSelectedValue("bridge_list_ssid",matchIndex+"")}else{alert(basicS.NoWLAN)}setSsidVisibility("wifi_list_ssid2");setControlsEnabled(true)}};runAjax("POST","utility/scan_wifi.sh",param,stateChangeFunction)}function setSsidVisibility(selectId){var visIds=["bridge_list_ssid_container","bridge_custom_ssid_container","bridge_ssid_container","bridge_channel_container","bridge_fixed_channel_container","bridge_encryption_container","bridge_fixed_encryption_container","wifi_list_ssid2_container","wifi_custom_ssid2_container","wifi_ssid2_container","wifi_channel2_container","wifi_fixed_channel2_container","wifi_encryption2_container","wifi_fixed_encryption2_container","wifi_channel1_container","wifi_fixed_channel1_container","wifi_pass2_container","wifi_wep2_container","bridge_pass_container","bridge_wep_container"];var isAp=getSelectedValue("wifi_mode").match(/ap/)&&document.getElementById("global_gateway").checked?1:0;if(scannedSsids[0].length>0){var scannedIndex=getSelectedValue(selectId);setSelectedValue("bridge_list_ssid",scannedIndex);setSelectedValue("wifi_list_ssid2",scannedIndex);document.getElementById("wifi_hwmode").disabled=0;document.getElementById("wifi_hwmode_5ghz").disabled=0;var ic=scannedIndex=="custom"?1:0;var inc=ic==0?1:0;if(inc){scannedIndex=parseInt(scannedIndex);var enc=scannedSsids[1][scannedIndex];var chan=scannedSsids[2][scannedIndex];var band=scannedSsids[4][scannedIndex];if(GwifiN){var modes=["11gn","11g"];var mnames=["B+G+N","B+G"]}else{var modes=["11g"];var mnames=["B+G"]}if(band=="A"){modes.unshift("disabled");mnames.unshift(UI.Disabled);document.getElementById("wifi_hwmode").disabled=1}else{setAllowableSelections("bridge_hwmode",modes,mnames)}setAllowableSelections("wifi_hwmode",modes,mnames);document.getElementById("wifi_hwmode").selectedIndex=0;if(dualBandWireless){if(AwifiAC){var modes=["11anac","11an","11a"];var mnames=["A+N+AC","A+N","A"]}else if(AwifiN){var modes=["11an","11a"];var mnames=["A+N","A"]}else{var modes=["11a"];var mnames=["A"]}if(band=="G"){modes.unshift("disabled");mnames.unshift(UI.Disabled);document.getElementById("wifi_hwmode_5ghz").disabled=1}else{setAllowableSelections("bridge_hwmode",modes,mnames)}setAllowableSelections("wifi_hwmode_5ghz",modes,mnames);document.getElementById("wifi_hwmode_5ghz").selectedIndex=0}setSelectedValue("wifi_encryption2",enc);setSelectedValue("bridge_encryption",enc);var enc=getSelectedText("wifi_encryption2");setChildText("wifi_fixed_encryption2",enc);setChildText("bridge_fixed_encryption",enc);var chanEl1="wifi_channel1"+(band=="A"?"_5ghz":"");var chanEl2="wifi_channel2"+(band=="A"?"_5ghz":"");var chanElB="bridge_channel"+(band=="A"?"_5ghz":"");setSelectedValue(chanEl1,chan);setSelectedValue(chanEl2,chan);setSelectedValue(chanElB,chan);setChildText("wifi_fixed_channel1",chan);setChildText("wifi_fixed_channel2",chan);setChildText("bridge_fixed_channel",chan)}var be=getSelectedValue("bridge_encryption");var we=getSelectedValue("wifi_encryption2");var bp=be.match(/psk/)||be.match(/WPA/)?1:0;var bw=be.match(/wep/)||be.match(/WEP/)?1:0;var wp=we.match(/psk/)||we.match(/WPA/)?1:0;var ww=we.match(/wep/)||we.match(/WEP/)?1:0;setVisibility(visIds,[1,ic,0,ic,inc,ic,inc,1,ic,0,ic,inc,ic,inc,ic*isAp,inc*isAp,wp,ww,bp,bw])}else{var be=getSelectedValue("bridge_encryption");var we=getSelectedValue("wifi_encryption2");var bp=be.match(/psk/)||be.match(/WPA/)?1:0;var bw=be.match(/wep/)||be.match(/WEP/)?1:0;var wp=we.match(/psk/)||we.match(/WPA/)?1:0;var ww=we.match(/wep/)||we.match(/WEP/)?1:0;setVisibility(visIds,[0,0,1,1,0,1,0,0,0,1,1,0,1,0,isAp,0,wp,ww,bp,bw])}if(ic){modes=[];mnames=[];for(x=0;x<document.getElementById("wifi_hwmode").length;x++){selection=document.getElementById("wifi_hwmode");modes[x]=selection.options[x].value;mnames[x]=selection.options[x].text}if(modes[0]!="disabled"){modes.unshift("disabled");mnames.unshift(UI.Disabled)}if(!dualBandWireless){modes.shift();mnames.shift()}setAllowableSelections("wifi_hwmode",modes,mnames);document.getElementById("wifi_hwmode").selectedIndex=1;if(dualBandWireless){modes=[];mnames=[];for(x=0;x<document.getElementById("wifi_hwmode_5ghz").length;x++){selection=document.getElementById("wifi_hwmode_5ghz");modes[x]=selection.options[x].value;mnames[x]=selection.options[x].text}if(modes[0]!="disabled"){modes.unshift("disabled");mnames.unshift(UI.Disabled)}setAllowableSelections("wifi_hwmode_5ghz",modes,mnames);document.getElementById("wifi_hwmode_5ghz").selectedIndex=1}var allowedbridgemodes=[];var allowedbridgemodes2=[];if(dualBandWireless){if(GwifiN){allowedbridgemodes.push("B+G+N");allowedbridgemodes2.push("11gn")}allowedbridgemodes.push("B+G");allowedbridgemodes2.push("11g");if(AwifiAC){allowedbridgemodes.push("A+N+AC");allowedbridgemodes2.push("11anac")}if(AwifiN){allowedbridgemodes.push("A+N");allowedbridgemodes2.push("11an")}allowedbridgemodes.push("A");allowedbridgemodes2.push("11a")}else{if(GwifiN){allowedbridgemodes.push("B+G+N");allowedbridgemodes2.push("11gn")}allowedbridgemodes.push("B+G");allowedbridgemodes2.push("11g")}setAllowableSelections("bridge_hwmode",allowedbridgemodes2,allowedbridgemodes)}setHwMode(document.getElementById("wifi_hwmode"));if(getSelectedValue("wifi_mode")=="ap+sta"){document.getElementById("wifi_hwmode").disabled=0;document.getElementById("wifi_hwmode_5ghz").disabled=0}}function parseWifiScan(rawScanOutput){adjScanOutput=rawScanOutput.replace(/Quality/g,"\n          Quality");adjScanOutput=adjScanOutput.replace(/Channel/g,"\n          Channel");var parsed=[[],[],[],[],[]];var cells=adjScanOutput.split(/Cell/);cells.shift();var getCellValues=function(id,cellLines){var vals=[];var lineIndex;for(lineIndex=0;lineIndex<cellLines.length;lineIndex++){var line=cellLines[lineIndex];var idIndex=line.indexOf(id);var cIndex=line.indexOf(":");var eqIndex=line.indexOf("=");var splitIndex=cIndex;if(splitIndex<0||eqIndex>=0&&eqIndex<splitIndex){splitIndex=eqIndex}if(idIndex>=0&&splitIndex>idIndex){var val=line.substr(splitIndex+1);val=val.replace(/^[^\"]*\"/g,"");val=val.replace(/\".*$/g,"");vals.push(val)}}return vals};while(cells.length>0){var cellData=cells.shift();var cellLines=cellData.split(/[\r\n]+/);var ssid=getCellValues("ESSID",cellLines).shift();var channel=getCellValues("Channel",cellLines).shift();var qualStr=getCellValues("Quality",cellLines).shift();var encStr=getCellValues("Encryption",cellLines).shift();if(ssid!=null&&channel!=null&&qualStr!=null&&encStr!=null){var enc="psk2";if(encStr.match(/WPA2 PSK/)){enc="psk2"}else if(encStr.match(/WPA PSK/)){enc="psk"}else if(encStr.match(/WEP/)){enc="wep"}else if(encStr.match(/none/)){enc="none"}var splitQual=qualStr.replace(/[\t ]+Sig.*$/g,"").split(/\//);var quality=Math.round(parseInt(splitQual[0])*100/parseInt(splitQual[1]));quality=quality>100?100:quality;parsed[0].push(ssid);parsed[1].push(enc);parsed[2].push(channel);parsed[3].push(quality);parsed[4].push(channel>30?"A":"G")}}var qualityIndices=[];var qIndex;for(qIndex=0;qIndex<parsed[3].length;qIndex++){qualityIndices.push([qIndex,parsed[3][qIndex]])}var sortQuality=function(q1,q2){return q2[1]-q1[1]};qualityIndices=qualityIndices.sort(sortQuality);var sortedParsed=[[],[],[],[],[]];while(qualityIndices.length>0){var i=qualityIndices.shift()[0];var pIndex;for(pIndex=0;pIndex<5;pIndex++){sortedParsed[pIndex].push(parsed[pIndex][i])}}return sortedParsed}function setChannelWidth(selectCtl,band){if(wirelessDriver==""){return}var chw=getSelectedValue(selectCtl.id);var hplus=chw=="HT40+";var h40=chw=="HT40+"||chw=="HT40-";var vht=chw=="VHT20"||chw=="VHT40"||chw=="VHT80"||chw=="VHT160";if(band=="G"){setSelectedValue("wifi_channel_width",getSelectedValue(selectCtl.id));setSelectedValue("bridge_channel_width",getSelectedValue(selectCtl.id));setAllowableSelections("bridge_channel",mac80211Channels["G"],mac80211Channels["G"],document);setAllowableSelections("wifi_channel1",mac80211Channels["G"],mac80211Channels["G"],document);setAllowableSelections("wifi_channel2",mac80211Channels["G"],mac80211Channels["G"],document);var removeChannels=[];var rIndex=1;for(rIndex=1;rIndex<=4&&h40;rIndex++){removeChannels.push(hplus?mac80211Channels["G"][mac80211Channels["G"].length-rIndex]:rIndex)}while(removeChannels.length>0){var rc=removeChannels.shift();removeOptionFromSelectElement("bridge_channel",rc,document);removeOptionFromSelectElement("wifi_channel1",rc,document);removeOptionFromSelectElement("wifi_channel2",rc,document)}updateTxPower("wifi_max_txpower","wifi_txpower","G")}else if(band=="A"&&mac80211Channels["A"]!=null){var origAChan=mac80211Channels["A"];var aChannels=origAChan;if(h40){aChannels=[];var validAPlus=[36,44,52,60,100,108,116,124,132,140,149,157];var validAMinus=[40,48,56,64,104,112,120,128,136,144,153,161];var validTest=hplus?arrToHash(validAPlus):arrToHash(validAMinus);for(var chanIndex=0;chanIndex<origAChan.length;chanIndex++){var ch=origAChan[chanIndex];if(validTest[ch]==1){aChannels.push(ch)}}}else if(vht&&chw!="VHT20"){aChannels=[];var valid40=[36,44,52,60,100,108,116,124,132,140,149,157];var valid80=[36,52,100,116,132,149];var valid160=[36,100];if(chw=="VHT40"){var validTest=arrToHash(valid40);for(var chanIndex=0;chanIndex<origAChan.length;chanIndex++){var ch=origAChan[chanIndex];if(validTest[ch]==1){aChannels.push(ch)}}}else if(chw=="VHT80"){var validTest=arrToHash(valid80);for(var chanIndex=0;chanIndex<origAChan.length;chanIndex++){var ch=origAChan[chanIndex];if(validTest[ch]==1){aChannels.push(ch)}}}else if(chw=="VHT160"){var validTest=arrToHash(valid160);for(var chanIndex=0;chanIndex<origAChan.length;chanIndex++){var ch=origAChan[chanIndex];if(validTest[ch]==1){aChannels.push(ch)}}}}setAllowableSelections("wifi_channel1_5ghz",aChannels,aChannels,document);setAllowableSelections("wifi_channel2_5ghz",aChannels,aChannels,document);setAllowableSelections("bridge_channel_5ghz",aChannels,aChannels,document);updateTxPower("wifi_max_txpower_5ghz","wifi_txpower_5ghz","A")}}function getSelectedWifiChannels(){var channels=[];channels["A"]="";channels["G"]="";if(wirelessDriver==""){return channels}if(document.getElementById("global_gateway").checked){var wimode=getSelectedValue("wifi_mode");var wifiGSelected=true;var wifiASelected=false;var dualBandSelected=false;if(document.getElementById("wifi_hwmode_container").style.display=="block"){wifiASelected=getSelectedValue("wifi_hwmode_5ghz")=="disabled"?"false":"true";wifiGSelected=getSelectedValue("wifi_hwmode")=="disabled"?"false":"true";dualBandSelected=wifiGSelected==true&&wifiASelected==true}var fixedChannels=scannedSsids[0].length>0&&wimode.match(/sta/);var ssidIndex=getSelectedValue("wifi_list_ssid2");fixedChannels=fixedChannels&&ssidIndex!="custom";if(fixedChannels){var fixedChannel=scannedSsids[2][parseInt(ssidIndex)].trim();var fixedBand=scannedSsids[4][parseInt(ssidIndex)];channels[fixedBand]=fixedChannel;if(dualBandSelected){var otherBand=fixedBand=="G"?"A":"G";var otherSelectId=otherBand=="G"?"wifi_channel1":"wifi_channel1_5ghz";channels[otherBand]=getSelectedValue(otherSelectId).trim()}}if(!fixedChannels){if(wifiGSelected){channels["G"]=getSelectedValue("wifi_channel1")}if(wifiASelected){channels["A"]=getSelectedValue("wifi_channel1_5ghz")}}}else{var bridgeModeA=getSelectedValue("bridge_hwmode");var bridgeModeA=!String(bridgeModeA).match(/11g/);if(bridgeModeA){channels["A"]=document.getElementById("bridge_fixed_channel_container").style.display!="none"?document.getElementById("bridge_fixed_channel").firstChild.data.trim():getSelectedValue("bridge_channel_5ghz").trim()}else{channels["G"]=document.getElementById("bridge_fixed_channel_container").style.display!="none"?document.getElementById("bridge_fixed_channel").firstChild.data.trim():getSelectedValue("bridge_channel").trim()}}return channels}function setHwMode(selectCtl){if(document.getElementById("wifi_hwmode_container").style.display=="none"&&document.getElementById("bridge_hwmode_container").style.display=="none"){return}hwGmode=getSelectedValue("wifi_hwmode");hwAmode=getSelectedValue("wifi_hwmode_5ghz");if(getSelectedValue("wifi_mode").match(/sta/)){if(hwGmode=="disabled"&&hwAmode=="disabled"){if(dualBandWireless&&selectCtl.id.match(/5ghz/g)){document.getElementById("wifi_hwmode").selectedIndex=1;hwGmode=getSelectedValue("wifi_hwmode")}else if(dualBandWireless){document.getElementById("wifi_hwmode_5ghz").selectedIndex=1;hwAmode=getSelectedValue("wifi_hwmode_5ghz")}else{document.getElementById("wifi_hwmode").selectedIndex=1;hwGmode=getSelectedValue("wifi_hwmode")}}if(selectCtl.id.match(/bridge/)){var allWirelessSections=uciOriginal.getAllSectionsOfType("wireless","wifi-iface");var seci=0;for(seci=0;seci<allWirelessSections.length;seci++){var sec=allWirelessSections[seci];var secmode=uciOriginal.get("wireless",sec,"mode");var secdev=uciOriginal.get("wireless",sec,"device");if(secmode=="sta"){HWMODE=uciOriginal.get("wireless",secdev,"hwmode");if(HWMODE=="11g"){hwGmode=uciOriginal.get("wireless",secdev,"htmode").match(/HT/)?"11gn":"11g";for(x=0;x<document.getElementById("wifi_hwmode").length;x++){if(hwGmode==document.getElementById("wifi_hwmode")[x].value){document.getElementById("wifi_hwmode").selectedIndex=x}}}else{hwAmode=uciOriginal.get("wireless",secdev,"htmode").match(/HT/)?"11an":"11a";hwAmode=uciOriginal.get("wireless",secdev,"htmode").match(/VHT/)?"11anac":hwAmode;for(x=0;x<document.getElementById("wifi_hwmode_5ghz").length;x++){if(hwAmode==document.getElementById("wifi_hwmode_5ghz")[x].value){document.getElementById("wifi_hwmode_5ghz").selectedIndex=x}}}}}}}if(getSelectedValue("wifi_mode").match(/^sta$/)){if(hwGmode!="disabled"&&hwAmode!="disabled"){if(dualBandWireless&&selectCtl.id.match(/5ghz/g)){document.getElementById("wifi_hwmode").selectedIndex=0;hwGmode=getSelectedValue("wifi_hwmode")}else{document.getElementById("wifi_hwmode_5ghz").selectedIndex=0;hwAmode=getSelectedValue("wifi_hwmode_5ghz")}}}dualMode=hwGmode!="disabled"&&hwAmode!="disabled";if(hwGmode=="disabled"){hwdualMode=hwAmode}else{hwdualMode=hwGmode}hwmode=dualMode==true&&document.getElementById("global_bridge").checked?hwGmode:hwdualMode;if(selectCtl.id=="bridge_hwmode"&&dualMode==false){setSelectedValue("wifi_hwmode",hwGmode)}bridgehwmode=getSelectedValue("bridge_hwmode");if(bridgehwmode.match(/11g/)&&document.getElementById("global_bridge").checked==true){hwGmode=bridgehwmode;hwAmode="disabled"}else if(document.getElementById("global_bridge").checked==true){hwGmode="disabled";hwAmode=bridgehwmode}document.getElementById("wifi_txpower_container").style.marginBottom="20px";document.getElementById("wifi_txpower_5ghz_container").style.marginBottom="20px";if(getSelectedValue("wifi_hwmode")=="disabled"){document.getElementById("wifi_hwmode_container").style.marginBottom="20px"}else{document.getElementById("wifi_hwmode_container").style.marginBottom="5px"}if(getSelectedValue("wifi_hwmode_5ghz")=="disabled"){document.getElementById("wifi_hwmode_5ghz_container").style.marginBottom="20px"}else{document.getElementById("wifi_hwmode_5ghz_container").style.marginBottom="5px"}if(hwGmode=="disabled"){setAllowableSelections("wifi_channel_width",["NONE"])}else if(hwGmode=="11g"){setAllowableSelections("wifi_channel_width",["NONE"],["20MHz"])}else{setAllowableSelections("wifi_channel_width",["HT20","HT40+","HT40-"],["20MHz","40MHz "+basicS.ChAbv,"40MHz "+basicS.ChBlw])}if(hwAmode=="disabled"){setAllowableSelections("wifi_channel_width_5ghz",["NONE"])}else if(hwAmode=="11a"){setAllowableSelections("wifi_channel_width_5ghz",["NONE"],["20MHz"])}else if(hwAmode=="11an"){setAllowableSelections("wifi_channel_width_5ghz",["HT20","HT40+","HT40-"],["20MHz","40MHz "+basicS.ChAbv,"40MHz "+basicS.ChBlw])}else{if(maxACwidth=="80"){setAllowableSelections("wifi_channel_width_5ghz",["VHT20","VHT40","VHT80"],["20MHz","40MHz","80MHz"])}else{setAllowableSelections("wifi_channel_width_5ghz",["VHT20","VHT40","VHT80","VHT160"],["20MHz","40MHz","80MHz","160MHz"])}}if(bridgehwmode=="11g"){setAllowableSelections("bridge_channel_width",["NONE"],["20MHz"])}else if(bridgehwmode=="11gn"){setAllowableSelections("bridge_channel_width",["HT20","HT40+","HT40-"],["20MHz","40MHz "+basicS.ChAbv,"40MHz "+basicS.ChBlw])}else if(bridgehwmode=="11a"){setAllowableSelections("bridge_channel_width_5ghz",["NONE"],["20MHz"])}else if(bridgehwmode=="11an"){setAllowableSelections("bridge_channel_width_5ghz",["HT20","HT40+","HT40-"],["20MHz","40MHz "+basicS.ChAbv,"40MHz "+basicS.ChBlw])}else{if(maxACwidth=="80"){setAllowableSelections("bridge_channel_width_5ghz",["VHT20","VHT40","VHT80"],["20MHz","40MHz","80MHz"])}else{setAllowableSelections("bridge_channel_width_5ghz",["VHT20","VHT40","VHT80","VHT160"],["20MHz","40MHz","80MHz","160MHz"])}}setChildText("wifi_ssid1a_label",dualMode==false?basicS.AcPt+" SSID:":"AP 5GHz SSID:");setChildText("wifi_channel1_5ghz_label",dualMode==false?basicS.WChn+":":basicS.WChn+" (5GHz):");setChildText("wifi_ssid1_label",dualMode==true?"AP 2.4GHz SSID:":basicS.AcPt+" SSID:");setChildText("wifi_channel1_label",dualMode==true?basicS.WChn+" (2.4GHz):":basicS.WChn+":");if(wirelessDriver=="mac80211"){setChannel(document.getElementById("wifi_channel1"),"G");if(dualMode==true||hwAmode!="disabled"){setChannel(document.getElementById("wifi_channel1_5ghz"),"A")}}var displayWidth=GwifiN;if(!displayWidth){setSelectedValue("wifi_channel_width","NONE");setChannelWidth(document.getElementById("wifi_channel_width"),"G")}displayWidth=AwifiN||AwifiAC;if(!displayWidth){setSelectedValue("wifi_channel_width_5ghz","NONE");setChannelWidth(document.getElementById("wifi_channel_width_5ghz"),"A")}displayWidth=GwifiN||AwifiN||AwifiAC;var containers=["wifi_channel_width_container","wifi_txpower_container","wifi_channel_width_5ghz_container","wifi_txpower_5ghz_container","wifi_ssid1a_container","wifi_ssid1_container","wifi_channel1_container","wifi_channel2_container","wifi_channel1_5ghz_container","wifi_channel2_5ghz_container","bridge_channel_width_container","bridge_channel_width_5ghz_container","bridge_txpower_container","bridge_txpower_5ghz_container","bridge_channel_container","bridge_channel_5ghz_container","wifi_guest_ssid1a_container","wifi_guest_ssid1_container"];var ci;var wimode=getSelectedValue("wifi_mode");var fixedChannels=scannedSsids[0].length>0&&(wimode.match(/sta/)||document.getElementById("global_bridge").checked);var fixedChannelBand="";if(fixedChannels){var ssidIndex=getSelectedValue("wifi_list_ssid2");fixedChannels=ssidIndex!="custom";if(fixedChannels){fixedChannelBand=scannedSsids[4][parseInt(ssidIndex)]}}if(selectCtl.id=="wifi_hwmode"){var gname=getSelectedText("wifi_guest_mode");var gval=getSelectedValue("wifi_guest_mode");var mvalues=["disabled"];var mnames=[UI.Disabled];if(dualMode==true){mvalues.push("dual");mnames.push(UI.Enabled);mvalues.push("24ghz");mnames.push(basicS.F24GHzOnly);mvalues.push("5ghz");mnames.push(basicS.F5GHzOnly);gval=gname==UI.Enabled?"dual":gval}else if(hwAmode!="disabled"){mvalues.push("5ghz");mnames.push(UI.Enabled);gval=gval!="disabled"?"5ghz":gval}else{mvalues.push("24ghz");mnames.push(UI.Enabled);gval=gval!="disabled"?"24ghz":gval}setAllowableSelections("wifi_guest_mode",mvalues,mnames);setSelectedValue("wifi_guest_mode",gval)}var gmode=getSelectedValue("wifi_guest_mode");setChildText("wifi_guest_ssid1a_label",dualMode==true&&gmode=="dual"?basicS.GNet5ID:basicS.GNetID);document.getElementById("wifi_ssid1a").value=document.getElementById("wifi_ssid1a").value==""?document.getElementById("wifi_ssid1").value+" 5GHz":document.getElementById("wifi_ssid1a").value;setChildText("wifi_guest_ssid1_label",dualMode==true&&gmode=="dual"?basicS.GNet24ID:basicS.GNetID);document.getElementById("wifi_guest_ssid1a").value=document.getElementById("wifi_guest_ssid1a").style.display=="block"&&document.getElementById("wifi_guest_ssid1a").value==""&&document.getElementById("wifi_guest_ssid1").value!=""?document.getElementById("wifi_guest_ssid1").value+" 5GHz":document.getElementById("wifi_guest_ssid1a").value;for(ci=0;ci<containers.length;ci++){var container=document.getElementById(containers[ci]);var cid=container.id;var isA=cid.match("5ghz")||cid.match(/a_/);var notA=!isA;var cBand=isA?"A":"G";var ap_only=cid.match(/1_/)||cid.match(/1a_/);var cli_only=cid.match(/2_/)||cid.match(/2a_/);var cli_ap_mismatch=ap_only&&!wimode.match(/ap/)||cli_only&&!wimode.match(/sta/);var hide_in_favor_of_fixed_channel=fixedChannels&&(cid.match(/channel/)&&!cid.match(/channel_width/))&&(!wimode.match(/ap/)||fixedChannelBand==cBand);var displayWithoutWidth=cid=="wifi_ssid1_container"||cid=="wifi_ssid1a_container"||cid=="wifi_txpower_container"||cid=="wifi_txpower_5ghz_container"||cid=="wifi_channel1_container"||cid=="wifi_channel2_container"||cid=="bridge_txpower_container"||cid=="bridge_channel_container"||cid=="wifi_guest_ssid1_container"||cid=="wifi_guest_ssid1a_container"||cid=="bridge_channel_5ghz_container"||cid=="bridge_txpower_5ghz_container"||cid=="wifi_channel1_5ghz_container"||cid=="wifi_channel2_5ghz_container";var isitbridge=1&&document.getElementById("global_bridge").checked;var bridgeModeA=getSelectedValue("bridge_hwmode");var bridgeModeA=!String(bridgeModeA).match(/11g/);var vis=(displayWidth||displayWithoutWidth)&&!cli_ap_mismatch&&!hide_in_favor_of_fixed_channel&&(isA&&(dualMode==true||hwAmode!="disabled")||notA&&hwGmode!="disabled")&&!(isA&&isitbridge==true&&bridgeModeA==false)&&!(notA&&isitbridge==true&&bridgeModeA==true)&&(!cid.match(/^wifi_guest_/)||gmode=="dual"||gmode=="5ghz"&&isA||gmode=="24ghz"&&!isA);container.style.display=vis?"block":"none"}document.getElementById("wifi_client_band_container").style.display=wimode=="ap+sta"&&dualMode==true?"block":"none";if(wimode=="ap+sta"&&dualMode==true){var cband=getSelectedValue("wifi_client_band");document.getElementById("wifi_client_band_container").style.display=!fixedChannels?"block":"none";document.getElementById("wifi_channel2_container").style.display=cband=="2.4"&&!fixedChannels?"block":"none";document.getElementById("wifi_channel2_5ghz_container").style.display=cband=="5"&&!fixedChannels?"block":"none"}channelG=getSelectedValue("wifi_channel1");channelA=getSelectedValue("wifi_channel1_5ghz");setChannelWidth(document.getElementById("wifi_channel_width"),"G");setChannelWidth(document.getElementById("wifi_channel_width_5ghz"),"A");setChannelWidth(document.getElementById("bridge_channel_width"),"G");setChannelWidth(document.getElementById("bridge_channel_width_5ghz"),"A");setSelectedValue("wifi_channel1",channelG);setSelectedValue("wifi_channel1_5ghz",channelA);if(hwGmode=="disabled"&&hwAmode=="disabled"){setSelectedValue("wifi_mode","disabled");setSelectedValue("wifi_hwmode","11g");setSelectedValue("wifi_hwmode_5ghz","11a");setSelectedValue("wifi_hwmode","11gn");setSelectedValue("wifi_hwmode_5ghz","11an");setSelectedValue("wifi_hwmode_5ghz","11anac");setWifiVisibility()}}function getMaxTxPower(band){var chMaxPwr=txPowerMax;if(wirelessDriver=="mac80211"){var ch=getSelectedValue(band=="A"?"wifi_channel1_5ghz":"wifi_channel1");var b=mac80211ChPwrs[band];var p=b==null?null:b[ch];chMaxPwr=p==null?chMaxPwr:p}return chMaxPwr}function updateTxPower(selectId,textId,band){var chMaxPwr=getMaxTxPower(band);var max=getSelectedValue(selectId);var atMax=max=="max";var dbm=document.getElementById(textId).value;var updateIds=[];updateIds["G"]=[["wifi_max_txpower","wifi_txpower","wifi_dbm"],["bridge_max_txpower","bridge_txpower","bridge_dbm"]];updateIds["A"]=[["wifi_max_txpower_5ghz","wifi_txpower_5ghz","wifi_dbm_5ghz"],["bridge_max_txpower_5ghz","bridge_txpower_5ghz","bridge_dbm_5ghz"]];var bandUpdateIds=updateIds[band];var idIndex=0;for(idIndex=0;idIndex<bandUpdateIds.length;idIndex++){sel=document.getElementById(bandUpdateIds[idIndex][0]);txt=document.getElementById(bandUpdateIds[idIndex][1]);lab=document.getElementById(bandUpdateIds[idIndex][2]);setSelectedValue(sel.id,max);setElementEnabled(txt,!atMax,""+chMaxPwr);txt.value=atMax||dbm>chMaxPwr?""+chMaxPwr:""+dbm;lab.firstChild.data="(0 - "+chMaxPwr+"dBm)";lab.style.color=atMax?"gray":"black"}}function renewDhcpLease(){var commands=[];commands.push("killall -SIGUSR1 udhcpc");commands.push("sleep 1");commands.push("wait_sec=10");commands.push("while [ $(uci -p /tmp/state get network.wan.ipaddr 2>/dev/null) == NULL ] && [ $wait_sec -gt 0 ] ; do");commands.push("sleep 1");commands.push("done");var param=getParameterDefinition("commands",commands.join("\n"))+"&"+getParameterDefinition("hash",document.cookie.replace(/^.*hash=/,"").replace(/[\t ;]+.*$/,""));setControlsEnabled(false,true,basicS.RnwL);var stateChangeFunction=function(req){if(req.readyState==4){setControlsEnabled(true);window.location.reload(true)}};runAjax("POST","utility/run_commands.sh",param,stateChangeFunction)}function releaseDhcpLease(){var commands=[];commands.push("killall -SIGUSR2 udhcpc");commands.push("uci -P /var/state set network.wan.ipaddr=''");commands.push("uci -P /var/state set network.wan.lease_lifetime=''");commands.push("uci -P /var/state set network.wan.lease_acquired=''");commands.push("uci -P /var/state set network.wan.gateway=''");commands.push("uci -P /var/state set network.wan.lease_server=''");commands.push("uci -P /var/state set network.wan.up=0");commands.push("uci commit");var param=getParameterDefinition("commands",commands.join("\n"))+"&"+getParameterDefinition("hash",document.cookie.replace(/^.*hash=/,"").replace(/[\t ;]+.*$/,""));setControlsEnabled(false,true,basicS.RlsL);setElementEnabled(document.getElementById("dhcp_release_button"),false);var stateChangeFunction=function(req){setChildText("dhcp_expires","");setChildText("dhcp_ip","");if(req.readyState==4){setTimeout(setControlsEnabled(true),2*1e3)}};runAjax("POST","utility/run_commands.sh",param,stateChangeFunction)}function singleEthernetIsWan(){return singleEthernetPort()&&document.getElementById("global_gateway").checked&&getSelectedValue("wan_protocol").match(/wired/)}function singleEthernetPort(){return defaultWanIf==""||defaultWanIf==defaultLanIf}function getAltServerDefs(currentAltDefs,currentRebindServers,altDefsEnabled){var defs=[];var domains=[];var definedTlds={};var setTlds={};var tldLists=[ncTlds,onTlds];var tli;var cadi;var crsi;for(tli=0;tli<tldLists.length;tli++){var tlds=tldLists[tli];var ti;for(ti=0;ti<tlds.length;ti++){definedTlds[tlds[ti]]=1}}for(cadi=0;cadi<currentAltDefs.length;cadi++){var def=currentAltDefs[cadi];var defTld=def.replace(/^\//,"").replace(/\/.*$/,"");if(definedTlds[defTld]==null){defs.push(def)}}for(crsi=0;crsi<currentRebindServers.length;crsi++){var defTld=currentRebindServers[crsi];if(definedTlds[defTld]==null){domains.push(defTld)}}function addDefsForAlt(tlds,dns){var ti;for(ti=0;ti<tlds.length;ti++){var t=tlds[ti];var di;for(di=0;di<dns.length;di++){defs.push("/"+t+"/"+dns[di]);if(setTlds[t]==null){domains.push(t);setTlds[t]=t}}}}if(altDefsEnabled){addDefsForAlt(ncTlds,ncDns);addDefsForAlt(onTlds,onDns)}return[defs,domains]}function set3GDevice(device){document.getElementById("wan_3g_device").value=device}function scan3GDevice(field){setControlsEnabled(false,true,basicS.ScnMo);var param=getParameterDefinition("hash",document.cookie.replace(/^.*hash=/,"").replace(/[\t ;]+.*$/,""));var stateChangeFunction=function(req){if(req.readyState==4){var scannedDevices=[];scannedDevices=req.responseText.split(/\n/);scannedDevices.pop();if(scannedDevices.length>0){setAllowableSelections(field,scannedDevices,scannedDevices);set3GDevice(getSelectedValue("wan_3g_list_device"));document.getElementById("wan_3g_device").style.display="none";document.getElementById("wan_3g_list_device").style.display="block"}else{alert(basicS.NoDv)}setControlsEnabled(true)}};runAjax("POST","utility/scan_3gdevices.sh",param,stateChangeFunction)}function updateService(){setSelectedValue("wan_3g_isp","custom");updateApnDetails();document.getElementById("wan_3g_user").value="";document.getElementById("wan_3g_pass").value="";showApn()}function showApn(){document.getElementById("wan_3g_apn_container").style.display=getSelectedValue("wan_3g_service")!="cdma"&&getSelectedValue("wan_protocol")=="3g"||getSelectedValue("wan_protocol")=="qmi"||getSelectedValue("wan_protocol")=="ncm"||getSelectedValue("wan_protocol")=="mbim"?"block":"none"}function getPingSection(){var ruleSections=uciOriginal.getAllSectionsOfType("firewall","rule");var ruleIndex;for(ruleIndex=0;ruleIndex<ruleSections.length;ruleIndex++){var section=ruleSections[ruleIndex];var icmp_type=uciOriginal.get("firewall",section,"icmp_type").toLowerCase();var family=uciOriginal.get("firewall",section,"family").toLowerCase();if(icmp_type=="echo-request"&&family=="ipv4"){return section}}}function togglePass(name){password_field=document.getElementById(name);if(password_field.type=="password"){password_field.type="text"}else{password_field.type="password"}}function randHexDigit(){return Math.floor(Math.random()*16).toString(16)}function getRandomMac(local,unicast){var macPairs=[];while(macPairs.length<6){if(macPairs.length==0){var secondDigit=randHexDigit();secondDigit=setNthBitToX("0x"+secondDigit,1,local?1:0);secondDigit=setNthBitToX("0x"+secondDigit,0,unicast?0:1);macPairs.push(randHexDigit()+secondDigit)}else{macPairs.push(randHexDigit()+randHexDigit())}}return macPairs.join(":")}function getRandomMacWithMask(local,unicast,ref,mask){ref=ref.toLowerCase();mask=mask.toLowerCase();var retVal=ref;while(retVal==ref){var macPairs=[];var randMac=getRandomMac(local,unicast);macPairs=randMac.split(":");if(ref=="00:00:00:00:00:00"||ref==""||ref==null){return randMac}if(mask=="00:00:00:00:00:00"||mask==""||mask==null){mask="fc:ff:ff:ff:ff:f0"}if(mask=="ff:ff:ff:ff:ff:ff"){return ref}var refPairs=[];var maskPairs=[];refPairs=ref.split(":");maskPairs=mask.split(":");for(x=0;x<6;x++){var macPair="0x"+macPairs[x];var refPair="0x"+refPairs[x];var maskPair="0x"+maskPairs[x];for(y=0;y<8;y++){if((maskPair&1<<y)!=0){macPair="0x"+setNthBitToX(macPair,y,refPair>>y&1)}}macPairs[x]=("0"+parseInt(macPair).toString(16)).slice(-2)}retVal=macPairs.join(":")}return retVal}function setNthBitToX(val,n,x){val=val&~(1<<n)|x<<n;return val.toString(16)}function parseCountry(countryLines){countryName=[];for(lineIndex=0;lineIndex<countryLines.length;lineIndex++){line=countryLines[lineIndex];if(!line.match(/^[\t]*#/)&&line.length>0){splitLine=line.split(/[\t]+/);name=stripQuotes(splitLine.pop());code=stripQuotes(splitLine.pop());countryName[code]=name}}return countryName}function checkWifiCountryVisibility(){if(typeof geo_countrycode==="undefined"||geo_countrycode===null){return false}else if(uciOriginal.get("wireless",uciWirelessDevs[0],"country")==""){var selOpt=countryName[geo_countrycode];if(selOpt==""){return false}else if(document.getElementById("wireless_country").length==1){removeAllOptionsFromSelectElement(document.getElementById("wireless_country"));removeAllOptionsFromSelectElement(document.getElementById("bridge_wireless_country"));addOptionToSelectElement("wireless_country",countryName["00"],"00");addOptionToSelectElement("bridge_wireless_country",countryName["00"],"00");addOptionToSelectElement("wireless_country",selOpt,geo_countrycode);addOptionToSelectElement("bridge_wireless_country",selOpt,geo_countrycode)}}if(document.getElementById("wireless_country").length==1){return false}return true}function syncWifiCountrySelection(elSelected){var selIdx=elSelected.selectedIndex;if(elSelected.id=="bridge_wireless_country"){document.getElementById("wireless_country").selectedIndex=selIdx}else{document.getElementById("bridge_wireless_country").selectedIndex=selIdx}}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top