function change_cpu_type()
{
var type = document.getElementById("s_cpu_type").value;
var iframe = document.getElementById("i_cpu");
iframe.src = "dashboard_cpu_flow.htm?Ntype="+type+"&csrftok="+get_csrf_token();
}
function change_memory_type()
{
var type = document.getElementById("s_memory_type").value;
var iframe = document.getElementById("i_memory");
iframe.src = "dashboard_memory_flow.htm?Ntype="+type+"&csrftok="+get_csrf_token();
}
tfar=new Array("device_","type_","rx_","tx_","rxrate_","txrate_")
function show_uptime(utime){
if(utime=="") return;
utimes=utime.split(".");
uv=utimes[0];
up_day=parseInt(uv/(24*60*60));
up_hr=parseInt((uv%(24*60*60))/(60*60));
up_min=parseInt(((uv%(24*60*60))%(60*60))/60);
up_sec=parseInt((((uv%(24*60*60))%(60*60))%60));
timev=up_day+"day "+up_hr+"hr "+up_min+"min "+up_sec+"sec";
document.getElementById("upt").innerHTML=timev;
utime1=String(parseInt(utime)+1);
setTimeout("show_uptime(utime1)",1000);
}
function show_cpu_mem_ses(xmlDoc){
var iu = xmlDoc.getElementsByTagName("usage")[0].childNodes[0].nodeValue;
if(iu=="") iu = "0|0|0"; //CPU|MEMORY|SESSION
iu1=iu.split("|");
/*
var cpu_number = ("0" == "0")?4:0;
for(var x=0;x<cpu_number;x++)
{
document.getElementById("_sp"+(x+1)).innerHTML = iu1[x];
document.getElementById("_me"+(x+1)).value = iu1[x];
document.getElementById("t_cpu_"+(x+1)).style.display = "";
}
*/
document.getElementById("_me1").value = iu1[0];
document.getElementById("_me5").value = iu1[1];
document.getElementById("_me6").value = iu1[2];
document.getElementById("_sp1").innerHTML = iu1[0];
document.getElementById("_sp5").innerHTML = iu1[1];
document.getElementById("_sp6").innerHTML = iu1[2];
document.getElementById("t_cpu_1").style.display = "";
}
function change_dashboard_info(xmlDoc){
xx=document.getElementById('tab_traffic')
z=xmlDoc.getElementsByTagName("item")
if(z==null || z.length<=0)return;
if(xx.rows.length == 1){
for(i=0;i<z.length/6;i++){
if(z[i*6].getAttribute("name").indexOf("device")==-1) break;
xxr=xx.insertRow(i+1);
for(j=0;j<6;j++){
xxd=xxr.insertCell(j);
xxd.id=tfar[j]+i; //cell id=...ex. device_0 ,type_0, rx_0, tx_0, rxrate_0, txrate_0
}
}
}
else if(xx.rows.length-1!=z.length/6){
rl=xx.rows.length;
for(i=1;i<rl;i++){xx.deleteRow(1)}
change_dashboard_info(xmlDoc);
}
var unit = new Array("Bytes","KB","MB","GB","TB");
for(i=0;i<xx.rows.length-1;i++){
for(j=0;j<6;j++){
if(j<2) eval("document.getElementById('"+tfar[j]+i+"').innerHTML=z[i*6+j].childNodes[0].nodeValue;");
else{
ta=z[i*6+j].childNodes[0].nodeValue;
var sw_ta=0;
for(k=0;k<5;k++){
if(ta<1024){
use_unit=k;
sw_ta=ta+" ("+unit[k]+")";
break;
}
ta=Math.floor(ta/1024);
}
eval("document.getElementById('"+tfar[j]+i+"').innerHTML=sw_ta");
}
}
}
}
function sw_port_link(){
var div_obj =  document.getElementById("sw_port");
var sw_table="";
var tr1="";
var tr2="";
if(window.swm_phy_3g_4g1){
if(swm_phy_3g_4g1>0){
name_3g1=(swName_3G1.indexOf('USB')!=-1)?swName_3G1.replace("3G/4G",""):swName_3G1.replace("/4G","")
name_3g1=name_3g1.replace(" ","")
tr1+="<td align=center>"+name_3g1+"</td>"
tr2+="<td align=center id=port_3g1>"
img_3g1_up=(name_3g1.indexOf('USB')!=-1)?"<img src=usb_up.png width=35>":"<img src=3g_up.png width=35>"
img_3g1_down=(name_3g1.indexOf('USB')!=-1)?"<img src=usb_down.png width=35>":"<img src=3g_down.png width=35>"
tr2+="<span id=port_3g1_up style='display:none'>"+img_3g1_up+"</span>"
tr2+="<span id=port_3g1_down xstyle='display:none'>"+img_3g1_down+"</span>"
tr2+="</td>"
}
if(swm_phy_3g_4g2>0){
if(swName_3G1.slice(0,3)!=swName_3G2.slice(0,3)){
}
name_3g2=(swName_3G2.indexOf('USB')!=-1)?swName_3G2.replace("3G/4G",""):swName_3G2.replace("/4G","")
name_3g2=name_3g2.replace(" ","")
tr1+="<td align=center>"+name_3g2+"</td>"
tr2+="<td align=center id=port_3g2>"
img_3g2_up=(name_3g2.indexOf('USB')!=-1)?"<img src=usb_up.png width=35>":"<img src=3g_up.png width=35>"
img_3g2_down=(name_3g2.indexOf('USB')!=-1)?"<img src=usb_down.png width=35>":"<img src=3g_down.png width=35>"
tr2+="<span id=port_3g2_up style='display:none'>"+img_3g2_up+"</span>"
tr2+="<span id=port_3g2_down xstyle='display:none'>"+img_3g2_down+"</span>"
tr2+="</td>"
}
}
if(swm_wireless){
tr1+="<td>2.4G</td>"
tr2+="<td align=center id=port_wifi2g>"
tr2+="<span id=port_wifi2g_up xstyle='display:none'><img src=2.4g_up.png width=35></span>"
tr2+="<span id=port_wifi2g_down style='display:none'><img src=2.4g_down.png width=35></span>"
tr2+="</td>"
}
tr1+="<td>5G</td>"
tr2+="<td align=center id=port_wifi2g>"
tr2+="<span id=port_wifi5g_up xstyle='display:none'><img src=5g_up.png width=35></span>"
tr2+="<span id=port_wifi5g_down style='display:none'><img src=5g_down.png width=35></span>"
tr2+="</td>"
/*   tr1+="<td><img src=sp.gif width=10></td>"
tr2+="<td><img src=sp.gif width=10></td>"
tr1+="<td width=20>COM</td>"
tr2+="<td align=center id=port_com><img src=oth_down.png width=35></td>"
usb_power="0";
tr1+="<td>Power1</td>";
sta_power1_up=(usb_power=="1")?"":"style='display:none'";
sta_power1_down=(usb_power!="1")?"":"style='display:none'";
tr2+="<td align=center id=port_power1>"
tr2+="<span id=port_power1_up "+sta_power1_up+"><img src=power_up.png width=30></span>"
tr2+="<span id=port_power1_down "+sta_power1_down+"><img src=power_down.png width=30></span>"
tr2+="</td>"
tr1+="<td>Power2</td>";
sta_power2_up=(usb_power=="2")?"":"style='display:none'";
sta_power2_down=(usb_power!="2")?"":"style='display:none'";
tr2+="<td align=center id=port_power2>"
tr2+="<span id=port_power2_up "+sta_power2_up+"><img src=power_up.png width=30></span>"
tr2+="<span id=port_power2_down "+sta_power2_down+"><img src=power_down.png width=30></span>"
tr2+="</td>"
*/
sw_table+="<table border=0 align=center height=118 class=port_link_out><tr><td width=56 style=\"background-image:url('port_bg_l.png');background-repeat:no-repeat;\"></td><td background=port_bg_in.png>";
sw_table+="<table border=0 align=center class='port_link'><tr>";
sw_table+=tr1;
sw_table+="</tr><tr>";
sw_table+=tr2;
sw_table+="</tr></table>";
sw_table+="</td><td width=58 style=\"background-image:url('port_bg_r.png');background-repeat:no-repeat;\"></td></tr></table>";
div_obj.innerHTML =sw_table;
}
function update_port(xmlDoc)
{
sw_3g1=xmlDoc.getElementsByTagName("port_3g1")[0].childNodes[0].nodeValue;
if(document.getElementById("port_3g1")){
document.getElementById("port_3g1_up").style.display=(sw_3g1==2)?"":"none";
document.getElementById("port_3g1_down").style.display=(sw_3g1!=2)?"":"none";
}
sw_3g2=xmlDoc.getElementsByTagName("port_3g2")[0].childNodes[0].nodeValue;
if(document.getElementById("port_3g2")){
document.getElementById("port_3g2_up").style.display=(sw_3g2==2)?"":"none";
document.getElementById("port_3g2_down").style.display=(sw_3g2!=2)?"":"none";
}
if(swm_wireless){
sw_wifi2g = xmlDoc.getElementsByTagName("port_wifi2g")[0].childNodes[0].nodeValue;
document.getElementById("port_wifi2g_up").style.display=(sw_wifi2g==1)?"":"none";
document.getElementById("port_wifi2g_down").style.display=(sw_wifi2g!=1)?"":"none";
}
sw_wifi5g=xmlDoc.getElementsByTagName("port_wifi5g")[0].childNodes[0].nodeValue;
document.getElementById("port_wifi5g_up").style.display=(sw_wifi5g==1)?"":"none";
document.getElementById("port_wifi5g_down").style.display=(sw_wifi5g!=1)?"":"none";
/*     sw_com=xmlDoc.getElementsByTagName("port_com")[0].childNodes[0].nodeValue;
if(document.getElementById("port_com")) document.getElementById("port_com").innerHTML=(sw_com==1)?"<img src=oth_up.png width=35>":"<img src=oth_down.png width=35>";
sw_power=xmlDoc.getElementsByTagName("port_power")[0].childNodes[0].nodeValue;
if(document.getElementById("port_power1")){
document.getElementById("port_power1_up").style.display=(sw_power==1)?"":"none";
document.getElementById("port_power1_down").style.display=(sw_power!=1)?"":"none";
}
if(document.getElementById("port_power2")){
document.getElementById("port_power2_up").style.display=(sw_power==2)?"":"none";
document.getElementById("port_power2_down").style.display=(sw_power!=2)?"":"none";
}
*/
}
function change_poe_info()
{
$.ajax({
url:'poe.xml',
type: 'GET',
dataType:'xml',
error: function(xml){
},
success: function(xml){
var list_str="",show_pdclass="";
var list_length = $(xml).find("outsts").length;
var table = $("#tab_poe");
$("#tab_poe tr").remove("tr:gt(0)");
for(var a = 0 ; a < list_length ; a++)
{
var outsts = $(xml).find("outsts").eq(a).text();
var pdclass = $(xml).find("pdclass").eq(a).text();
switch (parseInt(pdclass))
{
case 0:
show_pdclass = GetElmCont("_0","N/A (Power Off)");
break;
case 1:
show_pdclass = GetElmCont("_0","PD Classification 1 (4W)");
break;
case 2:
show_pdclass = GetElmCont("_0","PD Classification 2 (7W)");
break;
case 3:
show_pdclass = GetElmCont("_0","PD Classification 3 (15.4W)");
break;
case 4:
show_pdclass = GetElmCont("_0","PD Classification 4 (30W)");
break;
case 5:
show_pdclass = GetElmCont("_0","PD Classification Error");
break;
case 99:
show_pdclass = GetElmCont("_0","PD Classification 0 (Default)");
break;
default:
show_pdclass = GetElmCont("_0","N/A (Power Off)");
}
var voltage = $(xml).find("voltage").eq(a).text();
var currents = $(xml).find("currents").eq(a).text();
var consumption = $(xml).find("consumption").eq(a).text();
list_str += "<tr align='center'>";
list_str += "<td>Port-"+(a+1)+"</td>";
list_str += "<td>"+((outsts == 0) ? "OFF" : "ON")+"&nbsp;</td>";
list_str += "<td>"+show_pdclass+"&nbsp;</td>";
list_str += "<td>"+(voltage/10)+"&nbsp;</td>";
list_str += "<td>"+currents+"&nbsp;</td>";
list_str += "<td>"+(consumption/1000)+"&nbsp;</td>";
list_str += "</tr>";
}
table.append(list_str);
}
});
}