var request; function doRequestAsync(v, func) { try { request = new XMLHttpRequest(); } catch(e) { try { request = new ActiveXObject("MSXML2.XMLHTTP.3.0");; } catch(e) { try { request = new ActieXObject("Msxml2.XMLHTTP"); } catch(e) { try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert("You cannot run this web"); return false; } } } } try { request.onreadystatechange = func; request.open("GET", v , true, top.gAccount, top.gPwd) ; request.setRequestHeader("Cache-Control","no-cache"); request.setRequestHeader("Content-Type", "text/plain;charset=utf-8"); request.setRequestHeader("Pragma","no-cache"); request.setRequestHeader("Expires","0"); request.setRequestHeader("Last-Modified","Wed, 1 Jan 1997 00:00:00 GMT"); request.setRequestHeader("If-Modified-Since","01"); request.send(); } catch(e) { alert(v +'\n'+ e.description); } } function doXMLDOMRequestAsync(v, func) { var url = "/cgi-bin/system?" ; url += "USER=" + top.gAccount + "&PWD=" + top.gPwd + "&"; url += v; xmlhttp=new XMLHttpRequest(); xmlhttp.open("GET", url , true) ; xmlhttp.send(); return xmlhttp; } //-- getCookie ########################################################################### function getCookie(c_name) { if (document.cookie.length>0){ var c_start=document.cookie.indexOf(c_name + "="); if (c_start!=-1){ c_start=c_start + c_name.length+1 ; c_end=document.cookie.indexOf(";",c_start); if (c_end==-1) c_end=document.cookie.length return unescape(document.cookie.substring(c_start,c_end)); } } return "" } //-- setCookie ########################################################################### function setCookie(c_name,value,expiredays){ var today = new Date(); var exdate=new Date(); exdate.setTime(today.getTime() + 1000*60*60*24*7);//keep for one week document.cookie=c_name+ "=" +escape(value)+"; expires="+exdate.toUTCString(); } //-- idget ########################################################################### function idget(a){ return document.getElementById(a); } //-- doRequest ########################################################################### MD5 = function(e) { function h(a, b) { var c, d, e, f, g; e = a & 2147483648; f = b & 2147483648; c = a & 1073741824; d = b & 1073741824; g = (a & 1073741823) + (b & 1073741823); return c & d ? g ^ 2147483648 ^ e ^ f : c | d ? g & 1073741824 ? g ^ 3221225472 ^ e ^ f : g ^ 1073741824 ^ e ^ f : g ^ e ^ f } function k(a, b, c, d, e, f, g) { a = h(a, h(h(b & c | ~b & d, e), g)); return h(a << f | a >>> 32 - f, b) } function l(a, b, c, d, e, f, g) { a = h(a, h(h(b & d | c & ~d, e), g)); return h(a << f | a >>> 32 - f, b) } function m(a, b, d, c, e, f, g) { a = h(a, h(h(b ^ d ^ c, e), g)); return h(a << f | a >>> 32 - f, b) } function n(a, b, d, c, e, f, g) { a = h(a, h(h(d ^ (b | ~c), e), g)); return h(a << f | a >>> 32 - f, b) } function p(a) { var b = "", d = "", c; for (c = 0; 3 >= c; c++) d = a >>> 8 * c & 255, d = "0" + d.toString(16), b += d.substr(d.length - 2, 2); return b } var f = [], q, r, s, t, a, b, c, d; e = function(a) { a = a.replace(/\r\n/g, "\n"); for (var b = "", d = 0; d < a.length; d++) { var c = a.charCodeAt(d); 128 > c ? b += String.fromCharCode(c) : (127 < c && 2048 > c ? b += String.fromCharCode(c >> 6 | 192) : (b += String.fromCharCode(c >> 12 | 224), b += String.fromCharCode(c >> 6 & 63 | 128)), b += String.fromCharCode(c & 63 | 128)) } return b }(e); f = function(b) { var a, c = b.length; a = c + 8; for (var d = 16 * ((a - a % 64) / 64 + 1), e = Array(d - 1), f = 0, g = 0; g < c;) a = (g - g % 4) / 4, f = g % 4 * 8, e[a] |= b.charCodeAt(g) << f, g++; a = (g - g % 4) / 4; e[a] |= 128 << g % 4 * 8; e[d - 2] = c << 3; e[d - 1] = c >>> 29; return e }(e); a = 1732584193; b = 4023233417; c = 2562383102; d = 271733878; for (e = 0; e < f.length; e += 16) q = a, r = b, s = c, t = d, a = k(a, b, c, d, f[e + 0], 7, 3614090360), d = k(d, a, b, c, f[e + 1], 12, 3905402710), c = k(c, d, a, b, f[e + 2], 17, 606105819), b = k(b, c, d, a, f[e + 3], 22, 3250441966), a = k(a, b, c, d, f[e + 4], 7, 4118548399), d = k(d, a, b, c, f[e + 5], 12, 1200080426), c = k(c, d, a, b, f[e + 6], 17, 2821735955), b = k(b, c, d, a, f[e + 7], 22, 4249261313), a = k(a, b, c, d, f[e + 8], 7, 1770035416), d = k(d, a, b, c, f[e + 9], 12, 2336552879), c = k(c, d, a, b, f[e + 10], 17, 4294925233), b = k(b, c, d, a, f[e + 11], 22, 2304563134), a = k(a, b, c, d, f[e + 12], 7, 1804603682), d = k(d, a, b, c, f[e + 13], 12, 4254626195), c = k(c, d, a, b, f[e + 14], 17, 2792965006), b = k(b, c, d, a, f[e + 15], 22, 1236535329), a = l(a, b, c, d, f[e + 1], 5, 4129170786), d = l(d, a, b, c, f[e + 6], 9, 3225465664), c = l(c, d, a, b, f[e + 11], 14, 643717713), b = l(b, c, d, a, f[e + 0], 20, 3921069994), a = l(a, b, c, d, f[e + 5], 5, 3593408605), d = l(d, a, b, c, f[e + 10], 9, 38016083), c = l(c, d, a, b, f[e + 15], 14, 3634488961), b = l(b, c, d, a, f[e + 4], 20, 3889429448), a = l(a, b, c, d, f[e + 9], 5, 568446438), d = l(d, a, b, c, f[e + 14], 9, 3275163606), c = l(c, d, a, b, f[e + 3], 14, 4107603335), b = l(b, c, d, a, f[e + 8], 20, 1163531501), a = l(a, b, c, d, f[e + 13], 5, 2850285829), d = l(d, a, b, c, f[e + 2], 9, 4243563512), c = l(c, d, a, b, f[e + 7], 14, 1735328473), b = l(b, c, d, a, f[e + 12], 20, 2368359562), a = m(a, b, c, d, f[e + 5], 4, 4294588738), d = m(d, a, b, c, f[e + 8], 11, 2272392833), c = m(c, d, a, b, f[e + 11], 16, 1839030562), b = m(b, c, d, a, f[e + 14], 23, 4259657740), a = m(a, b, c, d, f[e + 1], 4, 2763975236), d = m(d, a, b, c, f[e + 4], 11, 1272893353), c = m(c, d, a, b, f[e + 7], 16, 4139469664), b = m(b, c, d, a, f[e + 10], 23, 3200236656), a = m(a, b, c, d, f[e + 13], 4, 681279174), d = m(d, a, b, c, f[e + 0], 11, 3936430074), c = m(c, d, a, b, f[e + 3], 16, 3572445317), b = m(b, c, d, a, f[e + 6], 23, 76029189), a = m(a, b, c, d, f[e + 9], 4, 3654602809), d = m(d, a, b, c, f[e + 12], 11, 3873151461), c = m(c, d, a, b, f[e + 15], 16, 530742520), b = m(b, c, d, a, f[e + 2], 23, 3299628645), a = n(a, b, c, d, f[e + 0], 6, 4096336452), d = n(d, a, b, c, f[e + 7], 10, 1126891415), c = n(c, d, a, b, f[e + 14], 15, 2878612391), b = n(b, c, d, a, f[e + 5], 21, 4237533241), a = n(a, b, c, d, f[e + 12], 6, 1700485571), d = n(d, a, b, c, f[e + 3], 10, 2399980690), c = n(c, d, a, b, f[e + 10], 15, 4293915773), b = n(b, c, d, a, f[e + 1], 21, 2240044497), a = n(a, b, c, d, f[e + 8], 6, 1873313359), d = n(d, a, b, c, f[e + 15], 10, 4264355552), c = n(c, d, a, b, f[e + 6], 15, 2734768916), b = n(b, c, d, a, f[e + 13], 21, 1309151649), a = n(a, b, c, d, f[e + 4], 6, 4149444226), d = n(d, a, b, c, f[e + 11], 10, 3174756917), c = n(c, d, a, b, f[e + 2], 15, 718787259), b = n(b, c, d, a, f[e + 9], 21, 3951481745), a = h(a, q), b = h(b, r), c = h(c, s), d = h(d, t); return (p(a) + p(b) + p(c) + p(d)).toLowerCase() } function getDigestAuthorizationString(name, pwd, method, url) { var realm = "Authenticate Service"; var nonce = "b7b67757c9f10abe9d82fb0576486b8d"; var cnonce = "d6aeaa6e89bc888dbfa2def38333a3d0"; var noncecount = "00000001"; var qop = "auth"; var ha1 = ""; var ha2 = ""; var response = ""; var input = name + ":" + realm + ":" + pwd; ha1 = MD5(input); //alert("md5(" + input +")=" + ha1); input = method + ":" + url; ha2 = MD5(input); //alert("md5(" + input +")=" + ha2); input = ha1 + ":" + nonce + ":" + noncecount + ":" + cnonce + ":" + qop + ":" + ha2; response = MD5(input); //alert("response :" + response); var strDigest="Digest "; strDigest += "username=" + "\"" + name + "\"" + ","; strDigest += "realm=" + "\"" + realm + "\"" + ","; strDigest += "nonce=" + "\"" + nonce + "\"" + ","; strDigest += "uri=" + url + ","; strDigest += "cnonce=" + "\"" + cnonce + "\"" + ","; strDigest += "nc=" + noncecount + ","; strDigest += "algorithm=MD5" + ","; strDigest += "response=" + "\"" + response + "\"" + ","; strDigest += "qop=" + "\"auth\""; //alert(strDigest); return strDigest; } function doRequestDigest(name, pwd, url) { xmlhttp=new XMLHttpRequest(); xmlhttp.open("GET", url , false, name, pwd) ; xmlhttp.setRequestHeader("Content-Type", "text/plain;charset=utf-8"); xmlhttp.setRequestHeader("Pragma","no-cache"); xmlhttp.setRequestHeader("Cache-Control","no-cache"); //xmlhttp.setRequestHeader("Expires","0"); //xmlhttp.setRequestHeader("Last-Modified","Wed, 1 Jan 1997 00:00:00 GMT"); //xmlhttp.setRequestHeader("If-Modified-Since","-1"); //alert(name+","+pwd+","+url); // give digest string //var strDigest=getDigestAuthorizationString(name, pwd, "GET", url); //xmlhttp.setRequestHeader("Authorization", strDigest); xmlhttp.send(); //alert(xmlhttp.responseText); return xmlhttp.responseText; } function doRequestUploadDigest(name, pwd, url, form_obj) { var oData = new FormData(form_obj); //oData.append("CustomField", "This is some extra data"); xmlhttp=new XMLHttpRequest(); if( (url.indexOf("FIRMWARE_SAVE") >= 0) || (url.indexOf("SECURE_FIRMWARE_SAVE") >= 0) ){ xmlhttp.open("POST", url , true, name, pwd); } else { xmlhttp.open("POST", url , false, name, pwd); } xmlhttp.setRequestHeader("Pragma","no-cache"); xmlhttp.setRequestHeader("Cache-Control","no-cache"); var strDigest=getDigestAuthorizationString(name, pwd, "POST", url); xmlhttp.setRequestHeader("Authorization", strDigest); xmlhttp.send(oData); //alert(xmlhttp.responseText); if( (url.indexOf("FIRMWARE_SAVE") >= 0) || (url.indexOf("SECURE_FIRMWARE_SAVE") >= 0) ){ xmlhttp.onload = function () { if (xmlhttp.status == 200) { idget("message").innerHTML = xmlhttp.responseText; idget("div_file_upload").style.display = "none"; idget("div_show_message").style.display = ""; } }; } else return xmlhttp.responseText; } function doRequestUpload(v, form_obj) { var cgi = v.split("?"); if(cgi.length >= 2) { if(cgi[0].search("system") > 0) cgi[0] = "/cgi-bin/cmd/system"; else if(cgi[0].search("encoder") > 0) cgi[0] = "/cgi-bin/cmd/encoder"; else if(cgi[0].search("update") > 0) cgi[0] = "/cgi-bin/cmd/update"; else if(cgi[0].search("test") > 0) cgi[0] = "/cgi-bin/cmd/test"; else { console.log("error. not found cgi in cgi[0]:" + cgi[0]); return doRequestType1(v); } var arg = cgi[1].split("&"); var name = ""; var pwd = ""; var i; cgi[1] = ""; for(i = 0 ; i < arg.length ; i ++) { if(arg[i].search(/USER=/i) == 0) { name = arg[i].slice(5); //alert("found" + arg[i] + ",name=" + name); } else if(arg[i].search(/PWD=/i) == 0) { pwd = arg[i].slice(4); //alert("found" + arg[i] + ",pwd=" + pwd); } else { if(cgi[1].length > 0) cgi[1] += "&" + arg[i]; else cgi[1] = arg[i]; } } //cgi[1] += "&DUMMY=" + Math.random(); var uri=cgi.join("?"); //alert("new uri=" + uri + " from " + v); if( (name.length) > 0 && (pwd.length > 0) ) return doRequestUploadDigest(name, pwd, uri, form_obj); //alert("error. not found name or pwd form " + cgi[1]); } else alert("error. split " + v); return doRequestType1(v); } function doRequestType1(str) { if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET", str , false) ; xmlhttp.setRequestHeader("Content-Type", "text/plain;charset=utf-8"); xmlhttp.setRequestHeader("Pragma","no-cache"); xmlhttp.setRequestHeader("Cache-Control","no-cache"); xmlhttp.setRequestHeader("Expires","0"); xmlhttp.setRequestHeader("Last-Modified","Wed, 1 Jan 1997 00:00:00 GMT"); xmlhttp.setRequestHeader("If-Modified-Since","-1"); xmlhttp.send(); return xmlhttp.responseText; } function doRequest(str) { var cgi = str.split("?"); if(cgi.length >= 2) { if(cgi[0].search("system") > 0) cgi[0] = "/cgi-bin/cmd/system"; else if(cgi[0].search("encoder") > 0) cgi[0] = "/cgi-bin/cmd/encoder"; else if(cgi[0].search("update") > 0) cgi[0] = "/cgi-bin/cmd/update"; else if(cgi[0].search("test") > 0) cgi[0] = "/cgi-bin/cmd/test"; else { console.log("error. not found cgi in cgi[0]:" + cgi[0]); return doRequestType1(str); } var arg = cgi[1].split("&"); var name = ""; var pwd = ""; var i; cgi[1] = ""; for(i = 0 ; i < arg.length ; i ++) { if(arg[i].search(/USER=/i) == 0) { name = arg[i].slice(5); //alert("found" + arg[i] + ",name=" + name); } else if(arg[i].search(/PWD=/i) == 0) { pwd = arg[i].slice(4); //alert("found" + arg[i] + ",pwd=" + pwd); } else { if(cgi[1].length > 0) cgi[1] += "&" + arg[i]; else cgi[1] = arg[i]; } } //cgi[1] += "&DUMMY=" + Math.random(); var uri=cgi.join("?"); //alert("new uri=" + uri + " from " + str); if( (name.length) > 0 && (pwd.length > 0) ) return doRequestDigest(name, pwd, uri); //alert("error. not found name or pwd form " + cgi[1]); } else alert("error. split " + str); return doRequestType1(str); } function doRequestXML(v) { if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else{// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET", v , false) ; xmlhttp.setRequestHeader("ontent-Type", "text/plain;charset=utf-8"); xmlhttp.setRequestHeader("Pragma","no-cache"); xmlhttp.setRequestHeader("Cache-Control","no-cache"); xmlhttp.setRequestHeader("Expires","0"); xmlhttp.setRequestHeader("Last-Modified","Wed, 1 Jan 1997 00:00:00 GMT"); xmlhttp.setRequestHeader("If-Modified-Since","-1"); xmlhttp.send(); return xmlhttp.responseXML; } //-- doSplitValue ########################################################################### function doSplitValue( v ) { var r = new Array(); r[0] = '' ; r[1] = '' ; if ( v.substr(0,4) != 'ERROR') { r[0]=v.slice(0, v.indexOf("=")); r[1]=v.slice(v.indexOf("=")+1, v.length); if ( r[0].substr(r[0].length-1,1) == ' '){ r[0] = r[0].substr(0, r[0].length-1 ) ;} if ( r[1].substr(r[1].length-1,1) == '\''){ r[1] = r[1].substr(0, r[1].length-1 ) ;} if ( r[1].substr( 0,1) == '\''){ r[1] = r[1].substr(1, r[1].length-1 ) ;} }else { r[0] = 'ERROR' ; r[1] = v.substr(6,v.length-6) ; } return r ; } //-- V2doSplitValue ########################################################################### function V2doSplitValue( v ) { var r = new Array(); r[0] = '' ; r[1] = '' ; if ( v.substr(0,4) != 'ERROR') { if ( v.indexOf('=') >= 0 ) { t = v.split("'") ; //alert(t[0]+','+t[1]); r[0] = t[0] ; r[1] = t[1] ; l = r[1].length ; if ( r[0].substr(r[0].length-1,1) == ' '){ r[0] = r[0].substr(0, r[0].length-1 ) ;} if ( r[1].substr(r[1].length-1,1) == '\''){ r[1] = r[1].substr(0, r[1].length-1 ) ;} if ( r[1].substr( 0,1) == '\''){ r[1] = r[1].substr(1, r[1].length-1 ) ;} } }else { r[0] = 'ERROR' ; r[1] = v.substr(6,v.length-6) ; } return r ; } //################################################################## function SetSelectedValue(e, v){ var i; for(i=0; i 0 ) { obj.remove(0); } var nIdx; for(nIdx=n_min; nIdx<=n_max; nIdx++){ //obj.add(new Option(nIdx, nIdx)); var y=document.createElement('option'); y.text=nIdx; y.value=nIdx; try{ obj.add(y,null); // standards compliant }catch(ex){ obj.add(y); // IE only } } } function InsertSelectOptions_Number_2(obj, n_min, n_max, str){ while (obj.options.length > 0 ) { obj.remove(0); } var nIdx; for(nIdx=n_min; nIdx<=n_max; nIdx++){ //obj.add(new Option(nIdx, nIdx)); var y=document.createElement('option'); y.text=nIdx+str; y.value=nIdx; //alert(y.value); try{ obj.add(y,null); // standards compliant }catch(ex){ obj.add(y); // IE only } } } //-- SelectSetOption ########################################################################### function SelectSetOption(obj, v){ var nIdx; for(nIdx=0; nIdx 0 ) { obj.remove(0); } items = items.split(","); for (i=0;i 0 ) { obj.remove(0); } items = items.split(","); for (i=0;i 0 ) { obj.remove(0); } items = items.split(","); values = values.split(","); for (i=0;i 0 ) obj.remove(0); items = items.split(","); for (i=0;i