function copy_statistics_fields(ix,sx,type,alter){ //index,show interface,Traffic WAN Interface(local,multi,3g1,3g2....)
if(document.getElementById("traff")){
if(type!="x"){
/*Ū�쪺�Ȭ�Bytes,*8/1024/1024�নMb,�L�����i�������p�Ʋ�2��*/
var rxv=Math.ceil(parseInt(document.getElementById("wan_"+type+"_rx").innerHTML)*8/1024/1024*100)/100;
var txv=Math.ceil(parseInt(document.getElementById("wan_"+type+"_tx").innerHTML)*8/1024/1024*100)/100;
document.getElementById('s_statistics_interface'+ix).innerHTML=document.getElementById(sx).innerHTML;
document.getElementById('s_statistics_receive'+ix).innerHTML=rxv;
document.getElementById('s_statistics_transmit'+ix).innerHTML=txv;
}
else{ //wan disabled
document.getElementById('s_statistics_interface'+ix).innerHTML='&nbsp';
document.getElementById('s_statistics_receive'+ix).innerHTML='-';
document.getElementById('s_statistics_transmit'+ix).innerHTML='-';
}
}
}
/*
ps.IPv4 Status�ݭncopy fields,�]��wan1��wan2 interface�|����,�i��wan1=ethernet, wan2=3g,�]�i���ϹL�ө�wan=ADSL
statistics�O�]����shellex�����Y
IPv6 Status��LAN Status..�������O�T�w��,�u�nŪCSID�N�n
*/
function copy_v4wan_fields(ind        ,s1         ,s2        ,s3          ,s4          ,s5            ,s6           ,s7         ,s8            ,s9   ,s10                    ,s11           ,s12              ,s13){
document.getElementById('s_v4_interface'+ind).innerHTML=document.getElementById(s1).innerHTML;
document.getElementById('s_v4_wantype'+ind).innerHTML=document.getElementById(s2).innerHTML;
document.getElementById('s_v4_ipaddr'+ind).innerHTML=document.getElementById(s3).innerHTML;
document.getElementById('s_v4_subnet'+ind).innerHTML=document.getElementById(s4).innerHTML;
document.getElementById('s_v4_gateway'+ind).innerHTML=document.getElementById(s5).innerHTML;
document.getElementById('s_v4_dns'+ind).innerHTML=document.getElementById(s6).innerHTML;
document.getElementById('s_v4_mac'+ind).innerHTML=s7;
document.getElementById('s_v4_conn'+ind).innerHTML=s8;
document.getElementById('s_v4_action'+ind).innerHTML=document.getElementById(s9).innerHTML;
copy_statistics_fields(ind,s1,s10,s11)
document.getElementById('s_v4_ntype'+ind).innerHTML=s12;
if (ind==0) {
if(document.getElementById('s_v6_interface0').innerHTML != "&nbsp;"){
document.getElementById('s_v6_interface0').innerHTML = document.getElementById('s_v4_interface0').innerHTML;
if(s1.indexOf('3g')!=-1){
document.getElementById('s_v6_wantype0').innerHTML = GetElmCont('ipv6_0','IPv6');
}
var v6_conn = document.getElementById('s_v6_conn0');
v6_conn.innerHTML+="<br>"+get_conntimev(document.getElementById('s_v6_time0').innerHTML);
if(document.getElementById(s13).innerHTML == 1){
document.getElementById('s_v6_action0').innerHTML="<input type=\"button\" id=_wary_0 value="+GetElmCont("wary_0","Edit")+" onclick=\"GURL('ipv6.htm?rc=')\">";
}
}
}
}
function set_v4wan_value(){
for(i=0;i<swm_phy_wan_nmber;i++){
if(ALL_INDEXV_sta[i]!="" && ALL_INDEXV_sta[i]!="0"){
if(ALL_INDEXV_sta[i]==99){
macv=ALL_mac_sta[0]
if(macv=="") macv="&nbsp;"
connv=get_connv(local_conn[0]);
connv+="<br>"+ get_conntimev(document.getElementById('ether_time').innerHTML);
ntypev=get_ntypev("eth",document.getElementById("ether_nat").innerHTML);
if(document.getElementById("ether_wtype").innerHTML=="Bridge") connv="N/A" //bridge no connection status
document.getElementById('ether_inter').innerHTML=swName_Eth1;
var traff_type="local";
copy_v4wan_fields(i,"ether_inter","ether_wtype","ether_ip","ether_subnet","ether_gateway","ether_dns",macv,connv,"ether_action",traff_type,"N80010803",ntypev,"ether_cnt")
}
else if(ALL_INDEXV_sta[i]==1){
macv=ALL_mac_sta[1]
if(macv=="") macv="&nbsp;"
connv=get_connv(multi_conn[0]);
connv+="<br>"+ get_conntimev(document.getElementById('multi0_time').innerHTML);
ntypev=get_ntypev("eth",document.getElementById("multi0_nat").innerHTML);
if(document.getElementById("multi0_wtype").innerHTML=="Bridge") connv="N/A" //bridge no connection status
var traff_type="multi";
copy_v4wan_fields(i,"multi0_inter","multi0_wtype","multi0_ip","multi0_subnet","multi0_gateway","multi0_dns",macv,connv,"multi0_action",traff_type,"N80010810",ntypev,"multi0_action");
}
else if(ALL_INDEXV_sta[i]==2){
macv=ALL_mac_sta[2]
if(macv=="") macv="&nbsp;"
connv=get_connv(multi_conn[1]);
connv+="<br>"+ get_conntimev(document.getElementById('multi1_time').innerHTML);
ntypev=get_ntypev("eth",document.getElementById("multi1_nat").innerHTML);
if(document.getElementById("multi1_wtype").innerHTML=="Bridge") connv="N/A" //bridge no connection status
var traff_type="multi";
copy_v4wan_fields(i,"multi1_inter","multi1_wtype","multi1_ip","multi1_subnet","multi1_gateway","multi1_dns",macv,connv,"multi1_action",traff_type,"N80010811",ntypev,"multi1_action");
}
else if(ALL_INDEXV_sta[i]==3){
macv=ALL_mac_sta[3]
if(macv=="") macv="&nbsp;"
connv=get_connv(multi_conn[2]);
connv+="<br>"+ get_conntimev(document.getElementById('multi2_time').innerHTML);
ntypev=get_ntypev("eth",document.getElementById("multi2_nat").innerHTML);
if(document.getElementById("multi2_wtype").innerHTML=="Bridge") connv="N/A" //bridge no connection status
var traff_type="multi";
copy_v4wan_fields(i,"multi2_inter","multi2_wtype","multi2_ip","multi2_subnet","multi2_gateway","multi2_dns",macv,connv,"multi2_action",traff_type,"N80010812",ntypev,"multi2_action");
}
else if(ALL_INDEXV_sta[i]==4){
macv=ALL_mac_sta[4]
if(macv=="") macv="&nbsp;"
connv=get_connv(multi_conn[3]);
connv+="<br>"+ get_conntimev(document.getElementById('multi3_time').innerHTML);
ntypev=get_ntypev("eth",document.getElementById("multi3_nat").innerHTML);
if(document.getElementById("multi3_wtype").innerHTML=="Bridge") connv="N/A" //bridge no connection status
var traff_type="multi";
copy_v4wan_fields(i,"multi3_inter","multi3_wtype","multi3_ip","multi3_subnet","multi3_gateway","multi3_dns",macv,connv,"multi3_action",traff_type,"N80010813",ntypev,"multi3_action");
}
else if(ALL_INDEXV_sta[i]==5){
macv=ALL_mac_sta[5]
if(macv=="") macv="&nbsp;"
connv=get_connv(multi_conn[4]);
connv+="<br>"+ get_conntimev(document.getElementById('multi4_time').innerHTML);
ntypev=get_ntypev("eth",document.getElementById("multi4_nat").innerHTML);
if(document.getElementById("multi4_wtype").innerHTML=="Bridge") connv="N/A" //bridge no connection status
var traff_type="multi";
copy_v4wan_fields(i,"multi4_inter","multi4_wtype","multi4_ip","multi4_subnet","multi4_gateway","multi4_dns",macv,connv,"multi4_action",traff_type,"N80010814",ntypev,"multi4_action");
}
else if(ALL_INDEXV_sta[i]==6){
macv=ALL_mac_sta[6]
if(macv=="") macv="&nbsp;"
connv=get_connv(multi_conn[5]);
connv+="<br>"+ get_conntimev(document.getElementById('multi5_time').innerHTML);
ntypev=get_ntypev("eth",document.getElementById("multi5_nat").innerHTML);
if(document.getElementById("multi5_wtype").innerHTML=="Bridge") connv="N/A" //bridge no connection status
var traff_type="multi";
copy_v4wan_fields(i,"multi5_inter","multi5_wtype","multi5_ip","multi5_subnet","multi5_gateway","multi5_dns",macv,connv,"multi5_action",traff_type,"N80010815",ntypev,"multi5_action");
}
else if(ALL_INDEXV_sta[i]==7){
macv=ALL_mac_sta[7]
if(macv=="") macv="&nbsp;"
connv=get_connv(multi_conn[6]);
connv+="<br>"+ get_conntimev(document.getElementById('multi6_time').innerHTML);
ntypev=get_ntypev("eth",document.getElementById("multi6_nat").innerHTML);
if(document.getElementById("multi6_wtype").innerHTML=="Bridge") connv="N/A" //bridge no connection status
var traff_type="multi";
copy_v4wan_fields(i,"multi6_inter","multi6_wtype","multi6_ip","multi6_subnet","multi6_gateway","multi6_dns",macv,connv,"multi6_action",traff_type,"N80010816",ntypev,"multi6_action");
}
else if(ALL_INDEXV_sta[i]==8){
macv=ALL_mac_sta[8]
if(macv=="") macv="&nbsp;"
connv=get_connv(multi_conn[7]);
connv+="<br>"+ get_conntimev(document.getElementById('multi7_time').innerHTML);
ntypev=get_ntypev("eth",document.getElementById("multi7_nat").innerHTML);
if(document.getElementById("multi7_wtype").innerHTML=="Bridge") connv="N/A" //bridge no connection status
var traff_type="multi";
copy_v4wan_fields(i,"multi7_inter","multi7_wtype","multi7_ip","multi7_subnet","multi7_gateway","multi7_dns",macv,connv,"multi7_action",traff_type,"N80010817",ntypev,"multi7_action");
}
else if(ALL_INDEXV_sta[i]==9){
macv=ALL_mac_sta[9]
if(macv=="") macv="&nbsp;"
connv=get_connv(multi_conn[8]);
connv+="<br>"+ get_conntimev(document.getElementById('multi8_time').innerHTML);
ntypev=get_ntypev("eth",document.getElementById("multi8_nat").innerHTML);
if(document.getElementById("multi8_wtype").innerHTML=="Bridge") connv="N/A" //bridge no connection status
var traff_type="multi";
copy_v4wan_fields(i,"multi8_inter","multi8_wtype","multi8_ip","multi8_subnet","multi8_gateway","multi8_dns",macv,connv,"multi8_action",traff_type,"N80010818",ntypev,"multi8_action");
}
else if(ALL_INDEXV_sta[i]==10){
macv=ALL_mac_sta[10]
if(macv=="") macv="&nbsp;"
connv=get_connv(multi_conn[9]);
connv+="<br>"+ get_conntimev(document.getElementById('multi9_time').innerHTML);
ntypev=get_ntypev("eth",document.getElementById("multi9_nat").innerHTML);
if(document.getElementById("multi9_wtype").innerHTML=="Bridge") connv="N/A" //bridge no connection status
var traff_type="multi";
copy_v4wan_fields(i,"multi9_inter","multi9_wtype","multi9_ip","multi9_subnet","multi9_gateway","multi9_dns",macv,connv,"multi9_action",traff_type,"N80010819",ntypev,"multi9_action");
}
else if(ALL_INDEXV_sta[i]==11){
macv=ALL_mac_sta[11]
if(macv=="") macv="&nbsp;"
connv=get_connv(multi_conn[10]);
connv+="<br>"+ get_conntimev(document.getElementById('multi10_time').innerHTML);
ntypev=get_ntypev("eth",document.getElementById("multi10_nat").innerHTML);
if(document.getElementById("multi10_wtype").innerHTML=="Bridge") connv="N/A" //bridge no connection status
var traff_type="multi";
copy_v4wan_fields(i,"multi10_inter","multi10_wtype","multi10_ip","multi10_subnet","multi10_gateway","multi10_dns",macv,connv,"multi10_action",traff_type,"N8001081A",ntypev,"multi10_action");
}
else if(ALL_INDEXV_sta[i]==12){
macv=ALL_mac_sta[12]
if(macv=="") macv="&nbsp;"
connv=get_connv(multi_conn[11]);
connv+="<br>"+ get_conntimev(document.getElementById('multi11_time').innerHTML);
ntypev=get_ntypev("eth",document.getElementById("multi11_nat").innerHTML);
if(document.getElementById("multi11_wtype").innerHTML=="Bridge") connv="N/A" //bridge no connection status
var traff_type="multi";
copy_v4wan_fields(i,"multi11_inter","multi11_wtype","multi11_ip","multi11_subnet","multi11_gateway","multi11_dns",macv,connv,"multi11_action",traff_type,"N8001081B",ntypev,"multi11_action");
}
else if(ALL_INDEXV_sta[i]==13){
macv=ALL_mac_sta[13]
if(macv=="") macv="&nbsp;"
connv=get_connv(multi_conn[12]);
connv+="<br>"+ get_conntimev(document.getElementById('multi12_time').innerHTML);
ntypev=get_ntypev("eth",document.getElementById("multi12_nat").innerHTML);
if(document.getElementById("multi12_wtype").innerHTML=="Bridge") connv="N/A" //bridge no connection status
var traff_type="multi";
copy_v4wan_fields(i,"multi12_inter","multi12_wtype","multi12_ip","multi12_subnet","multi12_gateway","multi12_dns",macv,connv,"multi12_action",traff_type,"N8001081C",ntypev,"multi12_action");
}
else if(ALL_INDEXV_sta[i]==14){
connv=get_connv(multi_conn[13]);
connv+="<br>"+ get_conntimev(document.getElementById('_3g1_time').innerHTML);
ntypev=get_ntypev("3g",document.getElementById("_3g1_nat").innerHTML,document.getElementById("_3g1_ippass").innerHTML,document.getElementById("_3g1_ippass2").innerHTML);
document.getElementById('_3g1_inter').innerHTML=swName_3G1;
copy_v4wan_fields(i,"_3g1_inter","_3g1_wtype","_3g1_ip","_3g1_subnet","_3g1_gateway","_3g1_dns","N/A",connv,"_3g1_action","3g1","N8001081D",ntypev,"_3g1_cnt")
}
else if(ALL_INDEXV_sta[i]==15 && swm_phy_3g_4g2 > 0){
connv=get_connv(multi_conn[14]);
connv+="<br>"+ get_conntimev(document.getElementById('_3g2_time').innerHTML);
ntypev=get_ntypev("3g",document.getElementById("_3g2_nat").innerHTML,document.getElementById("_3g2_ippass").innerHTML,document.getElementById("_3g2_ippass2").innerHTML);
document.getElementById('_3g2_inter').innerHTML=swName_3G2;
copy_v4wan_fields(i,"_3g2_inter","_3g2_wtype","_3g2_ip","_3g2_subnet","_3g2_gateway","_3g2_dns","N/A",connv,"_3g2_action","3g2","N8001081E",ntypev,"_3g2_cnt")
}
else if(ALL_INDEXV_sta[i]==16){
var isbridge=document.getElementById("wisp_bridge_1").innerHTML;
if(isbridge=="1"){
connv=get_connv(document.getElementById("wisp_sta_1").innerHTML);
}else{
connv=get_connv(multi_conn[15]);
}
connv+="<br>"+ get_conntimev(document.getElementById('wisp_time_1').innerHTML);
ntypev=get_ntypev("wisp",document.getElementById("wisp_nat_1").innerHTML,isbridge);
document.getElementById('wisp_inter_1').innerHTML="WIFI Module 1";
copy_v4wan_fields(i,"wisp_inter_1","wisp_wtype_1","wisp_ip_1","wisp_subnet_1","wisp_gateway_1","wisp_dns_1","N/A",connv,"wisp_action_1","wisp1","N8001081F",ntypev,"wisp_cnt_1")
}
else if(ALL_INDEXV_sta[i]==15 && swm_phy_wisp2 > 0){
var isbridge=document.getElementById("wisp_bridge_2").innerHTML;
if(isbridge=="1"){
connv=get_connv(document.getElementById("wisp_sta_2").innerHTML);
}else{
connv=get_connv(multi_conn[14]);
}
connv+="<br>"+ get_conntimev(document.getElementById('wisp_time_2').innerHTML);
ntypev=get_ntypev("wisp",document.getElementById("wisp_nat_2").innerHTML,isbridge);
document.getElementById('wisp_inter_2').innerHTML="WIFI Module 2";
copy_v4wan_fields(i,"wisp_inter_2","wisp_wtype_2","wisp_ip_2","wisp_subnet_2","wisp_gateway_2","wisp_dns_2","N/A",connv,"wisp_action_2","wisp2","N8001081E",ntypev,"wisp_cnt_2")
}
}
else{ //WAN type disabled
macv="&nbsp;"
connv="&nbsp;"
copy_v4wan_fields(i,"show_nbsp","show_disable","show_nbsp","show_nbsp","show_nbsp","show_nbsp",macv,connv,"show_edit","x","x","&nbsp;")
}
}
if(typeof(swm_vwan_g2)!="undefined"){
if(swm_vwan_g2) {set_vwan_value();}
}
}
function set_vwan_value(){
var vwan_record=document.getElementById('vwan_record').innerHTML;
for(a=0;a<16;a++){
document.getElementById('tr_vwan'+a).style.display="none";
}
if (vwan_record == ""||vwan_record == "&nbsp;") {return;}
var arys=vwan_record.split(",");
for (i=0, len = arys.length; i < len;i++){
var vid = arys[i];
var venalbe = document.getElementById('vwan_enable_'+vid).innerHTML;
if(venalbe == "1"){
var vwan_inter = document.getElementById('vwan_inter_'+vid).innerHTML;
document.getElementById('s_vwan_interface'+i).innerHTML = swName_idx[vwan_inter];
if(vwan_inter=="14"||vwan_inter=="15"){
document.getElementById('s_vwan_wantype'+i).innerHTML =GetElmCont("sta_0","3G/4G");
}
document.getElementById('s_vwan_ipaddr'+i).innerHTML = document.getElementById('vwan_ip_'+vid).innerHTML;
document.getElementById('s_vwan_subnet'+i).innerHTML = document.getElementById('vwan_subnet_'+vid).innerHTML;
document.getElementById('s_vwan_gateway'+i).innerHTML = document.getElementById('vwan_gateway_'+vid).innerHTML;
document.getElementById('s_vwan_dns'+i).innerHTML = document.getElementById('vwan_dns_'+vid).innerHTML;
document.getElementById('s_vwan_conn'+i).innerHTML = get_connv(document.getElementById('vwan_conn_'+vid).innerHTML)+"<br>"+ get_conntimev(document.getElementById('vwan_time_'+vid).innerHTML);
document.getElementById('s_vwan_action'+i).innerHTML = document.getElementById('vwan_action_'+vid).innerHTML;
document.getElementById('tr_vwan'+i).style.display="";
}
}
}
function get_connv(v){ //$S_LOCAL_WAN_STATUS or $S_LOCAL_MULTIWAN_STATUS[0~15]
if(v==0) return GetElmCont("wary_0","Disconnected")
else if(v==1) return GetElmCont("wary_0","Connecting...")
else if(v==2) return GetElmCont("wary_0","Connected")
else if(v==3) return GetElmCont("wary_0","Disconnecting...")
else if(v==5) return GetElmCont("wary_0","Wait for traffic...")
else if(v==6) return GetElmCont("wary_0","Disconnected")
else return GetElmCont("wary_0","Disconnected")
}
function get_ntypev(wtype,v1,v2,v3){
if (wtype == "3g" && (v2 == "1"||v3 == "1")){
return GetElmCont("wary_0","IP Passthrough")
}else if (wtype == "wisp" && v2 == "1"){
return GetElmCont("sta_0","Bridge")
}else{
return (v1 == "1")?GetElmCont("abasic_0","Routing"):GetElmCont("wary_0","NAT");
}
}
function get_conntimev(v){
if (v=="0"||v=="-") return "-"
var utime = v.split(":");
var uh = parseInt(utime[0]).toString(10);
var ud = parseInt(uh/24).toString(10);;
var uh2 = uh%24;
var swtime=ud+" day "+ uh2 + ":" + utime[1] + ":" + utime[2];
return swtime
}