1 2var keyPressed; 3var wItem; 4var ip = ""; 5 6// 2010.07 James. { 7function inet_network(ip_str){ 8 if(!ip_str) 9 return -1; 10 11 var re = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/; 12 if(re.test(ip_str)){ 13 var v1 = parseInt(RegExp.$1); 14 var v2 = parseInt(RegExp.$2); 15 var v3 = parseInt(RegExp.$3); 16 var v4 = parseInt(RegExp.$4); 17 18 if(v1 < 256 && v2 < 256 && v3 < 256 && v4 < 256) 19 return v1*256*256*256+v2*256*256+v3*256+v4; 20 } 21 22 return -2; 23} 24 25//Filtering ip address with leading zero, if end-user keyin IP 192.168.02.1, system auto filtering IP 192.168.2.1 26function ipFilterZero(ip_str){ 27 var re = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/; 28 if(re.test(ip_str)){ 29 var v1 = parseInt(RegExp.$1); 30 var v2 = parseInt(RegExp.$2); 31 var v3 = parseInt(RegExp.$3); 32 var v4 = parseInt(RegExp.$4); 33 return v1+"."+v2+"."+v3+"."+v4; 34 } 35 return -2; 36} 37 38function isMask(ip_str){ 39 if(!ip_str) 40 return 0; 41 42 var re = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/; 43 if(re.test(ip_str)){ 44 var v1 = parseInt(RegExp.$1); 45 var v2 = parseInt(RegExp.$2); 46 var v3 = parseInt(RegExp.$3); 47 var v4 = parseInt(RegExp.$4); 48 49 if(v4 == 255 || !(v4 == 0 || (is1to0(v4) && v1 == 255 && v2 == 255 && v3 == 255))) 50 return -4; 51 52 if(!(v3 == 0 || (is1to0(v3) && v1 == 255 && v2 == 255))) 53 return -3; 54 55 if(!(v2 == 0 || (is1to0(v2) && v1 == 255))) 56 return -2; 57 58 if(!is1to0(v1)) 59 return -1; 60 } 61 62 return 1; 63} 64 65function is1to0(num){ 66 if(typeof(num) != "number") 67 return 0; 68 69 if(num == 255 || num == 254 || num == 252 || num == 248 70 || num == 240 || num == 224 || num == 192 || num == 128) 71 return 1; 72 73 return 0; 74} 75 76function getSubnet(ip_str, mask_str, flag){ 77 var ip_num, mask_num; 78 var sub_head, sub_end; 79 80 if(!ip_str || !mask_str) 81 return -1; 82 83 if(isMask(mask_str) <= 0) 84 return -2; 85 86 if(!flag || (flag != "head" && flag != "end")) 87 flag = "head"; 88 89 ip_num = inet_network(ip_str); 90 mask_num = inet_network(mask_str); 91 92 if(ip_num < 0 || mask_num < 0) 93 return -3; 94 95 sub_head = ip_num-(ip_num&~mask_num); 96 sub_end = sub_head+~mask_num; 97 98 if(flag == "head") 99 return sub_head; 100 else 101 return sub_end; 102} 103 104function str2val(v){ 105 for(i=0; i<v.length; i++){ 106 if (v.charAt(i) !='0') 107 break; 108 } 109 return v.substring(i); 110} 111function inputRCtrl1(o, flag){ 112 if (flag == 0){ 113 o[0].disabled = 1; 114 o[1].disabled = 1; 115 } 116 else{ 117 o[0].disabled = 0; 118 o[1].disabled = 0; 119 } 120} 121function inputRCtrl2(o, flag){ 122 if (flag == 0){ 123 o[0].checked = true; 124 o[1].checked = false; 125 } 126 else{ 127 o[0].checked = false; 128 o[1].checked = true; 129 } 130} 131 132function portrange_min(o, v){ 133 var num = 0; 134 var common_index = o.substring(0, v).indexOf(':'); 135 136 if(common_index == -1) 137 num = parseInt(o.substring(0, v)); 138 else 139 num = parseInt(o.substring(0, common_index)); 140 141 return num; 142} 143function portrange_max(o, v){ 144 var num = 0; 145 var common_index = o.substring(0, v).indexOf(':'); 146 147 if(common_index == -1) 148 num = parseInt(o.substring(0, v)); 149 else 150 num = parseInt(o.substring(common_index+1, v+1)); 151 152 return num; 153} 154 155function entry_cmp(entry, match, len){ //compare string length function 156 var j; 157 158 if(entry.length < match.length) 159 return (1); 160 161 for(j=0; j < entry.length && j<len; j++){ 162 c1 = entry.charCodeAt(j); 163 if (j>=match.length) 164 c2=160; 165 else 166 c2 = match.charCodeAt(j); 167 168 if (c1==160) 169 c1 = 32; 170 171 if (c2==160) 172 c2 = 32; 173 174 if (c1>c2) 175 return (1); 176 else if (c1<c2) 177 return(-1); 178 } 179 return 0; 180} 181 182function add_options_x2(o, arr, varr, orig){ 183 free_options(o); 184 185 for(var i = 0; i < arr.length; ++i){ 186 if(orig == varr[i]) 187 add_option(o, arr[i], varr[i], 1); 188 else 189 add_option(o, arr[i], varr[i], 0); 190 } 191} 192 193function rcheck(o){ 194 if(o.value == "1") 195 return("1"); 196 else 197 return("0"); 198} 199 200function getDateCheck(str, pos){ 201 if (str.charAt(pos) == '1') 202 return true; 203 else 204 return false; 205} 206function getTimeRange(str, pos){ 207 if (pos == 0) 208 return str.substring(0,2); 209 else if (pos == 1) 210 return str.substring(2,4); 211 else if (pos == 2) 212 return str.substring(4,6); 213 else if (pos == 3) 214 return str.substring(6,8); 215} 216function setDateCheck(d1, d2, d3, d4, d5, d6, d7){ 217 str = ""; 218 if (d7.checked == true ) str = "1" + str; 219 else str = "0" + str; 220 if (d6.checked == true ) str = "1" + str; 221 else str = "0" + str; 222 if (d5.checked == true ) str = "1" + str; 223 else str = "0" + str; 224 if (d4.checked == true ) str = "1" + str; 225 else str = "0" + str; 226 if (d3.checked == true ) str = "1" + str; 227 else str = "0" + str; 228 if (d2.checked == true ) str = "1" + str; 229 else str = "0" + str; 230 if (d1.checked == true ) str = "1" + str; 231 else str = "0" + str; 232 233 return str; 234} 235function setTimeRange(sh, sm, eh, em){ 236 return(sh.value+sm.value+eh.value+em.value); 237} 238 239function change_firewall(r){ 240 if (r == "0"){ 241 inputCtrl(document.form.fw_log_x, 0); 242 inputRCtrl1(document.form.fw_dos_x, 0); 243 inputRCtrl1(document.form.misc_ping_x, 0); 244 } 245 else{ //r=="1" 246 inputCtrl(document.form.fw_log_x, 1); 247 inputRCtrl1(document.form.fw_dos_x, 1); 248 inputRCtrl1(document.form.misc_ping_x, 1); 249 } 250} 251 252function change_wireless_bridge(m){ 253 if (m == "0"){ 254 inputRCtrl2(document.form.wl_wdsapply_x, 1); 255 inputRCtrl1(document.form.wl_wdsapply_x, 0); 256 if(Qcawifi_support) 257 { 258 inputRCtrl2(document.form.wl_wds_vht, 1); 259 inputRCtrl1(document.form.wl_wds_vht, 0); 260 } 261 }else if (m == "1" && Rawifi_support){ // N66U-spec 262 inputRCtrl2(document.form.wl_wdsapply_x, 0); 263 inputRCtrl1(document.form.wl_wdsapply_x, 0); 264 }else{ 265 inputRCtrl1(document.form.wl_wdsapply_x, 1); 266 if(Qcawifi_support) 267 inputRCtrl1(document.form.wl_wds_vht, 1); 268 269 } 270} 271 272function onSubmitCtrl(o, s) { 273 document.form.action_mode.value = s; 274 return true; 275} 276 277function onSubmitCtrlOnly(o, s){ 278 if(s != 'Upload' && s != 'Upload1') 279 document.form.action_mode.value = s; 280 281 if(s == 'Upload1'){ 282 if(document.form.file.value){ 283 disableCheckChangedStatus(); 284 dr_advise(); 285 document.form.submit(); 286 } 287 else{ 288 alert("<#JS_Shareblanktest#>"); 289 document.form.file.focus(); 290 } 291 } 292 stopFlag = 1; 293 return true; 294} 295 296function handle_11ac_80MHz(){ 297 if(band5g_support == false || band5g_11ac_support == false || document.form.wl_unit[0].selected == true || document.form.wl_nmode_x.value=='2' || document.form.wl_nmode_x.value=='1') { 298 document.form.wl_bw[0].text = "20/40 MHz"; 299 document.form.wl_bw.remove(3); //remove 80 Mhz when not when not required required 300 } else { 301 document.form.wl_bw[0].text = "20/40/80 MHz"; 302 if(document.form.wl_bw.length == 3) 303 document.form.wl_bw[3] = new Option("80 MHz", "3"); 304 } 305} 306 307function change_ddns_setting(v){ 308 var hostname_x = '<% nvram_get("ddns_hostname_x"); %>'; 309 if (v == "WWW.ASUS.COM"){ 310 document.getElementById("ddns_hostname_info_tr").style.display = "none"; 311 document.getElementById("ddns_hostname_tr").style.display=""; 312 document.form.ddns_hostname_x.parentNode.style.display = "none"; 313 document.form.DDNSName.parentNode.style.display = ""; 314 var ddns_hostname_title = hostname_x.substring(0, hostname_x.indexOf('.asuscomm.com')); 315 if(hostname_x != '' && ddns_hostname_title) 316 document.getElementById("DDNSName").value = ddns_hostname_title; 317 else 318 document.getElementById("DDNSName").value = "<#asusddns_inputhint#>"; 319 320 inputCtrl(document.form.ddns_username_x, 0); 321 inputCtrl(document.form.ddns_passwd_x, 0); 322 document.form.ddns_wildcard_x[0].disabled= 1; 323 document.form.ddns_wildcard_x[1].disabled= 1; 324 showhide("link", 0); 325 showhide("linkToHome", 0); 326 showhide("wildcard_field",0); 327 document.form.ddns_regular_check.value = 0; 328 showhide("check_ddns_field", 0); 329 inputCtrl(document.form.ddns_regular_period, 0); 330 } 331 else if( v == "WWW.ORAY.COM"){ 332 document.getElementById("ddns_hostname_tr").style.display="none"; 333 inputCtrl(document.form.ddns_username_x, 1); 334 inputCtrl(document.form.ddns_passwd_x, 1); 335 document.form.ddns_wildcard_x[0].disabled= 1; 336 document.form.ddns_wildcard_x[1].disabled= 1; 337 showhide("link", 1); 338 showhide("linkToHome", 0); 339 showhide("wildcard_field",0); 340 document.form.ddns_regular_check.value = 0; 341 showhide("check_ddns_field", 0); 342 inputCtrl(document.form.ddns_regular_period, 0); 343 } 344 else{ 345 document.getElementById("ddns_hostname_info_tr").style.display = "none"; 346 document.getElementById("ddns_hostname_tr").style.display=""; 347 document.form.ddns_hostname_x.parentNode.style.display = ""; 348 document.form.DDNSName.parentNode.style.display = "none"; 349 inputCtrl(document.form.ddns_username_x, 1); 350 inputCtrl(document.form.ddns_passwd_x, 1); 351 if(v == "WWW.TUNNELBROKER.NET" || v == "WWW.SELFHOST.DE") 352 var disable_wild = 1; 353 else 354 var disable_wild = 0; 355 document.form.ddns_wildcard_x[0].disabled= disable_wild; 356 document.form.ddns_wildcard_x[1].disabled= disable_wild; 357 if(v == "WWW.ZONEEDIT.COM"){ // Jieming added at 2013/03/06, remove free trail of zoneedit and add a link to direct to zoneedit 358 showhide("link", 0); 359 showhide("linkToHome", 1); 360 } 361 else{ 362 showhide("link", 1); 363 showhide("linkToHome", 0); 364 } 365 366 showhide("wildcard_field",!disable_wild); 367 showhide("check_ddns_field", 1); 368 if(document.form.ddns_regular_check.value == 0) 369 inputCtrl(document.form.ddns_regular_period, 0); 370 else 371 inputCtrl(document.form.ddns_regular_period, 1); 372 } 373} 374 375function change_common_radio(o, s, v, r){ 376 if(v == "ddns_enable_x"){ 377 var hostname_x = '<% nvram_get("ddns_hostname_x"); %>'; 378 var ddns_updated = '<% nvram_get("ddns_updated"); %>'; 379 if(r == 1){ 380 inputCtrl(document.form.ddns_server_x, 1); 381 if('<% nvram_get("ddns_server_x"); %>' == 'WWW.ASUS.COM'){ 382 document.form.DDNSName.disabled = false; 383 document.form.DDNSName.parentNode.parentNode.parentNode.style.display = ""; 384 if(hostname_x != ''){ 385 var ddns_hostname_title = hostname_x.substring(0, hostname_x.indexOf('.asuscomm.com')); 386 if(!ddns_hostname_title) 387 document.getElementById("DDNSName").value = "<#asusddns_inputhint#>"; 388 else 389 document.getElementById("DDNSName").value = ddns_hostname_title; 390 }else{ 391 document.getElementById("DDNSName").value = "<#asusddns_inputhint#>"; 392 } 393 showhide("wildcard_field",0); 394 }else{ 395 if(document.form.ddns_server_x.value == "WWW.ORAY.COM"){ 396 if(ddns_updated == "1") 397 document.getElementById("ddns_hostname_info_tr").style.display = ""; 398 } 399 else 400 document.form.ddns_hostname_x.parentNode.parentNode.parentNode.style.display = ""; 401 inputCtrl(document.form.ddns_username_x, 1); 402 inputCtrl(document.form.ddns_passwd_x, 1); 403 showhide("wildcard_field",1); 404 } 405 change_ddns_setting(document.form.ddns_server_x.value); 406 }else{ 407 if(document.form.ddns_server_x.value == "WWW.ASUS.COM"){ 408 document.form.DDNSName.parentNode.parentNode.parentNode.style.display = "none"; 409 } 410 else{ 411 if(document.form.ddns_server_x.value == "WWW.ORAY.COM") 412 document.getElementById("ddns_hostname_info_tr").style.display = "none"; 413 document.form.ddns_hostname_x.parentNode.parentNode.parentNode.style.display = "none"; 414 inputCtrl(document.form.ddns_username_x, 0); 415 inputCtrl(document.form.ddns_passwd_x, 0); 416 } 417 inputCtrl(document.form.ddns_server_x, 0); 418 document.form.ddns_wildcard_x[0].disabled= 1; 419 document.form.ddns_wildcard_x[1].disabled= 1; 420 showhide("wildcard_field",0); 421 document.form.ddns_regular_check.value = 0; 422 showhide("check_ddns_field", 0); 423 inputCtrl(document.form.ddns_regular_period, 0); 424 } 425 } 426 else if(v == "wan_dnsenable_x"){ 427 if(r == 1){ 428 inputCtrl(document.form.wan_dns1_x, 0); 429 inputCtrl(document.form.wan_dns2_x, 0); 430 } 431 else{ 432 inputCtrl(document.form.wan_dns1_x, 1); 433 inputCtrl(document.form.wan_dns2_x, 1); 434 } 435 } 436 else if(v=="fw_enable_x"){ 437 change_firewall(r); 438 }else if(v=="wl_closed"){ 439 if(r==1) 440 showhide("WPS_hideSSID_hint",1); 441 else 442 showhide("WPS_hideSSID_hint",0); 443 } 444 445 return true; 446} 447 448 449function change_wlweptype(o, isload){ 450 var wflag = 0; 451 452 if(o.value != "0"){ 453 wflag = 1; 454 if(document.form.wl_phrase_x.value.length > 0 && isload == 0) 455 is_wlphrase("WLANConfig11b", "wl_phrase_x", document.form.wl_phrase_x); 456 } 457 458 wl_wep_change(); 459} 460 461function change_wlkey(o, s){ 462 wep = document.form.wl_wep_x.value; 463 464 if(wep == "1"){ 465 if(o.value.length > 10) 466 o.value = o.value.substring(0, 10); 467 } 468 else if(wep == "2"){ 469 if(o.value.length > 26) 470 o.value = o.value.substring(0, 26); 471 } 472 473 return true; 474} 475 476 477function subnetPrefix(ip, orig, count) 478{r=''; 479c=0; 480for(i=0;i<ip.length;i++) 481{if (ip.charAt(i) == '.') 482c++; 483if (c==count) break; 484r = r + ip.charAt(i); 485} 486c=0; 487for(i=0;i<orig.length;i++) 488{if (orig.charAt(i) == '.') 489{c++; 490} 491if (c>=count) 492r = r + orig.charAt(i); 493} 494return (r); 495} 496 497//Viz add 2011.10 For DHCP pool changed 498function subnetPostfix(ip, num, count){ //Change subnet postfix .xxx 499 r=''; 500 orig=""; 501 c=0; 502 for(i=0;i<ip.length;i++){ 503 if (ip.charAt(i) == '.') c++; 504 r = r + ip.charAt(i); 505 if (c==count) break; 506 } 507 c=0; 508 orig = String(num); 509 for(i=0;i<orig.length;i++){ 510 r = r + orig.charAt(i); 511 } 512 return (r); 513} 514 515function openLink(s){ 516 if (s == 'x_DDNSServer'){ 517 if (document.form.ddns_server_x.value.indexOf("WWW.DYNDNS.ORG")!=-1) 518 tourl = "https://account.dyn.com/services/zones/svc/add.html?_add_dns=c&trial=standarddns"; 519 else if (document.form.ddns_server_x.value == 'WWW.ZONEEDIT.COM') 520 tourl = "http://www.zoneedit.com/"; 521 else if (document.form.ddns_server_x.value == 'WWW.SELFHOST.DE') 522 tourl = "http://WWW.SELFHOST.DE"; 523 else if (document.form.ddns_server_x.value == 'WWW.DNSOMATIC.COM') 524 tourl = "http://dnsomatic.com/create/"; 525 else if (document.form.ddns_server_x.value == 'WWW.TUNNELBROKER.NET') 526 tourl = "http://www.tunnelbroker.net/register.php"; 527 else if (document.form.ddns_server_x.value == 'WWW.ASUS.COM') 528 tourl = ""; 529 else if (document.form.ddns_server_x.value == 'WWW.NO-IP.COM') 530 tourl = "http://www.no-ip.com/newUser.php"; 531 else if (document.form.ddns_server_x.value == 'WWW.ORAY.COM') 532 tourl = "http://www.oray.com/"; 533 else tourl = ""; 534 link = window.open(tourl, "DDNSLink","toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=640,height=480"); 535 } 536 else if (s=='x_NTPServer1'){ 537 tourl = "http://support.ntp.org/bin/view/Main/WebHome"; 538 link = window.open(tourl, "NTPLink","toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=640,height=480"); 539 } 540} 541 542/* input : s: service id, v: value name, o: current value */ 543/* output: wep key1~4 */ 544function is_wlphrase(s, v, o){ 545 var pseed = new Array; 546 var wep_key = new Array(5); 547 548 var valid_WPAPSK = function(o){ 549 if(o.value.length >= 64){ 550 o.value = o.value.substring(0, 63); 551 alert("<#JS_wpapass#>"); 552 return false; 553 } 554 555 return true; 556 } 557 558 if(v=='wl_wpa_psk') 559 return(valid_WPAPSK(o)); 560 561 // note: current_page == "Advanced_Wireless_Content.asp" 562 wepType = document.form.wl_wep_x.value; 563 wepKey1 = document.form.wl_key1; 564 wepKey2 = document.form.wl_key2; 565 wepKey3 = document.form.wl_key3; 566 wepKey4 = document.form.wl_key4; 567 568 569 phrase = o.value; 570 if(wepType == "1"){ 571 for(var i = 0; i < phrase.length; i++){ 572 pseed[i%4] ^= phrase.charCodeAt(i); 573 } 574 575 randNumber = pseed[0] | (pseed[1]<<8) | (pseed[2]<<16) | (pseed[3]<<24); 576 for(var j = 0; j < 5; j++){ 577 randNumber = ((randNumber*0x343fd)%0x1000000); 578 randNumber = ((randNumber+0x269ec3)%0x1000000); 579 wep_key[j] = ((randNumber>>16)&0xff); 580 } 581 582 wepKey1.value = binl2hex_c(wep_key); 583 for(var j = 0; j < 5; j++){ 584 randNumber = ((randNumber * 0x343fd) % 0x1000000); 585 randNumber = ((randNumber + 0x269ec3) % 0x1000000); 586 wep_key[j] = ((randNumber>>16) & 0xff); 587 } 588 589 wepKey2.value = binl2hex_c(wep_key); 590 for(var j = 0; j < 5; j++){ 591 randNumber = ((randNumber * 0x343fd) % 0x1000000); 592 randNumber = ((randNumber + 0x269ec3) % 0x1000000); 593 wep_key[j] = ((randNumber>>16) & 0xff); 594 } 595 596 wepKey3.value = binl2hex_c(wep_key); 597 for(var j = 0; j < 5; j++){ 598 randNumber = ((randNumber * 0x343fd) % 0x1000000); 599 randNumber = ((randNumber + 0x269ec3) % 0x1000000); 600 wep_key[j] = ((randNumber>>16) & 0xff); 601 } 602 603 wepKey4.value = binl2hex_c(wep_key); 604 } 605 else if(wepType == "2"){ 606 password = ""; 607 608 if(phrase.length > 0){ 609 for(var i = 0; i < 64; i++){ 610 ch = phrase.charAt(i%phrase.length); 611 password = password+ch; 612 } 613 } 614 615 for(i=0;i<4;i++){ 616 password = calcMD5(password); 617 if(i == 0) 618 wepKey1.value = password.substr(0, 26); 619 else if(i == 1) 620 wepKey2.value = password.substr(0, 26); 621 else if(i == 2) 622 wepKey3.value = password.substr(0, 26); 623 else 624 wepKey4.value = password.substr(0, 26); 625 } 626 } 627 628 return true; 629} 630 631function wl_wep_change(){ 632 var mode = document.form.wl_auth_mode_x.value; 633 var wep = document.form.wl_wep_x.value; 634 635 if(mode == "psk" || mode == "psk2" || mode == "pskpsk2" || mode == "wpa" || mode == "wpa2" || mode == "wpawpa2"){ 636 if(mode != "wpa" && mode != "wpa2" && mode != "wpawpa2"){ 637 inputCtrl(document.form.wl_crypto, 1); 638 inputCtrl(document.form.wl_wpa_psk, 1); 639 } 640 inputCtrl(document.form.wl_wpa_gtk_rekey, 1); 641 inputCtrl(document.form.wl_wep_x, 0); 642 inputCtrl(document.form.wl_phrase_x, 0); 643 inputCtrl(document.form.wl_key1, 0); 644 inputCtrl(document.form.wl_key2, 0); 645 inputCtrl(document.form.wl_key3, 0); 646 inputCtrl(document.form.wl_key4, 0); 647 inputCtrl(document.form.wl_key, 0); 648 } 649 else if(mode == "radius"){ //2009.01 magic 650 inputCtrl(document.form.wl_crypto, 0); 651 inputCtrl(document.form.wl_wpa_psk, 0); 652 inputCtrl(document.form.wl_wpa_gtk_rekey, 0); 653 inputCtrl(document.form.wl_wep_x, 0); //2009.0310 Lock 654 inputCtrl(document.form.wl_phrase_x, 0); 655 inputCtrl(document.form.wl_key1, 0); 656 inputCtrl(document.form.wl_key2, 0); 657 inputCtrl(document.form.wl_key3, 0); 658 inputCtrl(document.form.wl_key4, 0); 659 inputCtrl(document.form.wl_key, 0); 660 } 661 else{ 662 inputCtrl(document.form.wl_crypto, 0); 663 inputCtrl(document.form.wl_wpa_psk, 0); 664 inputCtrl(document.form.wl_wpa_gtk_rekey, 0); 665 if(mode == "open" && document.form.wl_nmode_x.value != 2){ 666 document.form.wl_wep_x.parentNode.parentNode.style.display = "none"; 667 document.form.wl_wep_x.value = "0"; 668 } 669 else 670 inputCtrl(document.form.wl_wep_x, 1); 671 672 if(wep != "0"){ 673 inputCtrl(document.form.wl_phrase_x, 1); 674 inputCtrl(document.form.wl_key1, 1); 675 inputCtrl(document.form.wl_key2, 1); 676 inputCtrl(document.form.wl_key3, 1); 677 inputCtrl(document.form.wl_key4, 1); 678 inputCtrl(document.form.wl_key, 1); 679 } 680 else{ 681 inputCtrl(document.form.wl_phrase_x, 0); 682 inputCtrl(document.form.wl_key1, 0); 683 inputCtrl(document.form.wl_key2, 0); 684 inputCtrl(document.form.wl_key3, 0); 685 inputCtrl(document.form.wl_key4, 0); 686 inputCtrl(document.form.wl_key, 0); 687 } 688 } 689 690 change_key_des(); // 2008.01 James. 691} 692 693function change_wep_type(mode, isload){ 694 var cur_wep = document.form.wl_wep_x.value; 695 var wep_type_array; 696 var value_array; 697 698 free_options(document.form.wl_wep_x); 699 if(mode == "shared"){ //2009.0310 Lock 700 wep_type_array = new Array("WEP-64bits", "WEP-128bits"); 701 value_array = new Array("1", "2"); 702 } 703 else{ 704 if(document.form.wl_nmode_x.value != 2 && sw_mode != 2){ 705 wep_type_array = new Array("None"); 706 value_array = new Array("0"); 707 } 708 else{ 709 wep_type_array = new Array("None", "WEP-64bits", "WEP-128bits"); 710 value_array = new Array("0", "1", "2"); 711 } 712 } 713 714 add_options_x2(document.form.wl_wep_x, wep_type_array, value_array, cur_wep); 715 if(mode == "psk" || mode == "psk2" || mode == "pskpsk2" || mode == "wpa" || mode == "wpa2" || mode == "wpawpa2" || mode == "radius") //2009.03 magic 716 document.form.wl_wep_x.value = "0"; 717 718 change_wlweptype(document.form.wl_wep_x, isload); 719} 720 721function insertExtChannelOption(){ 722 if('<% nvram_get("wl_unit"); %>' == '1'){ 723 insertExtChannelOption_5g(); 724 }else{ 725 insertExtChannelOption_2g(); 726 } 727} 728 729function insertExtChannelOption_5g(){ 730 var country = "<% nvram_get("wl1_country_code"); %>"; 731 var orig = document.form.wl_channel.value; 732 free_options(document.form.wl_channel); 733 if(wl_channel_list_5g != ""){ //With wireless channel 5g hook 734 wl_channel_list_5g = eval('<% channel_list_5g(); %>'); 735 if(document.form.wl_bw.value != "0" && document.form.wl_nmode_x.value != "2") 736 { //not Legacy mode and BW > 20MHz 737 var i; 738 //cut channels >= 165 when bw != 20MHz 739 for(i=0; i < wl_channel_list_5g.length; i++) 740 if(wl_channel_list_5g[i] == "165") 741 { 742 wl_channel_list_5g.splice(i,(wl_channel_list_5g.length - i)); 743 break; 744 } 745 for(i=0; i < wl_channel_list_5g.length; i++) 746 { 747 //remove ch56 when bw == 40MHz or remove ch56,60,64 when bw == 80MHz, on NO ch52 is provided. 748 if(wl_channel_list_5g[i] == "56" && (i == 0 || wl_channel_list_5g[i-1] != "52")) 749 { 750 if(!(Rawifi_support || Qcawifi_support)) 751 ; 752 else if(band5g_11ac_support && (document.form.wl_bw.value == "3" || document.form.wl_bw.value == "1") && (document.form.wl_nmode_x.value == "0" || document.form.wl_nmode_x.value == "8")) 753 { 754 for(var j=wl_channel_list_5g.length; j>=i ; j--) 755 if(wl_channel_list_5g[j] >= "56" && wl_channel_list_5g[j] <= "64") 756 wl_channel_list_5g.splice(j,1); 757 i--; 758 } else { 759 wl_channel_list_5g.splice(i,1); 760 i--; 761 } 762 } 763 //remove ch116 when bw != 20MHz when bw == 80MHz, on NO ch120 is provided. 764 if(wl_channel_list_5g[i] == "116" && (i + 1 < wl_channel_list_5g.length && wl_channel_list_5g[i+1] != "120")) 765 { 766 if(Rawifi_support || Qcawifi_support) 767 { 768 wl_channel_list_5g.splice(i,1); 769 i--; 770 } 771 } 772 //remove ch132~140 when bw == 80MHz or ch140 when bw != 20MHz, on NO ch120 is provided. 773 if(!(Rawifi_support || Qcawifi_support)) 774 ; 775 else if((document.form.wl_bw.value == "3" || document.form.wl_bw.value == "1") && (document.form.wl_nmode_x.value == "0" || document.form.wl_nmode_x.value == "8")) 776 { 777 if(wl_channel_list_5g[i] == "132" || wl_channel_list_5g[i] == "136" || wl_channel_list_5g[i] == "140") 778 { 779 wl_channel_list_5g.splice(i,1); 780 i--; 781 } 782 } 783 else if(wl_channel_list_5g[i] == "140") 784 { 785 wl_channel_list_5g.splice(i,1); 786 i--; 787 } 788 } 789 } 790 if(wl_channel_list_5g[0] != "<#Auto#>") 791 wl_channel_list_5g.splice(0,0,"0"); 792 793 channels = wl_channel_list_5g; 794 }else{ //start Without wireless channel 5g hook 795 if (document.form.wl_bw.value == "0"){ // 20 MHz 796 inputCtrl(document.form.wl_nctrlsb, 0); 797 if (country == "AL" || 798 country == "DZ" || 799 country == "AU" || 800 country == "BH" || 801 country == "BY" || 802 country == "CA" || 803 country == "CL" || 804 country == "CO" || 805 country == "CR" || 806 country == "DO" || 807 country == "SV" || 808 country == "GT" || 809 country == "HN" || 810 country == "HK" || 811 country == "IN" || 812 country == "IL" || 813 country == "JO" || 814 country == "KZ" || 815 country == "LB" || 816 country == "MO" || 817 country == "MK" || 818 country == "MY" || 819 country == "MX" || 820 country == "NZ" || 821 country == "NO" || 822 country == "OM" || 823 country == "PK" || 824 country == "PA" || 825 country == "PR" || 826 country == "QA" || 827 country == "RO" || 828 country == "RU" || 829 country == "SA" || 830 country == "SG" || 831 country == "SY" || 832 country == "TH" || 833 country == "UA" || 834 country == "AE" || 835 country == "US" || 836 country == "Q2" || 837 country == "VN" || 838 country == "YE" || 839 country == "ZW") 840 channels = new Array(0, 36, 40, 44, 48, 149, 153, 157, 161, 165); // Region 0 841 842 else if(country == "AT" || 843 country == "BE" || 844 country == "BR" || 845 country == "BG" || 846 country == "CY" || 847 country == "DK" || 848 country == "EE" || 849 country == "FI" || 850 country == "DE" || 851 country == "GR" || 852 country == "HU" || 853 country == "IS" || 854 country == "IE" || 855 country == "IT" || 856 country == "LV" || 857 country == "LI" || 858 country == "LT" || 859 country == "LU" || 860 country == "NL" || 861 country == "PL" || 862 country == "PT" || 863 country == "SK" || 864 country == "SI" || 865 country == "ZA" || 866 country == "ES" || 867 country == "SE" || 868 country == "CH" || 869 country == "GB" || 870 country == "EU" || 871 country == "UZ") 872 channels = new Array(0, 36, 40, 44, 48); // Region 1 873 874 else if(country == "AM" || 875 country == "AZ" || 876 country == "HR" || 877 country == "CZ" || 878 country == "EG" || 879 country == "FR" || 880 country == "GE" || 881 country == "MC" || 882 country == "TT" || 883 country == "TN" || 884 country == "TR") 885 channels = new Array(0, 36, 40, 44, 48); // Region 2 886 887 else if(country == "AR" || country == "TW") 888 channels = new Array(0, 52, 56, 60, 64, 149, 153, 157, 161, 165); // Region 3 889 890 else if(country == "BZ" || 891 country == "BO" || 892 country == "BN" || 893 country == "CN" || 894 country == "ID" || 895 country == "IR" || 896 country == "PE" || 897 country == "PH") 898 channels = new Array(0, 149, 153, 157, 161, 165); // Region 4 899 900 else if(country == "KP" || 901 country == "KR" || 902 country == "UY" || 903 country == "VE") 904 channels = new Array(0, 149, 153, 157, 161, 165); // Region 5 905 906 else if(country == "JP") 907 channels = new Array(0, 36, 40, 44, 48); // Region 9 908 909 else 910 channels = new Array(0, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165); // Region 7 911 } 912 else if(document.form.wl_bw.value == "1"){ // 20/40 MHz 913 inputCtrl(document.form.wl_nctrlsb, 1); 914 if (country == "AL" || 915 country == "DZ" || 916 country == "AU" || 917 country == "BH" || 918 country == "BY" || 919 country == "CA" || 920 country == "CL" || 921 country == "CO" || 922 country == "CR" || 923 country == "DO" || 924 country == "SV" || 925 country == "GT" || 926 country == "HN" || 927 country == "HK" || 928 country == "IN" || 929 country == "IL" || 930 country == "JO" || 931 country == "KZ" || 932 country == "LB" || 933 country == "MO" || 934 country == "MK" || 935 country == "MY" || 936 country == "MX" || 937 country == "NZ" || 938 country == "NO" || 939 country == "OM" || 940 country == "PK" || 941 country == "PA" || 942 country == "PR" || 943 country == "QA" || 944 country == "RO" || 945 country == "RU" || 946 country == "SA" || 947 country == "SG" || 948 country == "SY" || 949 country == "TH" || 950 country == "UA" || 951 country == "AE" || 952 country == "US" || 953 country == "Q2" || 954 country == "VN" || 955 country == "YE" || 956 country == "ZW") 957 channels = new Array(0, 36, 40, 44, 48, 149, 153, 157, 161); // Region 0 958 959 else if(country == "AT" || 960 country == "BE" || 961 country == "BR" || 962 country == "BG" || 963 country == "CY" || 964 country == "DK" || 965 country == "EE" || 966 country == "FI" || 967 country == "DE" || 968 country == "GR" || 969 country == "HU" || 970 country == "IS" || 971 country == "IE" || 972 country == "IT" || 973 country == "LV" || 974 country == "LI" || 975 country == "LT" || 976 country == "LU" || 977 country == "NL" || 978 country == "PL" || 979 country == "PT" || 980 country == "SK" || 981 country == "SI" || 982 country == "ZA" || 983 country == "ES" || 984 country == "SE" || 985 country == "CH" || 986 country == "GB" || 987 country == "EU" || 988 country == "UZ") 989 channels = new Array(0, 36, 40, 44, 48); // Region 1 990 991 else if(country == "AM" || 992 country == "AZ" || 993 country == "HR" || 994 country == "CZ" || 995 country == "EG" || 996 country == "FR" || 997 country == "GE" || 998 country == "MC" || 999 country == "TT" || 1000 country == "TN" || 1001 country == "TR") 1002 channels = new Array(0, 36, 40, 44, 48); // Region 2 1003 1004 else if(country == "AR" || country == "TW") 1005 channels = new Array(0, 52, 56, 60, 64, 149, 153, 157, 161); // Region 3 1006 1007 else if(country == "BZ" || 1008 country == "BO" || 1009 country == "BN" || 1010 country == "CN" || 1011 country == "ID" || 1012 country == "IR" || 1013 country == "PE" || 1014 country == "PH") 1015 channels = new Array(0, 149, 153, 157, 161); // Region 4 1016 1017 else if(country == "KP" || 1018 country == "KR" || 1019 country == "UY" || 1020 country == "VE") 1021 channels = new Array(0, 149, 153, 157, 161); // Region 5 1022 1023 else if(country == "JP") 1024 channels = new Array(0, 36, 40, 44, 48); // Region 9 1025 1026 else 1027 channels = new Array(0, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161); // Region 7 1028 } 1029 else{ // 40 MHz 1030 inputCtrl(document.form.wl_nctrlsb, 1); 1031 if (country == "AL" || 1032 country == "DZ" || 1033 country == "AU" || 1034 country == "BH" || 1035 country == "BY" || 1036 country == "CA" || 1037 country == "CL" || 1038 country == "CO" || 1039 country == "CR" || 1040 country == "DO" || 1041 country == "SV" || 1042 country == "GT" || 1043 country == "HN" || 1044 country == "HK" || 1045 country == "IN" || 1046 country == "IL" || 1047 country == "JO" || 1048 country == "KZ" || 1049 country == "LB" || 1050 country == "MO" || 1051 country == "MK" || 1052 country == "MY" || 1053 country == "MX" || 1054 country == "NZ" || 1055 country == "NO" || 1056 country == "OM" || 1057 country == "PK" || 1058 country == "PA" || 1059 country == "PR" || 1060 country == "QA" || 1061 country == "RO" || 1062 country == "RU" || 1063 country == "SA" || 1064 country == "SG" || 1065 country == "SY" || 1066 country == "TH" || 1067 country == "UA" || 1068 country == "AE" || 1069 country == "US" || 1070 country == "Q2" || 1071 country == "VN" || 1072 country == "YE" || 1073 country == "ZW") 1074 channels = new Array(0, 36, 40, 44, 48, 149, 153, 157, 161); 1075 1076 else if(country == "AT" || 1077 country == "BE" || 1078 country == "BR" || 1079 country == "BG" || 1080 country == "CY" || 1081 country == "DK" || 1082 country == "EE" || 1083 country == "FI" || 1084 country == "DE" || 1085 country == "GR" || 1086 country == "HU" || 1087 country == "IS" || 1088 country == "IE" || 1089 country == "IT" || 1090 country == "LV" || 1091 country == "LI" || 1092 country == "LT" || 1093 country == "LU" || 1094 country == "NL" || 1095 country == "PL" || 1096 country == "PT" || 1097 country == "SK" || 1098 country == "SI" || 1099 country == "ZA" || 1100 country == "ES" || 1101 country == "SE" || 1102 country == "CH" || 1103 country == "GB" || 1104 country == "EU" || 1105 country == "UZ") 1106 channels = new Array(0, 36, 40, 44, 48); 1107 1108 else if(country == "AM" || 1109 country == "AZ" || 1110 country == "HR" || 1111 country == "CZ" || 1112 country == "EG" || 1113 country == "FR" || 1114 country == "GE" || 1115 country == "MC" || 1116 country == "TT" || 1117 country == "TN" || 1118 country == "TR") 1119 channels = new Array(0, 36, 40, 44, 48); 1120 1121 else if(country == "AR" || country == "TW") 1122 channels = new Array(0, 52, 56, 60, 64, 149, 153, 157, 161); // Region 3 1123 1124 else if(country == "BZ" || 1125 country == "BO" || 1126 country == "BN" || 1127 country == "CN" || 1128 country == "ID" || 1129 country == "IR" || 1130 country == "PE" || 1131 country == "PH") 1132 channels = new Array(0, 149, 153, 157, 161); 1133 1134 else if(country == "KP" || 1135 country == "KR" || 1136 country == "UY" || 1137 country == "VE") 1138 channels = new Array(0, 149, 153, 157, 161); 1139 1140 else if(country == "JP") 1141 channels = new Array(0, 36, 40, 44, 48); 1142 1143 else 1144 channels = new Array(0, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161); 1145 } 1146 } //end Without wireless channel 5g hook 1147 1148 var ch_v = new Array(); 1149 for(var i=0; i<channels.length; i++){ 1150 ch_v[i] = channels[i]; 1151 } 1152 if(ch_v[0] == "0") 1153 channels[0] = "<#Auto#>"; 1154 add_options_x2(document.form.wl_channel, channels, ch_v, orig); 1155 var x = document.form.wl_nctrlsb; 1156 //x.remove(x.selectedIndex); 1157 free_options(x); 1158 add_option(x, "<#Auto#>", "lower"); 1159 x.selectedIndex = 0; 1160} 1161 1162function insertExtChannelOption_2g(){ 1163 var orig2 = document.form.wl_channel.value; 1164 var wmode = document.form.wl_nmode_x.value; 1165 free_options(document.form.wl_channel); 1166 1167 if(wl_channel_list_2g != ""){ 1168 wl_channel_list_2g = eval('<% channel_list_2g(); %>'); 1169 if(wl_channel_list_2g[0] != "<#Auto#>") 1170 wl_channel_list_2g.splice(0,0,"0"); 1171 var ch_v2 = new Array(); 1172 for(var i=0; i<wl_channel_list_2g.length; i++){ 1173 ch_v2[i] = wl_channel_list_2g[i]; 1174 } 1175 if(ch_v2[0] == "0") 1176 wl_channel_list_2g[0] = "<#Auto#>"; 1177 add_options_x2(document.form.wl_channel, wl_channel_list_2g, ch_v2, orig2); 1178 }else{ 1179 document.form.wl_channel.innerHTML = '<% select_channel("WLANConfig11b"); %>'; 1180 } 1181 1182 var CurrentCh = document.form.wl_channel.value; 1183 var option_length = document.form.wl_channel.options.length; 1184 if ((wmode == "0"||wmode == "1") && document.form.wl_bw.value != "0"){ 1185 inputCtrl(document.form.wl_nctrlsb, 1); 1186 var x = document.form.wl_nctrlsb; 1187 var length = document.form.wl_nctrlsb.options.length; 1188 if (length > 1){ 1189 x.selectedIndex = 1; 1190 x.remove(x.selectedIndex); 1191 } 1192 1193 if ((CurrentCh >=1) && (CurrentCh <= 4)){ 1194 x.options[0].text = "Above"; 1195 x.options[0].value = "lower"; 1196 } 1197 else if ((CurrentCh >= 5) && (CurrentCh <= 7)){ 1198 x.options[0].text = "Above"; 1199 x.options[0].value = "lower"; 1200 add_option(document.form.wl_nctrlsb, "Below", "upper"); 1201 if (document.form.wl_nctrlsb_old.value == "upper") 1202 document.form.wl_nctrlsb.options.selectedIndex=1; 1203 1204 if(is_high_power && CurrentCh == 5) // for high power model, Jieming added at 2013/08/19 1205 document.form.wl_nctrlsb.remove(1); 1206 else if(is_high_power && CurrentCh == 7) 1207 document.form.wl_nctrlsb.remove(0); 1208 } 1209 else if ((CurrentCh >= 8) && (CurrentCh <= 9)){ 1210 x.options[0].text = "Below"; 1211 x.options[0].value = "upper"; 1212 if (option_length >=14){ 1213 add_option(document.form.wl_nctrlsb, "Above", "lower"); 1214 if (document.form.wl_nctrlsb_old.value == "lower") 1215 document.form.wl_nctrlsb.options.selectedIndex=1; 1216 } 1217 } 1218 else if (CurrentCh == 10){ 1219 x.options[0].text = "Below"; 1220 x.options[0].value = "upper"; 1221 if (option_length > 14){ 1222 add_option(document.form.wl_nctrlsb, "Above", "lower"); 1223 if (document.form.wl_nctrlsb_old.value == "lower") 1224 document.form.wl_nctrlsb.options.selectedIndex=1; 1225 } 1226 } 1227 else if (CurrentCh >= 11){ 1228 x.options[0].text = "Below"; 1229 x.options[0].value = "upper"; 1230 } 1231 else{ 1232 x.options[0].text = "<#Auto#>"; 1233 x.options[0].value = "1"; 1234 } 1235 } 1236 else 1237 inputCtrl(document.form.wl_nctrlsb, 0); 1238} 1239 1240function wl_auth_mode_change(isload){ 1241 var mode = document.form.wl_auth_mode_x.value; 1242 var wireless_mode = document.form.wl_nmode_x.value; 1243 var i, cur, algos; 1244 inputCtrl(document.form.wl_wep_x, 1); 1245 1246 /* enable/disable crypto algorithm */ 1247 if(mode == "wpa" || mode == "wpa2" || mode == "wpawpa2" || mode == "psk" || mode == "psk2" || mode == "pskpsk2") 1248 inputCtrl(document.form.wl_crypto, 1); 1249 else 1250 inputCtrl(document.form.wl_crypto, 0); 1251 1252 /* enable/disable psk passphrase */ 1253 if(mode == "psk" || mode == "psk2" || mode == "pskpsk2") 1254 inputCtrl(document.form.wl_wpa_psk, 1); 1255 else 1256 inputCtrl(document.form.wl_wpa_psk, 0); 1257 1258 /* update wl_crypto */ 1259 if(mode == "psk" || mode == "psk2" || mode == "pskpsk2" || mode == "wpa" || mode == "wpa2" ||mode == "wpawpa2"){ 1260 /* Save current crypto algorithm */ 1261 for(var i = 0; i < document.form.wl_crypto.length; i++){ 1262 if(document.form.wl_crypto[i].selected){ 1263 cur = document.form.wl_crypto[i].value; 1264 break; 1265 } 1266 } 1267 1268 opts = document.form.wl_auth_mode_x.options; 1269 if(opts[opts.selectedIndex].text == "WPA-Personal" || opts[opts.selectedIndex].text == "WPA-Enterprise") 1270 algos = new Array("TKIP"); 1271 else if(opts[opts.selectedIndex].text == "WPA2-Personal" || opts[opts.selectedIndex].text == "WPA2-Enterprise") 1272 algos = new Array("AES"); 1273 else 1274 algos = new Array("AES", "TKIP+AES"); 1275 1276 /* Reconstruct algorithm array from new crypto algorithms */ 1277 free_options(document.form.wl_crypto); 1278 document.form.wl_crypto.length = algos.length; 1279 for(i=0; i<algos.length; i++){ 1280 document.form.wl_crypto[i] = new Option(algos[i], algos[i].toLowerCase()); 1281 document.form.wl_crypto[i].value = algos[i].toLowerCase(); 1282 if(algos[i].toLowerCase() == cur) 1283 document.form.wl_crypto[i].selected = true; 1284 } 1285 } 1286 1287 /*For Protected Management Frames, only enable for "(wpa)psk2" or "wpa2" on ARM platform (wl_mfp_support)*/ 1288 /* QTN_5G support PMF too*/ 1289 if(wl_mfp_support && (document.form.wl_mfp != null)){ 1290 if ((mode.search("psk2") >= 0 || mode.search("wpa2") >= 0)){ 1291 inputCtrl(document.form.wl_mfp, 1); 1292 } 1293 else{ 1294 inputCtrl(document.form.wl_mfp, 0); 1295 } 1296 } 1297 1298 change_wep_type(mode, isload); 1299 1300 /* Save current network key index */ 1301 cur = "1"; 1302 for(var i = 0; i < document.form.wl_key.length; i++){ 1303 if(document.form.wl_key[i].selected){ 1304 cur = document.form.wl_key[i].value; 1305 break; 1306 } 1307 } 1308 1309 /* Define new network key indices */ 1310 if(mode == "wpa" || mode == "wpa2" || mode == "wpawpa2" || mode == "psk" || mode == "psk2" || mode == "pskpsk2" || mode == "radius") 1311 algos = new Array("1", "2", "3", "4"); 1312 else{ 1313 algos = new Array("1", "2", "3", "4"); 1314 } 1315 1316 /* Reconstruct network key indices array from new network key indices */ 1317 free_options(document.form.wl_key); 1318 document.form.wl_key.length = algos.length; 1319 for(i=0; i<algos.length; i++){ 1320 document.form.wl_key[i] = new Option(algos[i], algos[i]); 1321 document.form.wl_key[i].value = algos[i]; 1322 if(algos[i] == cur) 1323 document.form.wl_key[i].selected = true; 1324 } 1325 1326 wl_wep_change(); 1327} 1328 1329function showhide(element, sh) 1330{ 1331 var status; 1332 if (sh == 1){ 1333 status = ""; 1334 } 1335 else{ 1336 status = "none" 1337 } 1338 1339 if(document.getElementById){ 1340 document.getElementById(element).style.display = status; 1341 } 1342 else if (document.all){ 1343 document.all[element].style.display = status; 1344 } 1345 else if (document.layers){ 1346 document.layers[element].display = status; 1347 } 1348} 1349 1350function check_port_input(obj, emp){ 1351 if(document.getElementById("check_port_input")) 1352 obj.parentNode.removeChild(obj.parentNode.childNodes[2]); 1353 if(!Check_multi_range(obj, 1, 65535) || (emp == 1 && obj.value == "")){ 1354 var childsel=document.createElement("div"); 1355 childsel.setAttribute("id","check_port_input"); 1356 childsel.style.color="#FFCC00"; 1357 obj.parentNode.appendChild(childsel); 1358 document.getElementById("check_port_input").innerHTML="<#BM_alert_port1#> 1 <#BM_alert_to#> 65535"; 1359 document.getElementById("check_port_input").style.display = ""; 1360 obj.value = obj.parentNode.childNodes[0].innerHTML; 1361 obj.focus(); 1362 obj.select(); 1363 return false; 1364 }else 1365 return true; 1366} 1367 1368//Viz add 2012.07 check Editable table macaddr field 1369function check_macaddr_input(obj,flag,emp){ //control hint of input mac address 1370 if(document.getElementById("check_mac_input")) 1371 obj.parentNode.removeChild(obj.parentNode.childNodes[2]); 1372 1373 if(flag == 1 || (emp == 1 && obj.value == "")){ 1374 var childsel=document.createElement("div"); 1375 childsel.setAttribute("id","check_mac_input"); 1376 childsel.style.color="#FFCC00"; 1377 obj.parentNode.appendChild(childsel); 1378 document.getElementById("check_mac_input").innerHTML="<#LANHostConfig_ManualDHCPMacaddr_itemdesc#>"; 1379 document.getElementById("check_mac_input").style.display = ""; 1380 obj.value = obj.parentNode.childNodes[0].innerHTML; 1381 obj.focus(); 1382 obj.select(); 1383 return false; 1384 }else if(flag == 2){ 1385 var childsel=document.createElement("div"); 1386 childsel.setAttribute("id","check_mac_input"); 1387 childsel.style.color="#FFCC00"; 1388 obj.parentNode.appendChild(childsel); 1389 document.getElementById("check_mac_input").innerHTML=Untranslated.illegal_MAC; 1390 document.getElementById("check_mac_input").style.display = ""; 1391 obj.value = obj.parentNode.childNodes[0].innerHTML; 1392 obj.focus(); 1393 obj.select(); 1394 return false; 1395 }else 1396 return true; 1397} 1398 1399function check_hwaddr_flag(obj){ //check_hwaddr() remove alert() 1400 if(obj.value == ""){ 1401 return 0; 1402 }else{ 1403 var hwaddr = new RegExp("(([a-fA-F0-9]{2}(\:|$)){6})", "gi"); 1404 var legal_hwaddr = new RegExp("(^([a-fA-F0-9][aAcCeE02468])(\:))", "gi"); // for legal MAC, unicast & globally unique (OUI enforced) 1405 1406 if(!hwaddr.test(obj.value)) 1407 return 1; 1408 else if(!legal_hwaddr.test(obj.value)) 1409 return 2; 1410 else 1411 return 0; 1412 } 1413} 1414 1415function change_key_des(){ 1416 var objs = getElementsByName_iefix("span", "key_des"); 1417 var wep_type = document.form.wl_wep_x.value; 1418 var str = ""; 1419 1420 if(wep_type == "1") 1421 str = "(<#WLANConfig11b_WEPKey_itemtype1#>)"; 1422 else if(wep_type == "2") 1423 str = "(<#WLANConfig11b_WEPKey_itemtype2#>)"; 1424 1425 for(var i = 0; i < objs.length; ++i) 1426 showtext(objs[i], str); 1427} 1428 1429function wl_gmode_protection_check(){ 1430 if (document.form.wl_gmode_check.checked == true) 1431 document.form.wl_gmode_protection.value = "auto"; 1432 else 1433 document.form.wl_gmode_protection.value = "off"; 1434} 1435 1436/* Handle WEP key index changed */ 1437function wep_key_index_change(obj){ 1438 var selected_key = eval("document.form.wl_key" + obj.value); 1439 selected_key.focus(); 1440 selected_key.select(); 1441} 1442 1443/* Handle WEP encryption changed */ 1444function wep_encryption_change(obj){ 1445 change_wlweptype(obj, 0); 1446} 1447 1448/* Handle Authentication Method changed */ 1449function authentication_method_change(obj){ 1450 wl_auth_mode_change(0); 1451} 1452 1453/* Handle wireless mode changed */ 1454function wireless_mode_change(obj){ 1455 if(obj.value=='0' || obj.value=='2') 1456 inputCtrl(document.form.wl_gmode_check, 1); 1457 else 1458 inputCtrl(document.form.wl_gmode_check, 0); 1459 1460 if(obj.value == "2") 1461 inputCtrl(document.form.wl_bw, 0); 1462 else 1463 inputCtrl(document.form.wl_bw, 1); 1464 1465 handle_11ac_80MHz(); 1466 insertExtChannelOption(); 1467 if(obj.value == "3"){ 1468 document.form.wl_wme.value = "on"; 1469 } 1470 1471 limit_auth_method(); 1472 check_NOnly_to_GN(); 1473} 1474 1475/* To hide Shared key, WPA-Personal/Enterprise and RADIUS with 802.1X*/ 1476function limit_auth_method(g_unit){ 1477 var auth_method_array = document.form.wl_auth_mode_x.value; 1478 if(sw_mode == 2){ 1479 if(based_modelid == "RT-AC87U" && g_unit) 1480 var auth_array = [["Open System", "open"], ["WPA2-Personal", "psk2"], ["WPA-Auto-Personal", "pskpsk2"]]; 1481 else if(based_modelid == "RT-AC87U" && g_unit =='0') 1482 var auth_array = [["Open System", "open"], ["Shared Key", "shared"], ["WPA-Personal", "psk"], ["WPA2-Personal", "psk2"], ["WPA-Auto-Personal", "pskpsk2"]]; 1483 else{ 1484 if((based_modelid == "RT-AC87U" && '<% nvram_get("wl_unit"); %>' == '1')) 1485 var auth_array = [["Open System", "open"], ["WPA2-Personal", "psk2"], ["WPA-Auto-Personal", "pskpsk2"]]; 1486 else 1487 var auth_array = [["Open System", "open"], ["Shared Key", "shared"], ["WPA-Personal", "psk"], ["WPA2-Personal", "psk2"], ["WPA-Auto-Personal", "pskpsk2"]]; 1488 } 1489 } 1490 else if(document.form.wl_nmode_x.value != "2"){ 1491 if(based_modelid == "RT-AC87U" && g_unit) 1492 var auth_array = [["Open System", "open"], ["WPA2-Personal", "psk2"], ["WPA-Auto-Personal", "pskpsk2"]]; 1493 else if(based_modelid == "RT-AC87U" && g_unit=='0') 1494 var auth_array = [["Open System", "open"], ["WPA2-Personal", "psk2"], ["WPA-Auto-Personal", "pskpsk2"], ["WPA2-Enterprise", "wpa2"], ["WPA-Auto-Enterprise", "wpawpa2"]]; 1495 else{ 1496 if((based_modelid == "RT-AC87U" && '<% nvram_get("wl_unit"); %>' == '1') || (based_modelid == "RT-AC87U" && g_unit)) 1497 var auth_array = [["Open System", "open"], ["WPA2-Personal", "psk2"], ["WPA-Auto-Personal", "pskpsk2"]]; 1498 else 1499 var auth_array = [["Open System", "open"], ["WPA2-Personal", "psk2"], ["WPA-Auto-Personal", "pskpsk2"], ["WPA2-Enterprise", "wpa2"], ["WPA-Auto-Enterprise", "wpawpa2"]]; 1500 } 1501 } 1502 else{ //Legacy 1503 if(based_modelid == "RT-AC87U" && g_unit) 1504 var auth_array = [["Open System", "open"], ["WPA2-Personal", "psk2"], ["WPA-Auto-Personal", "pskpsk2"]]; 1505 else if(based_modelid == "RT-AC87U" && g_unit=='0') 1506 var auth_array = [["Open System", "open"], ["Shared Key", "shared"], ["WPA-Personal", "psk"], ["WPA2-Personal", "psk2"], ["WPA-Auto-Personal", "pskpsk2"], ["WPA-Enterprise", "wpa"], ["WPA2-Enterprise", "wpa2"], ["WPA-Auto-Enterprise", "wpawpa2"], ["Radius with 802.1x", "radius"]]; 1507 else{ 1508 if((based_modelid == "RT-AC87U" && '<% nvram_get("wl_unit"); %>' == '1') || (based_modelid == "RT-AC87U" && g_unit)) 1509 var auth_array = [["Open System", "open"], ["WPA2-Personal", "psk2"], ["WPA-Auto-Personal", "pskpsk2"]]; 1510 else{ 1511 if(wifi_logo_support) 1512 var auth_array = [["Open System", "open"], ["WPA2-Personal", "psk2"], ["WPA-Auto-Personal", "pskpsk2"], ["WPA-Enterprise", "wpa"], ["WPA2-Enterprise", "wpa2"], ["WPA-Auto-Enterprise", "wpawpa2"]]; 1513 else 1514 var auth_array = [["Open System", "open"], ["Shared Key", "shared"], ["WPA-Personal", "psk"], ["WPA2-Personal", "psk2"], ["WPA-Auto-Personal", "pskpsk2"], ["WPA-Enterprise", "wpa"], ["WPA2-Enterprise", "wpa2"], ["WPA-Auto-Enterprise", "wpawpa2"], ["Radius with 802.1x", "radius"]]; 1515 } 1516 1517 } 1518 } 1519 1520 if(is_KR_sku){ // MODELDEP by Territory_code 1521 auth_array.splice(0, 1); //remove Open System 1522 } 1523 1524 free_options(document.form.wl_auth_mode_x); 1525 for(i = 0; i < auth_array.length; i++){ 1526 if(auth_method_array == auth_array[i][1]) 1527 add_option(document.form.wl_auth_mode_x, auth_array[i][0], auth_array[i][1], 1); 1528 else 1529 add_option(document.form.wl_auth_mode_x, auth_array[i][0], auth_array[i][1], 0); 1530 } 1531 1532 authentication_method_change(document.form.wl_auth_mode_x); 1533} 1534 1535function getDDNSState(ddns_return_code, ddns_hostname, ddns_old_hostname) 1536{ 1537 var ddnsStateHint = ""; 1538 if(ddns_return_code.indexOf('-1')!=-1) 1539 ddnsStateHint = "<#LANHostConfig_x_DDNS_alarm_2#>"; 1540 else if(ddns_return_code.indexOf('200')!=-1) 1541 ddnsStateHint = "<#LANHostConfig_x_DDNS_alarm_3#>"; 1542 else if(ddns_return_code.indexOf('203')!=-1) 1543 ddnsStateHint = "<#LANHostConfig_x_DDNS_alarm_hostname#> '"+ddns_hostname+"' <#LANHostConfig_x_DDNS_alarm_registered#>"; 1544 else if(ddns_return_code.indexOf('220')!=-1) 1545 ddnsStateHint = "<#LANHostConfig_x_DDNS_alarm_4#>"; 1546 else if(ddns_return_code.indexOf('230')!=-1) 1547 ddnsStateHint = "<#LANHostConfig_x_DDNS_alarm_5#>"; 1548 else if(ddns_return_code.indexOf('233')!=-1) 1549 ddnsStateHint = "<#LANHostConfig_x_DDNS_alarm_hostname#> '"+ddns_hostname+"' <#LANHostConfig_x_DDNS_alarm_registered_2#> '"+ddns_old_hostname+"'"; 1550 else if(ddns_return_code.indexOf('296')!=-1) 1551 ddnsStateHint = "<#LANHostConfig_x_DDNS_alarm_6#>"; 1552 else if(ddns_return_code.indexOf('297')!=-1) 1553 ddnsStateHint = "<#LANHostConfig_x_DDNS_alarm_7#>"; 1554 else if(ddns_return_code.indexOf('298')!=-1) 1555 ddnsStateHint = "<#LANHostConfig_x_DDNS_alarm_8#>"; 1556 else if(ddns_return_code.indexOf('299')!=-1) 1557 ddnsStateHint = "<#LANHostConfig_x_DDNS_alarm_9#>"; 1558 else if(ddns_return_code.indexOf('401')!=-1) 1559 ddnsStateHint = "<#LANHostConfig_x_DDNS_alarm_10#>"; 1560 else if(ddns_return_code.indexOf('407')!=-1) 1561 ddnsStateHint = "<#LANHostConfig_x_DDNS_alarm_11#>"; 1562 else if(ddns_return_code == 'Time-out') 1563 ddnsStateHint = "<#LANHostConfig_x_DDNS_alarm_1#>"; 1564 else if(ddns_return_code =='unknown_error') 1565 ddnsStateHint = "<#LANHostConfig_x_DDNS_alarm_2#>"; 1566 else if(ddns_return_code =='connect_fail') 1567 ddnsStateHint = "<#qis_fail_desc7#>"; 1568 else if(ddns_return_code =='no_change') 1569 ddnsStateHint = "<#LANHostConfig_x_DDNS_alarm_nochange#>"; 1570 /*else if(ddns_return_code =='ddns_query') 1571 ddnsStateHint = "<#LANHostConfig_x_DDNSHostnameCheck_buttonname#>";*/ 1572 else if(ddns_return_code =='auth_fail') 1573 ddnsStateHint = "<#qis_fail_desc1#>"; 1574 else if(ddns_return_code !='') 1575 ddnsStateHint = "<#LANHostConfig_x_DDNS_alarm_2#>"; 1576 1577 return ddnsStateHint; 1578} 1579 1580function get_yadns_modedesc(mode) 1581{ 1582 if (mode == 0) 1583 return "<#YandexDNS_mode0#>"; 1584 else if(mode == 1) 1585 return "<#YandexDNS_mode1#>"; 1586 else if(mode == 2) 1587 return "<#YandexDNS_mode2#>"; 1588 else if(mode == -1) 1589 return "<#btn_Disabled#>"; 1590 1591 return ""; 1592} 1593