var xml="gnss.xml?rc=";
var rhost_index = [];
var rhost_next_index = 0;
var rhost_max_number = 10;
var rhost_count =0;
/*
Add/Delete/Edit external server
rhost_record_csid => �n��J C_WEBUI_GNSS_RM_RECORD ���U�@�� index �ΨӰO��Ū��CSID ������
rhost_next_index => �U�@���� index  �� C_GNSS_RM_HOSTIP �Ĥ@�Ӫťժ�CSID
*/
var rhost_record_csid = [];
var rhost_name_csid = [];
var rhost_ip_csid= [];
var rhost_protocol_csid= [];
var rhost_port_num_csid= [];
var rhost_iterval_csid = [];
var rhost_prefix_msg_csid = [];
var rhost_suffix_msg_csid = [];
var rhost_enable_csid = [];
rhost_record_csid.push("N00202920");
rhost_name_csid.push("S00B60020");
rhost_ip_csid.push("I00B60030");
rhost_protocol_csid.push("N00B60040");
rhost_port_num_csid.push("N00B60050");
rhost_iterval_csid.push("N00B60060");
rhost_prefix_msg_csid.push("S00B60070");
rhost_suffix_msg_csid.push("S00B60080");
rhost_enable_csid.push("N00B60010");
rhost_record_csid.push("N00202921");
rhost_name_csid.push("S00B60021");
rhost_ip_csid.push("I00B60031");
rhost_protocol_csid.push("N00B60041");
rhost_port_num_csid.push("N00B60051");
rhost_iterval_csid.push("N00B60061");
rhost_prefix_msg_csid.push("S00B60071");
rhost_suffix_msg_csid.push("S00B60081");
rhost_enable_csid.push("N00B60011");
rhost_record_csid.push("N00202922");
rhost_name_csid.push("S00B60022");
rhost_ip_csid.push("I00B60032");
rhost_protocol_csid.push("N00B60042");
rhost_port_num_csid.push("N00B60052");
rhost_iterval_csid.push("N00B60062");
rhost_prefix_msg_csid.push("S00B60072");
rhost_suffix_msg_csid.push("S00B60082");
rhost_enable_csid.push("N00B60012");
rhost_record_csid.push("N00202923");
rhost_name_csid.push("S00B60023");
rhost_ip_csid.push("I00B60033");
rhost_protocol_csid.push("N00B60043");
rhost_port_num_csid.push("N00B60053");
rhost_iterval_csid.push("N00B60063");
rhost_prefix_msg_csid.push("S00B60073");
rhost_suffix_msg_csid.push("S00B60083");
rhost_enable_csid.push("N00B60013");
rhost_record_csid.push("N00202924");
rhost_name_csid.push("S00B60024");
rhost_ip_csid.push("I00B60034");
rhost_protocol_csid.push("N00B60044");
rhost_port_num_csid.push("N00B60054");
rhost_iterval_csid.push("N00B60064");
rhost_prefix_msg_csid.push("S00B60074");
rhost_suffix_msg_csid.push("S00B60084");
rhost_enable_csid.push("N00B60014");
rhost_record_csid.push("N00202925");
rhost_name_csid.push("S00B60025");
rhost_ip_csid.push("I00B60035");
rhost_protocol_csid.push("N00B60045");
rhost_port_num_csid.push("N00B60055");
rhost_iterval_csid.push("N00B60065");
rhost_prefix_msg_csid.push("S00B60075");
rhost_suffix_msg_csid.push("S00B60085");
rhost_enable_csid.push("N00B60015");
rhost_record_csid.push("N00202926");
rhost_name_csid.push("S00B60026");
rhost_ip_csid.push("I00B60036");
rhost_protocol_csid.push("N00B60046");
rhost_port_num_csid.push("N00B60056");
rhost_iterval_csid.push("N00B60066");
rhost_prefix_msg_csid.push("S00B60076");
rhost_suffix_msg_csid.push("S00B60086");
rhost_enable_csid.push("N00B60016");
rhost_record_csid.push("N00202927");
rhost_name_csid.push("S00B60027");
rhost_ip_csid.push("I00B60037");
rhost_protocol_csid.push("N00B60047");
rhost_port_num_csid.push("N00B60057");
rhost_iterval_csid.push("N00B60067");
rhost_prefix_msg_csid.push("S00B60077");
rhost_suffix_msg_csid.push("S00B60087");
rhost_enable_csid.push("N00B60017");
rhost_record_csid.push("N00202928");
rhost_name_csid.push("S00B60028");
rhost_ip_csid.push("I00B60038");
rhost_protocol_csid.push("N00B60048");
rhost_port_num_csid.push("N00B60058");
rhost_iterval_csid.push("N00B60068");
rhost_prefix_msg_csid.push("S00B60078");
rhost_suffix_msg_csid.push("S00B60088");
rhost_enable_csid.push("N00B60018");
rhost_record_csid.push("N00202929");
rhost_name_csid.push("S00B60029");
rhost_ip_csid.push("I00B60039");
rhost_protocol_csid.push("N00B60049");
rhost_port_num_csid.push("N00B60059");
rhost_iterval_csid.push("N00B60069");
rhost_prefix_msg_csid.push("S00B60079");
rhost_suffix_msg_csid.push("S00B60089");
rhost_enable_csid.push("N00B60019");
var protocol=["TCP","UDP"]
function swReHost_list()
{
var t=new Date()
xmlDoc=loadXMLDocs(xml+"&ZT="+t.getTime());
if(xmlDoc==null)return;
rhost_index.length=0;
var div = document.getElementById("sw_rhost_list");
var chk_add=0;
var table_str = "<table width=100% border=0 align=center cellpadding=0 cellspacing=0 class='staball'>"
table_str += "<tr class='staball_sum'>";
table_str += "<th width='3%'><span id='_0'>ID</span></th>";
table_str += "<th width='10%'><span id='_stalanlist_0'>Host Name</span></th>";
table_str += "<th width='10%'><span id='_prim_0'>Host IP</span></th>";
table_str += "<th width='5%'><span id='_0'>Protocol Type</span></th>";
table_str += "<th width='8%'><span id='_lanset_0'>Port Number</span></th>";
table_str += "<th width='8%'><span id='_0'>Interval(s)</span></th>";
table_str += "<th width='15%'><span id='_0'>Prefix Message</span></th>";
table_str += "<th width='15%'><span id='_0'>Suffix Message</span></th>";
table_str += "<th width='5%'><span id='_wary_0'>Enable</span></th>";
table_str += "<th width='12%'><span id='_sta_0'>Actions</span></th>";
table_str += "</tr>";
var list_id=0;
for(var x=0;x<rhost_max_number;x++)
{
rhost_rule_index = xmlDoc.getElementsByTagName("rhost_record")[x].childNodes[0];
if(rhost_rule_index != null)
{
index = parseInt(rhost_rule_index.nodeValue);
xml_index = (index-1);
list_id=list_id+1;
rhost_name = xml_getvalue(xmlDoc,"rhost_name",xml_index);
rhost_ip = xml_getvalue(xmlDoc,"rhost_ip",xml_index);
rhost_protocol = xml_getvalue(xmlDoc,"rhost_protocol",xml_index);
rhost_port_num = xml_getvalue(xmlDoc,"rhost_port_num",xml_index);
rhost_iterval = xml_getvalue(xmlDoc,"rhost_iterval",xml_index);
rhost_prefix_msg = xml_getvalue(xmlDoc,"rhost_prefix_msg",xml_index);
rhost_suffix_msg = xml_getvalue(xmlDoc,"rhost_suffix_msg",xml_index);
rhost_enable = xml_getvalue(xmlDoc,"rhost_enable",xml_index);
var enable_check = "";
enable_check = (rhost_enable == 1)?"checked":"";
protocol_type= (rhost_protocol == "")?"":protocol[rhost_protocol];
table_str += "<tr align='center' style='word-break:break-all'>"
table_str += "<td>"+list_id+"</td>"
table_str += "<td>"+rhost_name+"&nbsp;</td>"
table_str += "<td>"+rhost_ip+"&nbsp;</td>"
table_str += "<td>"+protocol_type+"&nbsp;</td>"
table_str += "<td>"+rhost_port_num+"&nbsp;</td>"
table_str += "<td>"+rhost_iterval+"&nbsp;</td>"
table_str += "<td>"+rhost_prefix_msg+"&nbsp;</td>"
table_str += "<td>"+rhost_suffix_msg+"&nbsp;</td>"
table_str += "<td><input type='checkbox' name='rhost_rule' "+enable_check+" disabled>&nbsp;</td>"
button = "<input type='button' id='_wary_0' value='Edit' onclick=\"edit_account(this,'rhost',"+xml_index+")\">";
button += "<input type='checkbox' name='rhost_del' value='"+(index)+"'><span id=_wary_0>Select</span>";
table_str += "<td align='center'>"+button+"</td>"
table_str += "</tr>"
rhost_index.push(index);
}
}
/*
rhost_count�O���ثe�ϥμ�
�b�ثe�ϥμƤp��̤j�ϥμƮɡA�q0��ثe�ϥμ�+1�h��U�@�ӰO������m
�g��rhost_next_index
*/
rhost_count = rhost_index.length;
if(rhost_index.length < rhost_max_number){
for(var x=0;x<=rhost_index.length;x++)
{
rhost_ip = xml_getvalue(xmlDoc,"rhost_ip",x);
if(rhost_ip == "")
{
rhost_next_index = x;
break;
}
}
}
table_str += "</table>";
div.innerHTML = table_str;
}
function add_account(obj,type)
{
if(rhost_count >= rhost_max_number)
{
alert(GetElmCont("dhcp_0","Rule could not be added anymore."));
}
else
{
obj.form.action = "gnssrule.htm";
obj.form.Nrhostmod.value = 1; //add
obj.form.Nrhostlen.value = rhost_count;
obj.form.Nrule.value = rhost_next_index;
obj.form.submit();
}
}
function edit_account(obj,type,idx)
{
rhost_url='/gnssrule.htm?rc=&Nrule='+idx;
GURL(rhost_url)
}
function del_tunnel(type)
{
var tmp_del = document.getElementsByName(type+"_del");
var record_index = eval(type+"_index");
var record_csid = eval(type+"_record_csid");
var del_arr = new Array();
var index = 0;
var new_index = 0;
var sent_str ="gnss.htm?rc=";
var iframe = document.getElementById("ifm_"+type+"list");
for(var t=0;t<tmp_del.length;t++)
{
if(tmp_del[t].checked)
{
del_arr[index] = tmp_del[t].value;
index++;
}
}
if(del_arr.length == 0)
{
alert(GetElmCont("lb_0","Please choose one or more rule."));
return false;
}
for(var r=0;r<record_index.length;r++)
{
for(var n=0;n<del_arr.length;n++)
{
if(record_index[r] == del_arr[n])
{
record_index[r] = "";
}
}
}
for(var a=0;a<record_index.length;a++)
{
if(record_index[a] != "")
{
sent_str += "&"+record_csid[new_index]+"="+record_index[a];
new_index++;
}
}
for(var c=new_index;c<record_csid.length;c++)
{
sent_str += "&"+record_csid[c]+"=";
}
for(var r=0;r<del_arr.length;r++)
{
var tunlname_index = del_arr[r]-1;
if(type=="rhost"){
sent_str += "&"+eval("rhost_name_csid["+tunlname_index+"]")+"=";
sent_str += "&"+eval("rhost_ip_csid["+tunlname_index+"]")+"=";
sent_str += "&"+eval("rhost_protocol_csid["+tunlname_index+"]")+"=";
sent_str += "&"+eval("rhost_port_num_csid["+tunlname_index+"]")+"=";
sent_str += "&"+eval("rhost_iterval_csid["+tunlname_index+"]")+"=";
sent_str += "&"+eval("rhost_prefix_msg_csid["+tunlname_index+"]")+"=";
sent_str += "&"+eval("rhost_suffix_msg_csid["+tunlname_index+"]")+"=";
sent_str += "&"+eval("rhost_enable_csid["+tunlname_index+"]")+"=0";
}
}
sent_str += "&N80B60001=1";
GURL(sent_str);
}