document.write('');
var cgipaddress = document.location.hostname;
var g_cgiport = 80;
var initialA;
var g_xmlHttp = null;
if(cgipaddress == ""){
cgipaddress = "10.10.89.145";
initialA = "http://" + cgipaddress + ":" + g_cgiport + "/cgi-bin/";
}else{
initialA = "/cgi-bin/";
}
function GetObject(){
g_xmlHttp = null;
if (window.XMLHttpRequest) { //éžIE
g_xmlHttp = new XMLHttpRequest();
} else if (window.ActiveXObject) {//IE
try {
g_xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
g_xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
alertUpdateBrowser();
}
}
}
}
function Communicate(cmdid, cmddata ,callback){
if(g_xmlHttp){
closeCommunicate();
}
GetObject();
if (g_xmlHttp != null) {
cmdid = initialA + cmdid + ".cgi";
g_xmlHttp.onreadystatechange = callback;
g_xmlHttp.open("POST", cmdid, true);
g_xmlHttp.send(JSON.stringify(cmddata));
} else {
alertUpdateBrowser();
}
}
function Communicate2(cmdid, cmddata ,callback){
if(g_xmlHttp){
closeCommunicate();
}
GetObject();
if (g_xmlHttp != null) {
cmdid = initialA + cmdid + ".cgi";
g_xmlHttp.onreadystatechange = callback;
g_xmlHttp.open("POST", cmdid, false);
g_xmlHttp.send(JSON.stringify(cmddata));
} else {
alertUpdateBrowser();
}
}
function GetWebConfig(filename, callback){
if(g_xmlHttp){
closeCommunicate();
}
GetObject();
if (g_xmlHttp != null) {
cmdid = "http://" + cgipaddress + ":" + g_cgiport + "/" + filename;
g_xmlHttp.onreadystatechange = callback;
g_xmlHttp.open("GET", cmdid, true);
g_xmlHttp.send(null);
} else {
alertUpdateBrowser();
}
}
function CheckGetResponse(){
if ( null == g_xmlHttp ) {
alert("null == this");
return "";
}
if(g_xmlHttp.readyState == 4){
var result;
if (g_xmlHttp.status == 200){
try{
result = JSON.parse(g_xmlHttp.responseText);
}catch(e){
throw new Error("ioe_Response_Invalid");
}
if (result == null) {
throw new Error("ioe_No_Response");
}
} else {
throw new Error("ioe_Server_Err");
}
return result;
}
return "";
}
function alertUpdateBrowser() {
alert("AJAX needed,please update your browser!");
}
function CheckResponse(a){
if ( null == g_xmlHttp ) {
alert("null == this");
return "";
}
if(g_xmlHttp.readyState == 4){
var result;
if (g_xmlHttp.status == 200){
try{
result = JSON.parse(g_xmlHttp.responseText);
}catch(e){
throw new Error("ioe_Response_Invalid");
}
if (result == null) {
throw new Error("ioe_No_Response");
} else if (result.Ret != 100 && result.Ret != 603 && a == void 0){
throw new Error(getErrorStr(result.Ret));
}
} else if(this.status != 0){
throw new Error("ioe_Server_Err");
}
return result;
}
return "";
}
function CheckResponseEx() {
if ( null == this ) {
return "";
}
// 排除时间åŽé¢æœ‰\n的情况
if (this.readyState == 4) {
var result;
if (this.status == 200){
try {
result = JSON.parse(this.responseText);
} catch (e) {
try {
var newResponse = this.responseText.replace(/:00\n/g, ":00");
result = JSON.parse(newResponse);
} catch (ex) {
throw new Error("ioe_Response_Invalid");
}
}
if (result == null) {
throw new Error("ioe_No_Response");
} else if (result.Ret != 100 && result.Ret != 603){
throw new Error(getErrorStr(result.Ret));
}
} else if(this.status != 0){
throw new Error("ioe_Server_Err");
}
return result;
}
return "";
}
function getErrorStr(nError){
var strError;
switch(nError){
case 101:
strError = "ioe_Sys_Busy";
break;
case -1:
strError = "ioe_Opr_Failed";
break;
case -2:
strError = "ioe_NoPermission";
break;
case 603:
strError = "ioe_Need_Reboot";
break;
default:
strError= "ioe_Unknow_Err";
break;
}
return strError;
}
var cloneObj = function (obj) {
var newObj = {};
if (obj instanceof Array) {
newObj = [];
}
for (var key in obj) {
var val = obj[key];
if(typeof val === 'object' && val != null ) {
newObj[key] = cloneObj(val);
}else{
newObj[key] = val;
}
}
return newObj;
}
function toHex(number, min) {
var hexes = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' ];
var hex = '';
var min = min || 2;
var nibble;
var len = 0;
do {
nibble = number & 0x0f;
number = number >> 4;
hex = hexes[nibble] + hex;
len += 1;
} while (number);
var temp = "";
while (len < min) {
temp = "0" + temp;
len += 1;
}
temp += hex;
return '0x' + temp;
}
function closeCommunicate(){
if(g_xmlHttp){
g_xmlHttp.abort();
g_xmlHttp = null;
}
}
function isObject(obj){
return null !== obj && 'object' === typeof obj;
}
function SetCurComboData(ComBoxID, data){
var nSel = -1;
for (var i = 0; i < $(ComBoxID)[0].options.length; i++) {
if ($(ComBoxID)[0].options[i].value == data) {
nSel = i;
break;
}
}
$(ComBoxID)[0].selectedIndex = nSel;
return nSel;
}
function GetCurComboData(ComBoxID){
var nSel = $(ComBoxID)[0].selectedIndex;
if(nSel < 0) return -1;
var nData = $(ComBoxID)[0].options[nSel].value;
nData = parseInt(nData);
return nData;
}
function GetComboData(ComBoxID, index){
if(index > $(ComBoxID)[0].options.length || index < 0) return -1;
var nData = $(ComBoxID)[0].options[index].value;
nData = parseInt(nData);
return nData;
}