function Basic(){this.w=window;this.routerAlive=!1;this.head=document.getElementsByTagName("head")[0];this.d=document;this.local="file:"==location.protocol;this.isIE=0<=navigator.userAgent.indexOf("IE");this.domainUrl="http://192.168.1.60";this.pppoeIp=this.staticIp=this.domainIp="192.168.1.60";this.domainPort="80";this.rtspExtPort=this.rtspInnerPort="554";this.vhttpdExtPort=this.vhttpdInnerPort="8800";this.resolutionWidth=1280;this.time=1E3;this.explorerTag=0;this.tmpPwdMD5=this.pwdMD5=this.pwd=
this.username=this.session=this.hostip="";this.httpTag="http://";this.httpsTag="https://";this.ajaxAsyn=!0;this.ajaxSyn=!1;this.getPwdMD5=function(a,b){return $.md5(a+":TP-LINK IP-Camera:"+b)};this.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)};this.getExplorer=function(){var a=navigator.userAgent;0<a.indexOf("IE 6.0")?this.explorerTag=6:0<a.indexOf("IE 7.0")&&(this.explorerTag=7)};this.transText=function(a){if(0<a.length){a=a.substring(a.indexOf("\r\n")+2);try{return eval("("+
a+")")}catch(b){return""}}};this.id=function(a){return document.getElementById(a)};this.changeDomain=function(a){var b=this.httpTag,c=a.indexOf(b);0==a.indexOf(this.httpsTag)&&(b=this.httpsTag,c=0);0==c?(this.domainIp=a.substring(b.length),this.domainUrl=a):(this.domainIp=a,this.domainUrl=b+a);a.lastIndexOf("/")==a.length-1&&(this.domainIp=this.domainIp.substring(0,this.domainIp.length-1),this.domainUrl=this.domainUrl.substring(0,this.domainUrl.length-1));-1!=this.domainIp.lastIndexOf(":")&&(this.domainIp=
this.domainIp.split(":")[0],this.domainPort=this.domainIp.split(":")[1])};this.initUrl=function(){if(!this.local){var a=location.href,b=a.indexOf("?");0<b&&(a=a.substring(0,b));this.changeDomain(a)}};this.objInitNull=function(a){for(var b in a)"object"==typeof a[b]?this.arguments.callee(a[b]):a[b]=""};this.objSet=function(a,b){if(this.isArray(b)){var c=0,d;for(d in a)a[d]=b[c++]}else for(d in a)a[d]=b};this.objCopy=function(a,b){var c,d;for(d in a)c=b[d],void 0!=c&&(a[d]=c)};this.encodePara=function(a){return a=
encodeURL(a.toString())}}
function WebAjax(){this.local="file:"==location.protocol;this.isIE=0<=navigator.userAgent.indexOf("IE");this.ajaxTimeout=2E3;this.sessionKey="stok";this.externDataParseFunc=new Function;this.result={errorno:0,data:"",timeout:!0};this.initResult=function(a){this.result.errorno=0;this.result.data="";this.result.timeout=!0};this.setDataParseFunc=function(a){this.externDataParseFunc=a};this.changeAsynTime=function(a){this.ajaxTimeout=a};this.getValueFromUrl=function(a,b){var c="",d;b+="=";d=a.indexOf(b);
0<=d&&(c=a.substring(d+b.length),d=c.indexOf("&"),d=0<d?d:c.length,c=c.substring(0,d));return c};this.orgURL=function(a){var b;0!=$.session.length&&(b=a.indexOf(".."),0<=b&&(a=a.substring(b+2)),a="/stok="+encodeURIComponent($.session)+a);return a};this.createXHR=function(){var a;if(void 0!=window.ActiveXObject)try{a=!0==this.local?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest}catch(b){a=new ActiveXObject("Microsoft.XMLHTTP")}else a=new XMLHttpRequest;return a};this.request=function(a,
b,c,d,h,f,e,g){function m(a){var b,c;try{c=JSON.parse(a,function(a,b){return"string"===typeof b?decodeURIComponent(b):b})}catch(d){c=null}null==c?b=ENONE:(b=c[ERR_CODE],a=c.data);return[b,a]}var k=this.createXHR(),n,l=this;this.initResult(l.result);k.onreadystatechange=function(){if(4==k.readyState&&(!0===$.local||100<=k.status)){l.result.timeout=!1;if(n=k.responseText)l.result.data=n;var a=m(n);l.result.errorno=a[0];l.result.data=a[1];void 0!=h&&h(l.result);return!0}};try{void 0!=e&&void 0!=g?k.open(c,
a,d,e,g):k.open(c,a,d),!0==this.isIE&&k.setRequestHeader("If-Modified-Since","0"),void 0!=b?k.send(b):k.send(null)}catch(p){}}}
function Load(){Basic.call(this);WebAjax.call(this);this.asyn=!0;this.syn=!1;this.detectTime=1E3;this.div=document.createElement("div");this.externResizefunc=new Function;this.externJSP=new Function;this.externLoading=new Function;this.externPageHandle=new Function;this.pageTickArray=[];this.scriptArray=[];this.unAuthCode=401;this.httpOK=200;this.setTimeout=function(a,b){var c=window.setTimeout(a,b);this.pageTickArray.push(c);return c};this.addScript=function(a){if(a&&/\S/.test(a)){var b=this.d.createElement("script");
b.type="text/javascript";void 0===b.text?b.appendChild(this.d.createTextNode(a)):b.text=a;this.head.insertBefore(b,this.head.firstChild);this.head.removeChild(b)}};this.getNodeArray=function(a,b){for(var c=[],d=0,h=a.length;d<h;d++)c[d]=a[d];b(c)};this.addDomNode=function(a,b,c){var d=this;this.div.innerHTML="div"+b;this.div.removeChild(this.div.firstChild);this.getNodeArray(this.div.childNodes,function(b){var f=[];emptyNodes(a);for(var e=0,g=b.length;e<g;e++)1==b[e].nodeType&&"script"===b[e].nodeName.toLowerCase()?
f.push(b[e]):a.appendChild(b[e]);"function"==typeof c.callBackLoadedDom&&c.callBackLoadedDom();e=0;for(g=f.length;e<g;e++)d.addScript(f[e].text||f[e].textContent||f[e].innerHTML||"")})};this.pageResize=function(){this.externResizefunc()};this.setPageResize=function(a){this.externResizefunc=a};this.setexternJSP=function(a){this.externJSP=a};this.setExternLoading=function(a){this.externLoading=a};this.setExternPageHandle=function(a){this.externPageHandle=a};this.append=function(a,b,c){a&&1==a.nodeType&&
"string"===typeof b&&(this.addDomNode(a,b,c),this.pageResize())};this.detectWidthImg=function(a){var b=new Image;b.onload=function(){a()};b.src=this.domainUrl+"/web-static/images/logoWhite.png?requence="+Math.random()};this.detect=function(a){!0==isIETenLess?this.detectWidthImg(a):this.request(this.domainUrl+"/web-static/images/nothing.png",void 0,"get",this.asyn,a)};this.loadHand=function(a,b,c){str=this.externJSP(a.data);void 0!=str&&(a.data=str);if(this.unAuthCode!=a.errorno){if(!1!==c.bClearPageTickArray)for(var d=
0,h=this.pageTickArray.length;d<h;d++)try{window.clearTimeout(this.pageTickArray[d])}catch(f){}this.append(this.id(b),a.data,c);try{this.externPageHandle()}catch(e){}}};this.getLgResult=function(a){return/\r\n\x3c!--(\d{3})--\x3e\r\n/gi.test(a.data)&&RegExp.$1!=this.httpOK?(a.errorno=RegExp.$1,/var authInfo = new Array("([a-zA-Z])","(\d{1,})");/g.test(a.data)&&(a.data=RegExp.$1+" "+RegExp.$2),!0):!1};this.refreshSession=function(a,b){var c=this;this.request(a,void 0,"get",this.asyn,function(a){a.errorno==
EUNAUTH&&c.parseAuthRlt(a.data);b()})};this.getUnAuthHandle=function(a,b,c){!0!=$.accountStatus.logoutHandle&&EUNAUTH==$.result.errorno&&($.authRltObj.authStatus=!1,$.parseAuthRlt($.result.data),ESYSRESET==$.result.data.code&&(gIsFactory=!0),null==$.pwd||0==$.pwd.length?window.setTimeout(function(){$.loginErrHandle()},0):$.auth($.username,$.pwd,$.oriPwd,function(d){if(ENONE==d)if(!0==b)$.request($.orgURL(a),void 0,"get",b,function(a){ENONE!=a.errorno?($.authRltObj.authStatus=!1,$.parseAuthRlt(a.data),
$.loginErrHandle()):($.authRltObj.authStatus=!0,c(a))});else return $.request($.orgURL(a),void 0,"get",b,void 0),ENONE!=$.result.errorno?($.authRltObj.authStatus=!1,$.parseAuthRlt($.result.data),$.loginErrHandle()):($.authRltObj.authStatus=!0,c($.result)),!0;else window.setTimeout(function(){$.authRltObj.authStatus=!1;$.loginErrHandle()},0)}))};this.load=function(a,b,c,d,h){function f(a){"function"==typeof h&&h(a);e=a.timeout;e||(d=void 0==d?{}:d,g.loadHand(a,c,d));"function"==typeof b&&b(a)}var e=
!1,g=this;if(this.local||void 0!=b)this.loadAsyn(a,this.ajaxTimeout,function(b){try{b.errorno==EUNAUTH?g.getUnAuthHandle(a,g.asyn,f):b.errorno==ENONE&&f(b)}catch(c){log(c)}});else try{this.request(this.orgURL(a),void 0,"get",this.syn),this.result.errorno==EUNAUTH?this.getUnAuthHandle(a,this.syn,f):this.result.errorno==ENONE&&f(this.result)}catch(m){log(m)}return e};this.loadAsyn=function(a,b,c){this.request(this.orgURL(a),void 0,"get",this.asyn,c,b)}};
