// JavaScript Document var m_HostName = ""; var m_HttpPort = "80"; var m_Http = "http://"; var m_RtspPort = 554; var m_cyUserPwdValue = ""; var g_iSaveResTimer = 0; //保存结果清空timer的索引 var m_cyReInfo = ""; var iePlugVersion = "2.1.45.6520"; //插件版本 var webVersion = "19.11.25.7526"; var first = 1; m_Http = location.protocol + "//"; //获取当前地址栏协议 m_HostName = location.hostname; //获取当前地址栏主机名 if(location.port != "") { m_HttpPort = location.port; //获取当前地址样端口 } /************************************************* Function: SaveState Description: 保存后返回的状态 Input: xhr XMLHttpRequest 对象 Output: 无 return: 无 *************************************************/ function SaveState(xhr) { var xmlDoc = xhr.responseXML; var state = $(xmlDoc).find('statusCode').eq(0).text(); if("0" == state) { m_cyReInfo = str_if_succeed; } else { m_cyReInfo = str_if_fail; } $("#meg").html(m_cyReInfo); $("#meg").fadeIn(1000); if(0 != g_iSaveResTimer) { clearTimeout(g_iSaveResTimer); } //3秒后自动清除 g_iSaveResTimer = setTimeout(function() { $("#meg").fadeOut(1000); $("#meg").html(""); }, 3000); } function SaveStateWifiMode(xhr) { var xmlDoc = xhr.responseXML; var state = $(xmlDoc).find('statusCode').eq(0).text(); if("0" == state) { m_cyReInfo = str_if_switchwifi_succeed; } else { m_cyReInfo = str_if_switchwifi_failed; } $("#meg").html(m_cyReInfo); $("#meg").fadeIn(1000); if(0 != g_iSaveResTimer) { clearTimeout(g_iSaveResTimer); } //3秒后自动清除 g_iSaveResTimer = setTimeout(function() { $("#meg").fadeOut(1000); $("#meg").html(""); }, 3000); } function SaveStateTestEmail(xhr) { var xmlDoc = xhr.responseXML; var state = $(xmlDoc).find('statusCode').eq(0).text(); if("0" == state) { m_cyReInfo = str_if_testemail_succeed; } else { m_cyReInfo = str_if_testemail_fail; } $("#meg").html(m_cyReInfo); $("#meg").fadeIn(1000); if(0 != g_iSaveResTimer) { clearTimeout(g_iSaveResTimer); } //3秒后自动清除 g_iSaveResTimer = setTimeout(function() { $("#meg").fadeOut(1000); $("#meg").html(""); }, 3000); } function SaveStateTestFtp(xhr) { var xmlDoc = xhr.responseXML; var state = $(xmlDoc).find('statusCode').eq(0).text(); if("0" == state) { m_cyReInfo = str_if_testftp_succeed; } else { m_cyReInfo = str_if_testftp_fail; } $("#meg").html(m_cyReInfo); $("#meg").fadeIn(1000); if(0 != g_iSaveResTimer) { clearTimeout(g_iSaveResTimer); } //3秒后自动清除 g_iSaveResTimer = setTimeout(function() { $("#meg").fadeOut(1000); $("#meg").html(""); }, 3000); } function SaveStateDTF(xhr) { var xmlDoc = xhr.responseXML; var state = $(xmlDoc).find('statusCode').eq(0).text(); if("0" == state) { m_cyReInfo = str_if_succeed; } else { m_cyReInfo = str_if_fail; } $("#meg").html(m_cyReInfo); if(0 != g_iSaveResTimer) { clearTimeout(g_iSaveResTimer); } //3秒后自动清除 g_iSaveResTimer = setTimeout(function() { $("#meg").html(""); }, 3000); } function SaveStateReboot(xhr) { var xmlDoc = xhr.responseXML; var state = $(xmlDoc).find('statusCode').eq(0).text(); if("0" == state) { m_cyReInfo = str_rebooting; } else { m_cyReInfo = str_if_fail; } $("#meg").html(m_cyReInfo); $("#meg").fadeIn(1000); if(0 != g_iSaveResTimer) { clearTimeout(g_iSaveResTimer); } g_iSaveResTimer = setTimeout(function() { $("#meg").html(""); }, 3000); } /********************************** 功能: 对时 ***********************************/ function setSyncDateTime() { var now = new Date(); var pcyear = now.getYear(); if(pcyear < 1000) { pcyear += 1900; } if((pcyear < 1971) || (pcyear > 2036)) { errorMsg(str_err_pctime, "meg"); return false; } var pcmonth = now.getMonth() + 1; if(pcmonth < 10) pcmonth = "0" + pcmonth; var pcday = now.getDate(); if(pcday < 10) pcday = "0" + pcday; var pchour = now.getHours(); if(pchour < 10) pchour = "0" + pchour; var pcminute = now.getMinutes(); if(pcminute < 10) pcminute = "0" + pcminute; var pcsecond = now.getSeconds(); if(pcsecond < 10) pcsecond = "0" + pcsecond; var setSyncPDT = pcyear + '.' + pcmonth + '.' + pcday + 'T' + pchour + '.' + pcminute + '.' + pcsecond; setSyncPDT = setSyncPDT.replace(/[.]/g, ""); var cyXml = "" + ""; var cyURL = m_Http + m_HostName + ":" + m_HttpPort + "/System/Time"; $.ajax({ type: "PUT", url: cyURL, async: true, processData: false, data: cyXml, beforeSend: function(xhr) { xhr.setRequestHeader("If-Modified-Since", "0"); }, complete: function(xhr, textStatus) { //SaveState(xhr); } }); } /************************************************* Function: Logout Description: 注销用户 Input: 无 Output: 无 return: 无 *************************************************/ function Logout() { clearTimeout(gs_interval); $.cookie('userInfo', null); $.cookie('commandPort', null); $.cookie('strem', null); $.cookie('rtspPort', null); m_cyUserPwdValue = ""; window.location.href = "/"; } /************************************************* Function: Base64 Description: Base64加密解密 Input: 无 Output: 无 return: 无 *************************************************/ var Base64 = { // private property _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", // public method for encoding encode: function(input) { var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0; input = Base64._utf8_encode(input); while(i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if(isNaN(chr2)) { enc3 = enc4 = 64; } else if(isNaN(chr3)) { enc4 = 64; } output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); } return output; }, // public method for decoding decode: function(input) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while(i < input.length) { enc1 = this._keyStr.indexOf(input.charAt(i++)); enc2 = this._keyStr.indexOf(input.charAt(i++)); enc3 = this._keyStr.indexOf(input.charAt(i++)); enc4 = this._keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if(enc3 != 64) { output = output + String.fromCharCode(chr2); } if(enc4 != 64) { output = output + String.fromCharCode(chr3); } } output = Base64._utf8_decode(output); return output; }, // private method for UTF-8 encoding _utf8_encode: function(string) { string = string.replace(/\r\n/g, "\n"); var utftext = ""; for(var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if(c < 128) { utftext += String.fromCharCode(c); } else if((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }, // private method for UTF-8 decoding _utf8_decode: function(utftext) { var string = ""; var i = 0; var c = c1 = c2 = 0; while(i < utftext.length) { c = utftext.charCodeAt(i); if(c < 128) { string += String.fromCharCode(c); i++; } else if((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i + 1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i + 1); c3 = utftext.charCodeAt(i + 2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } } /************************************************* Function: errorMsg Description: 错误信息提示 *************************************************/ function errorMsg(msg, cyID) { $("#" + cyID).html(msg); $("#" + cyID).fadeIn(1000); if(0 != g_iSaveResTimer) { clearTimeout(g_iSaveResTimer); } //3秒后自动清除 g_iSaveResTimer = setTimeout(function() { $("#" + cyID).fadeOut(1000); $("#" + cyID).html(""); }, 3000); } /********************************** 功能: 计算字符串的长度 参数: szString: 输入的字符串 ***********************************/ function strlen(str) { var len = 0; for(var i = 0; i < str.length; i++) { var c = str.charCodeAt(i); //单字节加1 if((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) { len++; } else { len += 2; } } return len; } function checkStr(str){ var string =/[\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3008|\u3009|\u3010|\u3011|\u300e|\u300f|\u300c|\u300d|\ufe43|\ufe44|\u3014|\u3015|\u2026|\u2014|\uff5e|\ufe4f|\uffe5]/; if(string.test(str)){ return true }else{ return false } } /************************************************* Function: CheckKeyDown Description: 输入时按下空格时,不允许输入 Input: iSetValue: 需要验证的值 Output: 无 return: 无 *************************************************/ function CheckKeyDown(event) { event = event ? event : (window.event ? window.event : null); if(event.keyCode == 32) { if(navigator.appName == "Netscape" || navigator.appName == "Opera") { event.preventDefault(); } else { event.returnValue = false; //非ie浏览器event无returnValue属性 } return; } } /************************************************* Function: checkVal Description: 检测端口值 **************************************************/ function checkVal(tipsId) { if($("#" + tipsId).val() > 65535) { $("#" + tipsId).val(65535); } if($("#" + tipsId).val() < 1) { $("#" + tipsId).val(1); } }