var TMtype=0;
var SelPg=2;
crstyle=(pser=='811')?'b':'';
var showL1Help = true; // judge whether to show L1 help page when user clicks L1 button
function sa(s){alert(s)}
function append_url(url) { // we can modify this function to append paramters to url
url += (url.indexOf("?")==-1) ? "?" : "&";
url = url.replace("/","");
var t = new Date();
return url+'ZT='+t.getTime()+'&csrftok='+get_csrf_token();
}
function GURL(x) {
window.location = append_url(x);
}
function tGURL(x) {
top.location = append_url(x);
}
function sGURL(x) { // We can use this function to send ALTER or modify CSIDs in secret.
top.Hide.location = append_url(x);
}
function tf0GURL(x) {
parent.frames[0].location = append_url(x);
}
function mGURL2(x) {
if(top.frames['main']!=null)top.frames['main'].location = append_url(x);
else location = append_url(x);
}
function mGURL(x) {
if(top.frames['main']!=null) top.frames['main'].location = append_url(x);
else top.location = append_url(x);
}
function downloadFile(file_path, file_name) {
var link = document.createElement('a');
link.href = file_path;
link.download = file_name;
document.body.appendChild(link);
link.click();
setTimeout( function () { link.parentNode.removeChild( link ); }, 10 ); // remove garbage element
}
function refresh_self_defined_ui() {
}
function makesure(p,l,k) {
if (confirm(p)) GURL(l);
else eval(k);
}
function pmakesure(p,l){if (confirm(p))pGURL(l)}
function dw(str){document.write(str)}
function dwln(str){document.writeln(str)}
function dwBR(str){document.write(str+"<BR>")}
function ah(msgs){alert(msgs);history.go(-1);}
function MGURL(x){
parent.main.location = append_url(x);
}
function Mmakesure(p,l){if (confirm(p)) MGURL(l);}
function gec(){GetElmCont(arguments[0],arguments[1])}
function changeClass(id0, class0){
document.getElementById(id0).className = class0;
}
function changeImg(id0, url0){
document.getElementById(id0).src = url0;
}
function tempchglang(lgsel)
{
fm=lgsel.form
if(location.pathname=="/primx.htm"||location.pathname=="/primx_sim.htm"||location.pathname=="/vprimx.htm")
loc=String(location+"&N0002000F="+lgsel.value+"&_sck=httpd&Nlang="+lgsel.value)
else
loc=String(location.pathname+"?N0002000F="+lgsel.value+"&_sck=httpd&Nlang="+lgsel.value)
GURL(loc);
}
function DevInfo(nlg) {
if(login&&langselection){
langsel="<select id='langoption' class=toptitle onchange='tempchglang(this)'>"
for(s=0;s<langnames.length;s++){
langsel+="<option value="+(s+1)+" id='_alangnames_"+s+"_' "+((nlg == s+1) ? " selected" : "")+">"+langnames[s]
}
langsel+="</select>"
}
if ("0" == 99) { //amit logo
dw("<tr><td><img src=amit.gif></td>")
} else { //客戶logo
dw("<tr><td><img id=sw_logo src=logo.gif></td>")
}
dw("<td width=100% align=right>")
dw("<table border=0 class=ALL-LINK_banner><tr>");
if(swm_wireless==true){
var ssid_str="NetComm_2.4GHz";
var ssid2_str="NetComm_5GHz";
if(swm_wireless2g == true){ //代表用舊的WiFi Configuration
if(typeof(swm_single_select)!="undefined"){  //若有設wifi slectable時，C_LOCAL_WLAN2ENABLE == 1 顯示5G SSID
if(swm_single_select){
ssid_str="NetComm_5GHz";
}
}
if(typeof(swm_wireless24g)!="undefined"){ //若有設wifi 2.4g開關時，2.4g關而5g開，則顯示5G SSID
if(swm_wireless24g==false&&swm_wireless5g==true){
ssid_str="NetComm_5GHz";
}
}
}
if(typeof(swm_wifi_module1)!="undefined"){
if(swm_wifi_module1){ //代表用WiFi Module One
ssid_str="NetComm_2.4GHz";
}
if(!swm_wifi_module1&&swm_wifi_module2){  //若module1沒開且module2有開顯示module2 CSID
ssid_str="NetComm_5GHz";
}
}
if(typeof(swm_wifi_module2)!="undefined"){
if(swm_wifi_module2){ //代表用WiFi Module Two
ssid2_str="NetComm_5GHz";
}
if(!swm_wifi_module1&&swm_wifi_module2){  //若module1沒開且module2有開顯示module2 CSID
ssid2_str="NetComm_5GHz";
}
}
dw("<td>2.4G SSID : <span id='_banner_ssid' class='val'>"+ssid_str+"</span></br>");
dw("5G SSID : <span id='_banner_ssid' class='val'>"+ssid2_str+"</span></td>");
}else{
dw("<td>&nbsp;</td>"); }
if (login){
dw("<td id=langsels style='visibility:hidden'>");
if(langselection) { dw("<span id=_wary_0>Language</span>  :  "+langsel+" &nbsp;"); } // set language select menu
dw("</td></tr><tr>");
dw("<td><span id=_sta_0>Firmware Version</span> : <span id='_banner_fwversion' class='val'>0NC0WF0.H51_e52.0NC1_201804131700</span></td>");
dw("<td>");
dw("<table border=0 cellpadding=0 cellspacing=0><tr>");
dw("<td class='login_button1'></td>");
dw("<td class='login_button2' onclick='logout()'><span id=_wary_0>Logout</span></td>");
dw("<td class='login_button3'></td>");
dw("</tr></table>");
dw("</td>");
}
else{
dw("</tr>");
dw("<tr><td><span id=_sta_0>Firmware Version</span>: <span id='_banner_fwversion_0' class='val'>0NC0WF0.H51_e52.0NC1_201804131700</span></td>");
}
dw("</tr>");
dw("</table></td>");
}
function sslvpnbner(nlg)
{
if(login&&langselection){
langsel="<select id='langoption' class=toptitle onchange='tempchglang(this)'>"
for(s=0;s<langnames.length;s++){
langsel+="<option value="+(s+1)+" id='_alangnames_"+s+"_' "+((nlg == s+1) ? " selected" : "")+">"+langnames[s]
}
langsel+="</select>"
}
else langsel="<select><option>---</select>"
if ("0" == 99) { //amit logo
dw("<tr><td><img src=amit.gif></td>")
} else { //客戶logo
dw("<tr><td><img src=logo.gif></td>")
}
dw("<td width=100% align=right>")
dw("<table border=0 class=ALL-LINK_banner><tr>");
if(swm_wireless==true){
dw("<td>SSID : <span id='_banner_ssid' class='val'>NetComm_2.4GHz</span></td>") }
else{
dw("<td>&nbsp;</td>") }
if (login){
dw("<td id=langsels><!--span id=_wary_0>Language</span>  :  "+langsel+"--> &nbsp;</td>");
dw("</tr><tr>");
dw("<td><span id=_sta_0>Firmware Version</span> : <span id='_banner_fwversion' class='val'>0NC0WF0.H51_e52.0NC1_201804131700</span></td>");
dw("<td>");
dw("<table border=0 cellpadding=0 cellspacing=0><tr>");
dw("<td class='login_button1'></td>");
dw("<td class='login_button2' onclick='logout()'><span id=_wary_0>Logout</span></td>");
dw("<td class='login_button3'></td>");
dw("</tr></table>");
dw("</td>");
}
else{
dw("</tr>");
dw("<tr><td><span id=_sta_0>Firmware Version</span> : <span id='_banner_fwversion_0' class='val'>0NC0WF0.H51_e52.0NC1_201804131700</span></td>");
}
dw("</tr>")
dw("<tr><td>&nbsp;</td</tr>") //未開放i_info.htm
dw("</table></td>")
}
function logout()
{
mGURL("start.htm");
}
function clk(link)
{
var links=link;
if(link=="#")return link
if((link.indexOf(':')==-1)&&(link.indexOf('.')==-1)&&(link.indexOf('=')==-1))links=""+link+".htm?rc="
return links
}
function displaymenu(){
m='_m'+setLMtp();
if(!login) return;
for(i=0;i<TopMenus.length;i++){
document.getElementById('_m'+i).style.display='none';
}
if(m!="_m99") {    //_m99 no set L123
document.getElementById(m).style.display='';
}
}
SecMenus=new Array(
m_wizard_network[0]+m_wizard_vpn[0]
,m_dashboard[0]+m_status_network[0]+m_status_wireless[0]+m_status_clientlist[0]+m_status_firewall[0]+m_status_vpn[0]+m_status_system[0]+m_status_voip[0]+m_status_ddns[0]+m_status_upnp[0]+m_status_usb[0]+m_status_statis[0]+m_status_gnss[0]+m_sta_basic[0]+m_sta_security[0]+m_sta_administration[0]+m_sta_statis[0]
,m_lan_wan[0]+m_vlan[0]+m_wireless[0]+m_ipv6[0]+m_nat[0]+m_nat_g2[0]+m_routing[0]+m_client_server_proxy[0]+m_dns_ddns[0]+m_qos_g2[0]+m_redundancy_g2[0]
,m_firewall[0]+m_qos[0]+m_s_vpn[0]+m_redundancy[0]+m_management[0]+m_certificate[0]+m_communication_bus[0]
,m_voice[0]+/*m_voice_over_3G[0]+m_voice_over_ip[0]+*/m_mobile_applications[0]+m_nas[0]+m_ap_management[0]+m_captive_protal[0]+m_io_management[0]+m_evt_management[0]+m_posittion_app[0]+m_pdu_mgmt[0]+m_device_link[0]+m_license[0]+m_ftp[0]+m_plaintext_sys[0]+m_macAuth[0]
,m_system_related[0]+m_schedule[0]+m_user_management[0]+m_grouping[0]+m_external_servers[0]+m_mmi[0]+m_powermgt[0]
,m_schedule_g2[0]+m_user[0]+m_grouping_releated[0]+m_external_server[0]+m_certificate_g2[0]
,m_busprotocol[0]+m_data_interchg[0]+m_datalog_related[0]
,m_s_vpn_g2[0]+m_firewall_g2[0]+m_authentication_l2[0]
,m_confg_manage[0]+m_system_opt[0]+m_ftp_l2[0]+m_diagnostic[0]
,m_celltoolkit[0]+m_evthanding[0]+m_loctracking[0]+m_device_link_g2[0]+m_pwercontr[0]+m_ap_management_g2[0]+m_license_g2[0]
,m_helloworld1[0]+m_helloworld2[0]
)
SecMenulk=new Array(
m_wizard_network[1]+m_wizard_vpn[1]
,m_dashboard[1]+m_status_network[1]+m_status_wireless[1]+m_status_clientlist[1]+m_status_firewall[1]+m_status_vpn[1]+m_status_system[1]+m_status_voip[1]+m_status_ddns[1]+m_status_upnp[1]+m_status_usb[1]+m_status_statis[1]+m_status_gnss[1]+m_sta_basic[1]+m_sta_security[1]+m_sta_administration[1]+m_sta_statis[1]
,m_lan_wan[1]+m_vlan[1]+m_wireless[1]+m_ipv6[1]+m_nat[1]+m_nat_g2[1]+m_routing[1]+m_client_server_proxy[1]+m_dns_ddns[1]+m_qos_g2[1]+m_redundancy_g2[1]
,m_firewall[1]+m_qos[1]+m_s_vpn[1]+m_redundancy[1]+m_management[1]+m_certificate[1]+m_communication_bus[1]
,m_voice[1]+/*m_voice_over_3G[1]+m_voice_over_ip[1]+*/m_mobile_applications[1]+m_nas[1]+m_ap_management[1]+m_captive_protal[1]+m_io_management[1]+m_evt_management[1]+m_posittion_app[1]+m_pdu_mgmt[1]+m_device_link[1]+m_license[1]+m_ftp[1]+m_plaintext_sys[1]+m_macAuth[1]
,m_system_related[1]+m_schedule[1]+m_user_management[1]+m_grouping[1]+m_external_servers[1]+m_mmi[1]+m_powermgt[1]
,m_schedule_g2[1]+m_user[1]+m_grouping_releated[1]+m_external_server[1]+m_certificate_g2[1]
,m_busprotocol[1]+m_data_interchg[1]+m_datalog_related[1]
,m_s_vpn_g2[1]+m_firewall_g2[1]+m_authentication_l2[1]
,m_confg_manage[1]+m_system_opt[1]+m_ftp_l2[1]+m_diagnostic[1]
,m_celltoolkit[1]+m_evthanding[1]+m_loctracking[1]+m_device_link_g2[1]+m_pwercontr[1]+m_ap_management_g2[1]+m_license_g2[1]
,m_helloworld1[1]+m_helloworld2[1]
)
SecMenuv=new Array(
m_wizard_network+"|"+m_wizard_vpn
,m_dashboard+"|"+m_status_network+"|"+m_status_wireless+"|"+m_status_clientlist+"|"+m_status_firewall+"|"+m_status_vpn+"|"+m_status_system+"|"+m_status_voip+"|"+m_status_ddns+"|"+m_status_upnp+"|"+m_status_usb+"|"+m_status_statis+"|"+m_status_gnss+"|"+m_sta_basic+"|"+m_sta_security+"|"+m_sta_administration+"|"+m_sta_statis
,m_lan_wan+"|"+m_vlan+"|"+m_wireless+"|"+m_ipv6+"|"+m_nat+"|"+m_nat_g2+"|"+m_routing+"|"+m_client_server_proxy+"|"+m_dns_ddns+"|"+m_qos_g2+"|"+m_redundancy_g2
,m_firewall+"|"+m_qos+"|"+m_s_vpn+"|"+m_redundancy+"|"+m_management+"|"+m_certificate+"|"+m_communication_bus
,m_voice+"|"+/*m_voice_over_3G+"|"+m_voice_over_ip+"|"+*/m_mobile_applications+"|"+m_nas+"|"+m_ap_management+"|"+m_captive_protal+"|"+m_io_management+"|"+m_evt_management+"|"+m_posittion_app+"|"+m_pdu_mgmt+"|"+m_device_link+"|"+m_license+"|"+m_ftp+"|"+m_plaintext_sys+"|"+m_macAuth
,m_system_related+"|"+m_schedule+"|"+m_user_management+"|"+m_grouping+"|"+m_external_servers+"|"+m_mmi+"|"+m_powermgt
,m_schedule_g2+"|"+m_user+m_grouping_releated+"|"+m_external_server+"|"+m_certificate_g2
,m_busprotocol+"|"+m_data_interchg+"|"+m_datalog_related
,m_s_vpn_g2+"|"+m_firewall_g2+"|"+m_authentication_l2
,m_confg_manage+"|"+m_system_opt+"|"+m_ftp_l2+"|"+m_diagnostic
,m_celltoolkit+"|"+m_evthanding+"|"+m_loctracking+m_device_link_g2+m_pwercontr+m_ap_management_g2+m_license_g2
,m_helloworld1+"|"+m_helloworld2
)
function show_L1_button(l, link) {
topsnm=TopMenus[l]
topsnm_logo=TopMenus_logo[l]
topsnm0=eval(topsnm+"[0]") //L1 name
topsnm1=(showL1Help==true || link==null)?eval(topsnm+"[1]"):link; //L1 link
L1ID=TAID_L1[l]            //L1 TAID
dw("<TR " + setTopMenus(topsnm) + " CLASS=handlk onMouseOver=\"changeClass('TA0_"+ L1ID +"','LM_mouse')\" onMouseOut=\"changeClass('TA0_"+ L1ID +"','LM')\" ONCLICK=\"mGURL2('"+ topsnm1 +".htm?rc=')&&displaymenu('_m"+ l +"')\"><TD HEIGHT=45 colspan=3 width=100% id='TA0_"+ L1ID +"' CLASS='LM' NOWRAP><IMG SRC=sp.gif WIDTH=12 HEIGHT=5 BORDER=0><IMG SRC="+topsnm_logo+".gif WIDTH=30 HEIGHT=30 ALIGN=ABSMIDDLE><IMG SRC=sp.gif WIDTH=6 HEIGHT=5 BORDER=0 ALIGN=ABSMIDDLE>")
dw("<A id='TA_"+ L1ID +"' xHREF=#>"+ topsnm0 +"</A></TD></TR>")
dw("<TR id='_m"+ l +"' style='display:none'><td colspan=3 width=100%><table border=0 align=right width=99%>")
}
function LM_loginL() { // login box on left menu
dw("<TABLE border='0' width='200' cellpadding='0' cellspacing='0' align='center' style='padding-top: 30px;'>");
golink = "sslvpnportal.htm";
if(swm_nas) { //有NAS時，才輸入帳號及密碼
dw("<TR><TD CLASS=AdminMM align=left style='padding-left:10px;'><span id=_wary_0>Username</span> : </td><td><input type=text name=un size=9 maxlength=9></TD></TR>");
}
dw("<TR HEIGHT=40><TD CLASS=AdminMM align=left style='padding-left:10px;'><span id=_wary_0>Password</span> : </td><td colspan=2><input type=password name=pw size=9 maxlength=9></TD></TR>");
dw("<TR HEIGHT=25 valign=top><TD CLASS=AdminMM align=left colspan=3 style='padding-left:10px;'><span id=_wary_0>(default: admin)</span>&nbsp;</TD></TR>");
dw("<TR HEIGHT=36><TD colspan=3><input type=hidden name=rd value=/uir/status.htm><input type=hidden name=rd2 value=/uir/status.htm><input type=hidden name=Nrd value=1>");
dw("<input type='hidden' name='Ntime' id='Ntime' value=''>");
dw("<span style='display:none' ><input type='submit' value='hsbmit' id=hsbmit></span>");
dw("<table border=0 cellpadding=0 cellspacing=0><tr>");
dw("<td style='padding-left:8px;'>&nbsp;</td>");
dw("<td class=login_button1></td>");
dw("<td class=login_button2 style='padding-bottom:2px;' onclick='gohsbmit()'><span id=_wary_5>Login</span></td>");
dw("<td class=login_button3>&nbsp;</td>");
dw("</tr></table>");
dw("</TD></TR>");
if(swm_s_sslvpn) { // show SSL VPN button
dw("<TR HEIGHT=36><TD colspan=3>");
dw("<table border=0 cellpadding=0 cellspacing=0><tr>");
dw("<td style='padding-left:8px;'>&nbsp;</td>");
dw("<td class=login_button1></td>");
dw("<td class=login_button2 style='padding-bottom:2px;' onclick='window.location=golink'><span id=_sslvpn_0>Link to SSL VPN</span></td>");
dw("<td class=login_button3>&nbsp;</td>");
dw("<td width='30px'>&nbsp;</td>");
dw("</tr></table>");
dw("</TD></TR>");
}
dw("</TABLE>");
}
function LM() { // show left menu
var ck_loginL = (typeof(left_menu_login) != "undefined");
if(ck_loginL && left_menu_login && !login) {
LM_loginL();
return;
}
LP=setLMtp();
LS=setLMts();
dw("<TABLE BORDER=0 WIDTH=200 HEIGHT='100%' CELLPADDING=0 CELLSPACING=0 align=center>")
dw("<TR><TD HEIGHT=10 colspan=3></TD></TR>")
for (l=0;l<TopMenus.length;l++){
var found_first_L2 = false; // use this flag to record whether found the first L2 button or not
sm=SecMenus[l];
sms=sm.split("~");
smu=SecMenulk[l];
smus=smu.split("~");
sml2=TAID_L2[l];         //L2
sml2s=sml2.split("~");   //L2 TAID
for (k=0;k<sms.length;k++){
if(sms[k]=="") sms.splice(k,1);
if(smus[k]=="") smus.splice(k,1);
}
var L2_button_str = "";
for(i=0;i<sms.length;i++){
showl2=(sms[i].indexOf("remove_this")!=-1)? "style='display:none'" : ""
c_link=smus[i]
L2ID=sml2s[i] //L2 TAID
if(c_link.indexOf("remove_this")!=-1){ //若L3第一個compo剛好被reomve, L2的link要修正
smv=SecMenuv[l];
try{    //在L2只有一個時smvs=smv.split("|")會有問題，所以用try
smvs=smv.split("|");
smvss=smvs[i].split(",")
for(a=2;a<smvss.length;a++){
if(eval(smvss[a]+"[1]").indexOf("remove_this")==-1){ //L2改成這個link
c_link=eval(smvss[a]+"[1]");
c_link=c_link.substring(0,c_link.length-1) //remove "~"
break;
}
}
}catch(e){}
}
if(l==0) sloc="top.frames['main'].location" //wizard使用mGURL是因為用GURL會有重覆框架的問題....liwei
else sloc="location"
var L2_link = clk(c_link); // L2 url link
if(LP==l&&LS==i){ // selected L1 and selected L2
L2_button_row = "<TR "+ showl2 +"><td><table border=0 width=100%><TR CLASS=handlk ONCLICK=\""+sloc+"='" + L2_link;
L2_class_name = "LM2_mouse";
}
else { // other L2
L2_button_row = "<TR "+ showl2 +"><td><table border=0 width=100%><TR CLASS=handlk onMouseOver=\"changeClass('TA0_"+ L2ID +"','LM2_mouse')\" onMouseOut=\"changeClass('TA0_"+ L2ID +"','LM2')\" ONCLICK=\""+sloc+"='" + L2_link;
L2_class_name = "LM2";
}
if(found_first_L2==false && L2_link.indexOf("remove_this")==-1) { // find the first available L2 button
show_L1_button(l, L2_link); // show the L1 button with the link of the first available L2
found_first_L2 = true; // found first L2
if(LP!=l) { // if current L1 isn't selected, stop it because it doesn't need to expand L2 buttons
break;
}
}
L2_button_str = L2_button_str + L2_button_row+ "'\"><TD HEIGHT=19 id='TA0_"+ L2ID +"' CLASS='"+L2_class_name+"' NOWRAP>&nbsp;<IMG SRC=ag219.gif>&nbsp;<A id='TA_"+ L2ID +"' xHREF=#>" + sms[i] +"</A></TD></TR></table></td></tr>\n";
}
if(found_first_L2 == false) { // none of available L2 buttons
show_L1_button(l, null);
}
if(LP==l) { // show L2 buttons if current L1 is selected by user
dw(L2_button_str);
}
dw("</table></td></tr>");
}
dw("<TR><TD HEIGHT=100% valign=bottom colspan=3></TD></TR>");
dw("</TABLE>");
}
function LM_sslvpn()
{
LP=setLMtp();
LS=setLMts();
dw("<TABLE BORDER=0 WIDTH='200px' HEIGHT='100%' CELLPADDING=0 CELLSPACING=0 algn=center>")
dw("<TR><TD HEIGHT=10 colspan=3></TD></TR>");
if(login){
dw("<TR><TD colspan=3><IMG SRC=sp.gif WIDTH=6 HEIGHT=30></TD></TR>")
dw("<TR><TD CLASS=AdminMM align=left style='padding-left:10px;'><span id=_wary_0>Username</span> : </td><td><input type=text name=un value='' size=9 maxlength=9 disabled></TD><td>&nbsp;</td></TR>")
dw("<TR HEIGHT=40><TD CLASS=AdminMM align=left style='padding-left:10px;'><span id=_wary_0>Password</span> : </td><td colspan=2><input type=password name=pw value='******' size=9 maxlength=9 disabled></TD></TR>")
dw("<TR HEIGHT=25 valign=top><TD CLASS=AdminMM align=left colspan=3 style='padding-left:10px;'>&nbsp;</TD></TR>")
}
else{ //not login
dw("<TR><TD colspan=3><IMG SRC=sp.gif WIDTH=6 HEIGHT=30></TD></TR>")
dw("<TR><TD CLASS=AdminMM align=left style='padding-left:10px;'><span id=_wary_0>Username</span> : </td><td><input type=text name=un size=9 maxlength=9></TD><td>&nbsp;</td></TR>")
dw("<TR HEIGHT=40><TD CLASS=AdminMM align=left style='padding-left:10px;'><span id=_wary_0>Password</span> : </td><td colspan=2><input type=password name=pw size=9 maxlength=9></TD></TR>")
dw("<TR HEIGHT=25 valign=top><TD CLASS=AdminMM align=left colspan=3 style='padding-left:10px;'><span id=_wary_0>(default: admin)</span>&nbsp;</TD></TR>")
dw("<TR HEIGHT=36><TD colspan=3><input type=hidden name=rd value=/uir/sslvpnportal.htm><input type=hidden name=rd2 value=/uir/sslvpnportal.htm><input type=hidden name=Nrd value=1>")
dw("<table border=0 width=100% height=100% cellpadding=0 cellspacing=0><tr>")
dw("<td style='padding-left:8px;'>&nbsp;</td>")
dw("<td class=login_button1></TD>")
dw("<td class=login_button2 style='padding-bottom:2px;' onclick='document.forms[0].submit();'><span id=_wary_5>Login</span></td>")
dw("<td width=100% class=login_button3>&nbsp;</td>")
dw("</tr></table>")
dw("</TD></TR>")
}
dw("<TR><TD HEIGHT=100% valign=bottom colspan=3></TD></TR>");
dw("</TABLE>");
}
function gohsbmit(){
document.getElementById("hsbmit").click();
}
function check_login(){
/*  for check login when Ntry >= N (N:C_HTTP_AUTH_RETRY_MAX), wait 30 seconds  */
var default_second = 30;
var auth_failnum = 3;
var d = new Date();
var now = Date.UTC(d.getFullYear(),d.getMonth(),d.getDate(),d.getHours(),d.getMinutes(),d.getSeconds());
var code_time = "1527239339";
code_time = (code_time == "")?0:parseInt(code_time);
var second = (now/1000)-code_time;
var wait_second = (default_second - second);
if((typeof(Ntry) != "undefined") && Ntry == auth_failnum && wait_second >= 1)
{
alert(GetElmCont('wary_0','Already reaching maximum Password-Guessing times, please wait a few seconds!'))
return false
}
else
{
document.getElementById("Ntime").value = now/1000;
return true
}
}
function swWLAN(sw)
{
f2=document.forms[0]
s=false;
for(r=0;r<f2.length;r++)
{
f2elm=f2.elements[r].name
if((f2elm=="_eny_start")||(f2elm=="_eny_start2")){s=true;}
else if((f2elm=="_eny_end")||(f2elm=="_eny_end2")){s=false;}
if(s) f2.elements[r].disabled=!sw
else continue;
}
}
function DisableEnableForm(xForm,xHow)
{
for(i=0;i<xForm.length;i++)
{
if(xForm[i].type.toLowerCase()=="button")
{
xForm[i].disabled = xHow;
}
}
}
function trnaslate_member(vv){
var count = 1;
var count_all = 0;
var trans2=parseInt(vv).toString(2);  //轉2進制
trans2rr=trans2.split("");
for(c=0;c<trans2rr.length-1;c++){
if(trans2rr[c]==1) count++
}
return count-1;
}
function trnaslate_member_count(vv){
var count = 1;
var count_all = 0;
var trans2=parseInt(vv).toString(2);  //轉2進制
trans2rr=trans2.split("");
for(c=0;c<trans2rr.length-1;c++){
if(trans2rr[c]==1) count++
}
return count;
}
function translate_member2(num){
var currnum=128;
if(num.length<=4){
num=chang_length(num);
}
num1 = num;
num2 = eval(num1.charAt(0)) * currnum;
for (i = 1; i <= 7; i++)
{
currnum = currnum / 2;
num2 = num2 + (eval(num1.charAt(i)) * currnum);
}
return num2;
}
function compare(arrv){
for(h=0;h<arrv.length;h++){
for (n=0;n<arrv.length;n++){
if(h!=n && arrv[h]==arrv[n] ) {
alert("please check IP address is not equll!");
return false;
}
}
}
}
function compare2(arrv){
var vidv="";
arrv=arrv.sort();
for(h=0;h<arrv.length;h++){
for (n=0;n<arrv.length;n++){
if(h!=n && arrv[h]==arrv[n] ) {
delete(arrv[n]);
}
}
}
var ca=0;
for(k=0;k<arrv.length;k++){
if(typeof(arrv[k])!="undefined"){
vidv+=((ca==0)?"":", ")+arrv[k]
ca++;
}
}
return vidv;
}
function compare3(sv){
f=document.forms[0];
var sendvidv="";
for(g=0;g<vidvarr.length;g++){
if(sv==vidvarr[g]){
if(f.mems[g].checked==1) sendvidv='1';
else sendvidv='0';
break;
}
}
return sendvidv;
}
function compare6(cv,arrv){
var retstatus="";
arrv=arrv.split(", ");
for(h=0;h<arrv.length;h++){
if(arrv[h]==cv)  {
retstatus="checked";
break;
} else if(arrv[h]!=cv){
retstatus="disabled";
}
}
return retstatus;
}
function compare7(cv,arrv,chkv,chknov){
var retstatus="disabled";
arrv=arrv.split(", ");
if(chknov==null){
for(h=0;h<arrv.length;h++){
if(arrv[h]==cv && chkv==1)  {
retstatus="checked";
break;
}else if (arrv[h]==cv && chkv==0){
retstatus="";
break;
}
}
}else{
for(h=0;h<arrv.length;h++){
if(arrv[h]==cv && chkv==1 && chknov==0)  {
retstatus="checked";
break;
}else if (arrv[h]==cv && chkv==0 && chknov==1){
retstatus="";
break;
}else if (arrv[h]==cv && chkv==0 && chknov==0){
retstatus="checked";
break;
}
}
}
return retstatus;
}
function chang_length(num){
if(num.length<=4){
var adnum=8-num.length;
for (j=0;j<adnum;j++){
num="0"+num;
}
}
return num;
}
function clear_sign(strv){
if(strv.indexOf(",")==1){
strv.substr(1,strv.length)
}else if(strv.lastIndexOf(",")==1){
strv.substr(0,strv.length-1)
}
}
function compare8(sv,modd){
f=document.forms[0];
var sendvidv="";
var mems_name1=eval("f.mems_"+modd+".length");
for(g=0;g<mems_name1;g++){
var mems_name2=eval("f.mems_"+modd+"["+g+"].value");
var mems_name3=eval("f.mems_"+modd+"["+g+"].checked");
if(sv==mems_name2){
if(mems_name3==1) sendvidv='1';
else sendvidv='0';
break;
}
}
return sendvidv;
}
function compare12(sv){
f=document.forms[0];
var vidvarr=new Array('1','2','3','4');
var sendvidv="";
for(g=0;g<vidvarr.length;g++){
if(sv==vidvarr[g]){
sendvidv='1';
break
}
else { sendvidv='0'; }
}
return sendvidv;
}
/*
compare_repeatvalue:
用途:比較重複的value值
目前應用於:vid,vlan_tagbase
Designer:Avril
*/
function compare_repeatvalue() {
flag = 0;
if(arguments.length == 3 && arguments[2] == 1)
{
var temp = []; arr1 = arguments[0] ; arr2 = arguments[1] ;
for (var i = 0; i < arr2.length; i++) {
if(arr2[i]>0) temp[arr2[i]] = true;
};
for (var i = 0; i < arr1.length; i++) {
if (temp[arr1[i]]==true) { flag=1; break; } ;
};
}
else if (arguments.length == 2 && arguments[1] == 2)
{
arr1 = arguments[0] ;
for(h = 0 ; h < arr1.length; h++)
{
for (n = 0 ; n < arr1.length; n++)
{
if( h != n && arr1[h] == arr1[n] && arr1[h]>0 ) { flag = 1; break; }
}
}
}
return flag;
}
/*
Combinevalue:
用途:將字串以特殊符號分離放置在所需對應的欄位內
objv:所需切割分離的值
idlist:將分離的值填入所對應的欄位的id名稱,需用"-"做區隔
ex:Combinevalue(100-200,aa-bb) =>aa=100 ; bb=200
目前應用於:qos_rulebasededit
Designer:Avril
*/
function Combinevalue(objv,idlist) {
var equalsign = objv.match(/\W/);
var idlist = idlist.split("-");
if(equalsign != -1)
{
arr = objv.split(equalsign);
for (var i = 0 ; i < arr.length ; i++)
{
document.getElementById(idlist[i]).value = arr[i];
}
}
else
{
document.getElementById(idlist).value = objv;
}
}
/*
getValues:
用途:取得字串某一段的值
v:欲使用的值
l:適合的模式
ex:getValues(192.168.123.100,1) =>100
Designer:Avril
*/
function getValues(v,l){
if(l==0) //取得前三個ip或mask
vv=v.substring(0,v.lastIndexOf(".")+1);
else if (l==1)
vv=v.substring(v.lastIndexOf(".")+1,v.length);
else if (l==2)
vv=v.substring(v.lastIndexOf("/")+1,v.lastIndexOf(")")-1);
return vv
}
/*
getmaskrange:
用途:取得陣列:DHCP_MASK "/"後的VALUE
v:MASK VALUE
ex:getmaskrange(255.255.255.0 (/30)) =>/30
目前應用於:qos_balance,qos_rulebased,qos_rulebasededit
Designer:Avril
*/
DHCP_MASK=new Array(
"255.0.0.0 (/8)",
"255.128.0.0 (/9)",
"255.192.0.0 (/10)",
"255.224.0.0 (/11)",
"255.240.0.0 (/12)",
"255.248.0.0 (/13)",
"255.252.0.0 (/14)",
"255.254.0.0 (/15)",
"255.255.0.0 (/16)",
"255.255.128.0 (/17)",
"255.255.192.0 (/18)",
"255.255.224.0 (/19)",
"255.255.240.0 (/20)",
"255.255.248.0 (/21)",
"255.255.252.0 (/22)",
"255.255.254.0 (/23)",
"255.255.255.0 (/24)",
"255.255.255.128 (/25)",
"255.255.255.192 (/26)",
"255.255.255.224 (/27)",
"255.255.255.240 (/28)",
"255.255.255.248 (/29)",
"255.255.255.252 (/30)",
"255.255.255.254 (/31)",
"255.255.255.255 (/32)"
)
function getmaskrange(v)
{
for(m = 0 ; m < DHCP_MASK.length ; m++)
{
if(DHCP_MASK[m].match(v)!=null) break;
}
vv = DHCP_MASK[m].match(/\/[0-9]+/);
return vv
}
function show_onoff(idd,v){
if(document.getElementById("tr_"+idd)) document.getElementById("tr_"+idd).style.display="" //dont remove this
xx=document.getElementById(idd)
for(a=1;a<xx.rows.length;a++){
xx.rows[a].style.display=(v==1)?'':'none'
}
document.getElementById(idd+"_add").style.display=(v==1)?'none':''
document.getElementById(idd+"_subtract").style.display=(v==1)?'':'none'
}
function add_empty_tr(idd){
xx=document.getElementById(idd)
if(xx.rows.length==1){ //only have <tr><th>.....
emp=xx.insertRow(1).insertCell(0)
emp.colSpan=10
emp.innerHTML=GetElmCont('_0','Empty')
emp.id="tr_"+idd
emp.style.display="none"
}
}
function get_csid_with_offset(csid_base, offset) {
if(typeof(offset)=="string") offset = parseInt(offset, 10);
var csid_type = csid_base.charAt(0); // first character is CSID type
var csid_addr = parseInt(csid_base.substring(1), 16) + offset; // parse the CSID address (hex string) to integer and then plus offset
var csid_addr_str = csid_addr.toString(16); // change from integer to hex string
var pad = "00000000";
var csid_addr_str = pad.substring(0, pad.length - csid_addr_str.length) + csid_addr_str; // padding head zeros to let address string length be 8
return csid_type + csid_addr_str;
}
function busy_loading(div_id) {
var totalTop=0;
var totalHeight=0;
var jobj = $('#'+div_id);
ckeckDivHeight(div_id);
var isIE = navigator.userAgent.search("MSIE") > -1;
if(isIE){// check using IE browser or not
totalHeight = jobj.height()+15;// the height div in IE8 browser need more 15px
totalTop = getScrollTop()+jobj.offset().top-15;// the starting side of div in IE8 browser need to pull up 15px
} else {// using other browsers except IE
totalHeight = jobj.height();
totalTop = jobj.offset().top;
}
$.fancybox.showLoading(); // show loading icon
$.fancybox.helpers.overlay.open({parent: jobj, closeClick : false, css : {
'position': 'absolute',
'height': totalHeight,
'width': jobj.width(),
'top': totalTop,
'left': jobj.offset().left,
'overflow': 'hidden'
}}); // show overlay to avoid user clicking in div
$(window).bind("resize", function() { // bind resize event to adjust the size of overlay
close_busy_loading();
busy_loading(div_id);
});
}
function close_busy_loading() {
$.fancybox.hideLoading(); // hide loading icon
$.fancybox.helpers.overlay.close(); // hide overlay
$(window).unbind("resize"); // unbind resize event
}
function getScrollTop() {// to get the scroll value in IE8
var scrollPos;
if (window.pageYOffset) {
scrollPos = window.pageYOffset;
}
else if (document.compatMode && document.compatMode != 'BackCompat') {
scrollPos = document.documentElement.scrollTop;
}
else if (document.body) {
scrollPos = document.body.scrollTop;
}
return scrollPos;
}
function ckeckDivHeight(div){// check div height exceeding 530px or not before using busy_loading
totalHeight = document.getElementById(div).offsetHeight;
if(totalHeight<530){
document.getElementById(div).style.height=530;
}
}