function inArr(arr,itm)
{
for(aa=0;aa<arr.length;aa++)
{
if(arr[aa]==itm)return true;
}
return false;
}
var open_win;
function openwin(url,sx,sy)
{
var width=sx;
var height=sy;
open_win=window.open('','_new','width='+width+',height='+height+',resizable=yes,scrollbars=yes,status=yes,menubar=no,toolbar=no');
open_win.focus();
open_win.location.href = url;
open_win.opener = window;
}
function SPgTl(tl,hplk,ind)
{// Help format : Domain Filter - Help
if(arguments.length==2)
{
if(hplk.indexOf("|")==-1) tl=(hplk.indexOf("h-")==-1)?tl+" - "+GetElmCont('wary_0','Help')+"</span>":tl
}
dw("<TABLE WIDTH=100% HEIGHT=27 BORDER=0 CELLPADDING=0 CELLSPACING=0 class='L4title'><TR>")
dw("<TD nowrap><IMG SRC=sp.gif WIDTH=10 HEIGHT=27 ALIGN=ABSMIDDLE><IMG SRC=dot1.gif WIDTH=16 HEIGHT=9 ALIGN=ABSMIDDLE>"+tl+"</TD>")
if(arguments.length==2)
{
if(hplk.indexOf("|")!=-1)
{
e=hplk.split("|")
lkn=e[0]
hplk=e[1]
}
else lkn=(hplk.indexOf("h-")!=-1)?GetElmCont('wary_0','Help'):GetElmCont('wary_88','Back')
if(hplk=="prim")
dw("<TD ALIGN=RIGHT><A HREF='javascript:history.go(-1)'>[ "+lkn+" ]</A></TD>")
else
dw("<TD ALIGN=RIGHT><A HREF='"+clk(hplk)+"'>[ "+lkn+" ]</A></TD>")
}
if(login && arguments.length==3){ //show refresh button
if(ind=="x"){ //show edit button
dw("<td width=75% align=left><input type=button id=_wary_0 value=Edit onclick=\"GURL('"+hplk+"')\"></td>")
}
else{         //show refresh button
dw("<td width=75% align=left><input type=button id=_wary_0 value=Refresh onclick=\"rlist('sta_refresh.xml?rc=&Nrd="+ind+"');showdbm()\"></td>")
}
}
dw("</TR></TABLE>")
}
function swb(lb,ws,rb)
{
sstr="<TABLE BORDER=0 WIDTH=100% ALIGN=CENTER CELLPADDING=0 CELLSPACING=0><TR>"
sstr+="<TD CLASS=wbl WIDTH=10%>"+lb+"</TD>"
sstr+="<TD WIDTH=80%><div CLASS=wbc>"+ws+"</div></TD>"
sstr+="<TD CLASS=wbr WIDTH=10%>"+rb+"</TD></TR></TABLE>"
if(arguments.length==4)return sstr;
else dw(sstr)
}
tabs=new Array('tab','stab','ltab','ttab','tab0','tab1','sxtab','tab50')
for(t=2;t<25;t++)tabs[tabs.length]='tab'+t
for(t=0;t<10;t++)tabs[tabs.length]='tab4'+t
for(t=0;t<6;t++)tabs[tabs.length]='ptab'+t
for(t=0;t<10;t++)tabs[tabs.length]='wtab'+t
for(t=0;t<26;t++)tabs[tabs.length]='stab'+t
function setTabStyle2()
{
for(p=0;p<tabs.length;p++)
{
if(document.getElementById(tabs[p])==null)continue;
setTabStyle(tabs[p])
}
}
function setTabStyle(tab)
{
x=document.getElementById(tab)
if(x!=null)
{
x.cellPadding=0;
x.cellSpacing=0;
if(x.rows==null) return
xrowl=x.rows.length
for(i=0;i<xrowl;i++)
{
xrcl=x.rows[i].cells.length
for(j=0;j<xrcl;j++)
{
xij=x.rows[i].cells[j]
if(xij.innerHTML=='')xij.innerHTML='&nbsp;'
if(j<xrcl-1) {xij.style.borderRight ="1px solid #666666"
}
if((i<xrowl-1)||(x.id.substring(0,1)!='s'))
{xij.style.borderBottom="1px solid #666666"
}
}
}
}
}
function setMaxLen(item,len)
{
eval("document.forms[0]."+item+".maxLength="+len)
}
function insert(tosel,pos,opt)
{
tosell=tosel.length
if(pos>tosell) tosel.options[tosell+1]=opt
else
{
for(i2=tosell;i2>pos;i2--)
{
st=tosel.options[i2-1].text
sv=tosel.options[i2-1].value
sht=new Option(st,sv)
tosel.options[i2]=sht
}
tosel.options[pos]=opt
}
}
function swelm(div,sw)
{
ddiv=document.getElementById(div)
if(ddiv!=null)ddiv.style.display=(sw)?'':'none';
}
function swids(div,sw)
{
for(d=0;d<arguments.length;d+=2)
{
ddiv=document.getElementById(arguments[d]);
if(ddiv!=null)ddiv.style.display=(arguments[d+1])?'':'none';
}
}
function swid(div,sw)
{
swids.apply(this,arguments); // just call swids() instead of writing the same code
}
function swidary(divary,sw)
{
for(d=0;d<divary.length;d++)
{
ddiv=document.getElementById(divary[d])
if(ddiv!=null)ddiv.style.display=(sw)?'':'none';
}
}
function findInArr(findstr,arr)
{
for (x in arr)
{
if(arr[x].indexOf(findstr)!=-1)return x
}
return 0
}
function findSelectIndex(selobj,searchval)
{
for(o=0;o<selobj.length;o++)
{
if(selobj.options[o].value==searchval){return o}
}
return false;
}
function links(link)
{
if((link.indexOf('.')==-1)&&(link.indexOf('=')==-1)&&(link.indexOf('javascript:')==-1))link=""+link+".htm"
return link
}
function diselm(obj,sw)
{
for(p=0;p<arguments.length/2;p++)
{
ddiv=document.getElementById(arguments[p*2])
if(ddiv!=null)ddiv.disabled=!(arguments[p*2+1]);
}
}
function showsPg(pgs)
{
pgss=pgs.split("#")
pg=pgss[0].split("|") //diff. with showsPgX
pgl3=pgss[1].split("~")
wid="100%"
dw("<table class='L3menu' cellPadding=0 cellSpacing=0 border=0 width="+wid+"><tr><td><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0><TR>")
dw("<td height=30>&nbsp;&nbsp;&nbsp;</td>")
for(i=0;i<pg.length;i++)
{
showl3=(pg[i].indexOf("remove_this")!=-1)? "style='display:none'" : ""
pga=pg[i].split("~")
L3ID=pgl3[i] //L3 TAID
lk = append_url( links(pga[1]) ); // append CSRF token at the tail of url
if(pga[2]=="")  //selected item.  //diff. with showsPgX
{
dw("<TD id=TA_"+L3ID+" NOWRAP><div class='LM3_mouse'><img src=dot2.gif height=10><B><A HREF="+lk+">"+pga[0]+"</A></B></div></TD>");
}
else
{
dw("<TD NOWRAP><div id=TA_"+L3ID+" "+ showl3 +"  class='LM3' onMouseOver=\"changeClass('TA_"+L3ID+"','LM3_mouse');changeImg('IMG_"+L3ID+"','dot2.gif');\" onMouseOut=\"changeClass('TA_"+L3ID+"','LM3');changeImg('IMG_"+L3ID+"','dot1.gif');\"><img id='IMG_"+L3ID+"' src=dot1.gif height=10><B><A HREF="+lk+">"+pga[0]+"</A></B></div></TD>");
}
}
dw("</TR></TABLE></TD></TR></TABLE>")
dw("<div class='LM3_hr'></div>");
}
function progress_time()
{
/*
ps1.
大部份status頁面因有read xml的關係
所以永遠不會被code logout
set force_logout=1, 由UI來force logout這些頁面
*/
if(force_logout==1) GURL("/log/out?rd=/index.htm"); //check ps1.
xhr = createXHR()
if (xhr) {
xhr.onreadystatechange = progress_time_update
xhr.open("GET", "timeout.xml", true)
xhr.send(null)
}
else {
alert("xhr fail")
}
}
function progress_time_update() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var xmldoc = xhr.responseXML
db = xmldoc.getElementsByTagName("login")[0].childNodes[0].nodeValue
if(db==7) setTimeout('progress_time()',add_tout*1000); //not time out
else top.location="/index.htm" //time out
}
}
}
var timeout_timer;
var force_logout=0;
function showdbm(num){
if(num==0){ //只有剛進入才讀num=0
document.getElementById("s_3gmodem_signal1").innerHTML="Detecting"
}
else{
if(document.getElementById("_sgn1")){ //only in status.htm
sgnv=document.getElementById("_sgn1").innerHTML
dbmv=document.getElementById("_dbm1").innerHTML
if(sgnv>0){
if(sgnv==2){
if(dbmv<=77){
document.getElementById("s_3gmodem_signal1").innerHTML="<img src='dbm_5.gif'>"+"(-"+dbmv+" dBm)"
}
else if((dbmv>=78) && (dbmv<=85)){
document.getElementById("s_3gmodem_signal1").innerHTML="<img src='dbm_4.gif'>"+"(-"+dbmv+" dBm)"
}
else if((dbmv>=86) && (dbmv<=92)){
document.getElementById("s_3gmodem_signal1").innerHTML="<img src='dbm_3.gif'>"+"(-"+dbmv+" dBm)"
}
else if((dbmv>=93) && (dbmv<=101)){
document.getElementById("s_3gmodem_signal1").innerHTML="<img src='dbm_2.gif'>"+"(-"+dbmv+" dBm)"
}
else if((dbmv>=102) && (dbmv<=109)){
document.getElementById("s_3gmodem_signal1").innerHTML="<img src='dbm_1.gif'>"+"(-"+dbmv+" dBm)"
}
else if(dbmv>=110){
document.getElementById("s_3gmodem_signal1").innerHTML="N/A"
}
else{
document.getElementById("s_3gmodem_signal1").innerHTML="N/A"
}
}
else if(sgnv==3){
if(dbmv>=-77){
document.getElementById("s_3gmodem_signal1").innerHTML="<img src='dbm_5.gif'>"+"("+dbmv+" dBm)"
}
else if((dbmv>=-85) && (dbmv<=-78)){
document.getElementById("s_3gmodem_signal1").innerHTML="<img src='dbm_4.gif'>"+"("+dbmv+" dBm)"
}
else if((dbmv>=-92) && (dbmv<=-86)){
document.getElementById("s_3gmodem_signal1").innerHTML="<img src='dbm_3.gif'>"+"("+dbmv+" dBm)"
}
else if((dbmv>=-101) && (dbmv<=-93)){
document.getElementById("s_3gmodem_signal1").innerHTML="<img src='dbm_2.gif'>"+"("+dbmv+" dBm)"
}
else if((dbmv>=-109) && (dbmv<=-102)){
document.getElementById("s_3gmodem_signal1").innerHTML="<img src='dbm_1.gif'>"+"("+dbmv+" dBm)"
}
else if(dbmv<=-110){
document.getElementById("s_3gmodem_signal1").innerHTML="N/A"
}
else{
document.getElementById("s_3gmodem_signal1").innerHTML="N/A"
}
}
else if(sgnv==7){
if(dbmv>=-89){
document.getElementById("s_3gmodem_signal1").innerHTML="<img src='dbm_5.gif'>"+" ("+dbmv+" dBm)"
}
else if((dbmv>=-99) && (dbmv<=-90)){
document.getElementById("s_3gmodem_signal1").innerHTML="<img src='dbm_4.gif'>"+" ("+dbmv+" dBm)"
}
else if((dbmv>=-104) && (dbmv<=-100)){
document.getElementById("s_3gmodem_signal1").innerHTML="<img src='dbm_3.gif'>"+" ("+dbmv+" dBm)"
}
else if((dbmv>=-114) && (dbmv<=-105)){
document.getElementById("s_3gmodem_signal1").innerHTML="<img src='dbm_2.gif'>"+" ("+dbmv+" dBm)"
}
else if((dbmv>=-119) && (dbmv<=-115)){
document.getElementById("s_3gmodem_signal1").innerHTML="<img src='dbm_1.gif'>"+" ("+dbmv+" dBm)"
}
else if(dbmv<=-120){
document.getElementById("s_3gmodem_signal1").innerHTML="N/A"
}
else{
document.getElementById("s_3gmodem_signal1").innerHTML="N/A"
}
}
}
else{
document.getElementById("s_3gmodem_signal1").innerHTML="N/A"
}
}
}
if(num==0){ //只有剛進入才讀num=0
document.getElementById("s_3gmodem_signal2").innerHTML="Detecting"
}
else{
if(document.getElementById("_sgn2")){ //only in status.htm
sgnv=document.getElementById("_sgn2").innerHTML
dbmv=document.getElementById("_dbm2").innerHTML
if(sgnv>0){
if(sgnv==2){
if(dbmv<=77){
document.getElementById("s_3gmodem_signal2").innerHTML="<img src='dbm_5.gif'>"+"(-"+dbmv+" dBm)"
}
else if((dbmv>=78) && (dbmv<=85)){
document.getElementById("s_3gmodem_signal2").innerHTML="<img src='dbm_4.gif'>"+"(-"+dbmv+" dBm)"
}
else if((dbmv>=86) && (dbmv<=92)){
document.getElementById("s_3gmodem_signal2").innerHTML="<img src='dbm_3.gif'>"+"(-"+dbmv+" dBm)"
}
else if((dbmv>=93) && (dbmv<=101)){
document.getElementById("s_3gmodem_signal2").innerHTML="<img src='dbm_2.gif'>"+"(-"+dbmv+" dBm)"
}
else if((dbmv>=102) && (dbmv<=109)){
document.getElementById("s_3gmodem_signal2").innerHTML="<img src='dbm_1.gif'>"+"(-"+dbmv+" dBm)"
}
else if(dbmv>=110){
document.getElementById("s_3gmodem_signal2").innerHTML="N/A"
}
else{
document.getElementById("s_3gmodem_signal2").innerHTML="N/A"
}
}
else if(sgnv==3){
if(dbmv>=-77){
document.getElementById("s_3gmodem_signal2").innerHTML="<img src='dbm_5.gif'>"+"("+dbmv+" dBm)"
}
else if((dbmv>=-85) && (dbmv<=-78)){
document.getElementById("s_3gmodem_signal2").innerHTML="<img src='dbm_4.gif'>"+"("+dbmv+" dBm)"
}
else if((dbmv>=-92) && (dbmv<=-86)){
document.getElementById("s_3gmodem_signal2").innerHTML="<img src='dbm_3.gif'>"+"("+dbmv+" dBm)"
}
else if((dbmv>=-101) && (dbmv<=-93)){
document.getElementById("s_3gmodem_signal2").innerHTML="<img src='dbm_2.gif'>"+"("+dbmv+" dBm)"
}
else if((dbmv>=-109) && (dbmv<=-102)){
document.getElementById("s_3gmodem_signal2").innerHTML="<img src='dbm_1.gif'>"+"("+dbmv+" dBm)"
}
else if(dbmv<=-110){
document.getElementById("s_3gmodem_signal2").innerHTML="N/A"
}
else{
document.getElementById("s_3gmodem_signal2").innerHTML="N/A"
}
}
else if(sgnv==7){
if(dbmv>=-89){
document.getElementById("s_3gmodem_signal2").innerHTML="<img src='dbm_5.gif'>"+" ("+dbmv+" dBm)"
}
else if((dbmv>=-99) && (dbmv<=-90)){
document.getElementById("s_3gmodem_signal2").innerHTML="<img src='dbm_4.gif'>"+" ("+dbmv+" dBm)"
}
else if((dbmv>=-104) && (dbmv<=-100)){
document.getElementById("s_3gmodem_signal2").innerHTML="<img src='dbm_3.gif'>"+" ("+dbmv+" dBm)"
}
else if((dbmv>=-114) && (dbmv<=-105)){
document.getElementById("s_3gmodem_signal2").innerHTML="<img src='dbm_2.gif'>"+" ("+dbmv+" dBm)"
}
else if((dbmv>=-119) && (dbmv<=-115)){
document.getElementById("s_3gmodem_signal2").innerHTML="<img src='dbm_1.gif'>"+" ("+dbmv+" dBm)"
}
else if(dbmv<=-120){
document.getElementById("s_3gmodem_signal2").innerHTML="N/A"
}
else{
document.getElementById("s_3gmodem_signal2").innerHTML="N/A"
}
}
}
else{
document.getElementById("s_3gmodem_signal2").innerHTML="N/A"
}
}
}
}
function telstra(){
var s=document.getElementById("_sgn1").innerHTML;
var k=document.getElementById("_name1").innerHTML;
if(k.indexOf("Telstra")>=0){
if(s==3){
document.getElementById("s_3gmodem_network1").innerHTML="Telstra "+"(3G)"
}
else if(s==7){
document.getElementById("s_3gmodem_network1").innerHTML="Telstra "+"(4G)"
}
else if(s==2){
document.getElementById("s_3gmodem_network1").innerHTML="N/A"
}
else{ //這個else是為了第一次進入時先保留之前顯示的資訊，因為之後重連(Reconnect)不會再跑這裡了
document.getElementById("s_3gmodem_network1").innerHTML="N/A"
}
}
else{
document.getElementById("s_3gmodem_network1").innerHTML=document.getElementById("_name1").innerHTML;
}
var s=document.getElementById("_sgn2").innerHTML;
var k=document.getElementById("_name2").innerHTML;
if(k.indexOf("Telstra")>=0){
if(s==3){
document.getElementById("s_3gmodem_network2").innerHTML="Telstra "+"(3G)"
}
else if(s==7){
document.getElementById("s_3gmodem_network2").innerHTML="Telstra "+"(4G)"
}
else if(s==2){
document.getElementById("s_3gmodem_network2").innerHTML="N/A"
}
else{ //這個else是為了第一次進入時先保留之前顯示的資訊，因為之後重連(Reconnect)不會再跑這裡了
document.getElementById("s_3gmodem_network2").innerHTML="N/A"
}
}
else{
document.getElementById("s_3gmodem_network2").innerHTML=document.getElementById("_name2").innerHTML;
}
}
function up_adslFW(){
alert("ADSL fw version is outdated, please confirm to upgarde the new one!")
GURL('hide.htm?rc=&Nrd=4')
}
function chg_interface(page)
{
var inter = document.getElementById("s_interface");
GURL(page+".htm?Nindex="+inter.value+"&Nrefresh=1");
}