// 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.2.9.9631"; //插件版本 2.2.9.9631 var webVersion = "23.04.24.10523"; var first = 1; m_Http = location.protocol + "//"; //获取当前地址栏协议 m_HostName = location.hostname; //获取当前地址栏主机名 if (location.port != "") { m_HttpPort = location.port; //获取当前地址样端口 } var deviceCap = []; var MacAddress, HTTPprot, StreamCount; var MainBitrate, FirstBitrate, SecondBitrate; /************************************************* Function: SaveState Description: 保存后返回的状态 Input: ptzbitrate xhr XMLHttpRequest 对象 Output: 无 return: 无 *************************************************/ function isIElANCE() { if (!!window.ActiveXObject || "ActiveXObject" in window) { return true; } else { return false; } } function SaveState(xhr) { var xmlDoc = xhr.responseXML; var state = $(xmlDoc).find('statusCode').eq(0).text(); if ("0" == state) { m_cyReInfo = str_if_succeed; $("#meg").css("background-color", "#8BA579") } else { m_cyReInfo = str_if_fail; $("#meg").css("background-color", "red") } $("#meg").html(m_cyReInfo); $("#meg").fadeIn(1000); if (0 != g_iSaveResTimer) { clearTimeout(g_iSaveResTimer); } //3秒后自动清除N 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); } function browserRedirect() { var sUserAgent = navigator.userAgent.toLowerCase(); var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; var bIsMidp = sUserAgent.match(/midp/i) == "midp"; var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb"; var bIsAndroid = sUserAgent.match(/android/i) == "android"; var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"; var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"; if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) { return false } else { return true } } /********************************** 功能: 计算字符串的长度 参数: 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); } } Date.prototype.format = function(fmt) { //author: meizz var o = { "M+": this.getMonth() + 1, //月份 "d+": this.getDate(), //日 "h+": this.getHours(), //小时 "m+": this.getMinutes(), //分 "s+": this.getSeconds(), //秒 "q+": Math.floor((this.getMonth() + 3) / 3), //季度 "S": this.getMilliseconds() //毫秒 }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt; } function getDeviceCap() { $.ajax({ url: m_Http + m_HostName + ":" + m_HttpPort + "/System/DeviceCap", type: "GET", async: false, timeout: 15000, beforeSend: function(xhr) { xhr.setRequestHeader("If-Modified-Since", "0"); }, success: function(xmlDoc) { /* 与通道无关的功能 */ StreamCount = $(xmlDoc).find("StreamCount").eq(0).text(); deviceCap.CarDetect = $(xmlDoc).find("CarDetect").find("Support").text().toLowerCase(); //叠加人形 deviceCap.Human = $(xmlDoc).find("AIOverlay").find("Human").text().toLowerCase(); //叠加人形 deviceCap.Face = $(xmlDoc).find("AIOverlay").find("Face").text().toLowerCase(); //叠加人脸 deviceCap.PolygonRegion = $(xmlDoc).find("AIOverlay").find("PolygonRegion").text().toLowerCase(); //叠加布防 deviceCap.TraverseLine = $(xmlDoc).find("AIOverlay").find("TraverseLine").text().toLowerCase(); //叠加绊线 deviceCap.Car = $(xmlDoc).find("AIOverlay").find("Car").text().toLowerCase(); //叠加绊线 deviceCap.WarmLight = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find('WarmLight').text(); deviceCap.StorageCapacity = $(xmlDoc).find('StorageCapacity').text().toLowerCase(); //sd卡容量 deviceCap.isSupportG711u = $(xmlDoc).find('AudioCodec').eq(0).find('G711u').text().toLowerCase(); deviceCap.isSupportG711a = $(xmlDoc).find('AudioCodec').eq(0).find('G711a').text().toLowerCase(); deviceCap.isSupportAlarmOutPlan = $(xmlDoc).find('AlarmOutPlan').eq(0).find('Support').text().toLowerCase(); deviceCap.PlaybackSpeed = $(xmlDoc).find('PlaybackSpeed').eq(0).find('Support').text().toLowerCase(); // deviceCap.Max = parseInt($(xmlDoc).find('PlaybackSpeed').eq(0).find('Max').text().toLowerCase()); deviceCap.streamCount = parseInt($(xmlDoc).find('StreamCount').text()); //支持的码流个数 deviceCap.diskEnable = $(xmlDoc).find('SD').text().toLowerCase(); //是否支持SD卡 // if (deviceCap.diskEnable == "true") { // $("#recordtime").show(); //录像时间 // $("#disk").show(); //磁盘信息 // } else { // $("#recordtime").hide(); // $("#disk").hide(); // } if ((deviceCap.Human == "false" || deviceCap.Human == "") && (deviceCap.Face == "false" || deviceCap.Face == "") && (deviceCap.PolygonRegion == "false" || deviceCap.PolygonRegion == "") && (deviceCap.TraverseLine == "false" || deviceCap.TraverseLine == "")) { $("#overlay_settingsdiv").hide(); } else { $("#overlay_settingsdiv").show(); }; deviceCap.isSupportPolygonRegion = $(xmlDoc).find("DetectRegion").find("PolygonRegion").find("Support").text().toLowerCase(); //是否支持多边行 if (deviceCap.isSupportPolygonRegion == "true") { // $("#defense_areadiv").show(); $("#face_humandetectdiv").hide(); // $("#face_detectdiv").hide(); } else { // $("#defense_areadiv").show(); deviceCap.FaceMode = $(xmlDoc).find('Device').eq(0).find("AIWorkMode").eq(0).find("FaceMode").eq(0).text(); if (deviceCap.FaceMode == "true") { $("#face_humandetectdiv").show(); }; // deviceCap.PeopleMode = $(xmlDoc).find('Device').eq(0).find("AIWorkMode").eq(0).find("PeopleMode").eq(0).text(); // if (deviceCap.PeopleMode == "true") { // $("#face_detectdiv").show(); // }else{ // $("#face_detectdiv").hide(); // } }; deviceCap.AudioAlarmType = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("AudioAlarmType").eq(0); deviceCap.CarAudioAlarmType = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("CarAudioAlarmType").eq(0); deviceCap.FaceSnapshot = $(xmlDoc).find('Device').eq(0).find("FaceFunction").eq(0).find("FaceSnapshot").eq(0).text(); deviceCap.LightAlarm = $(xmlDoc).find('Device').eq(0).find("LightAlarm").eq(0).find("Support").eq(0).text(); deviceCap.Voicealarm = $(xmlDoc).find('Device').eq(0).find("AudioAlarm").eq(0).text(); deviceCap.PlaybackSpeed = $(xmlDoc).find('PlaybackSpeed').eq(0).find('Support').text().toLowerCase(); deviceCap.Max = parseInt($(xmlDoc).find('PlaybackSpeed').eq(0).find('Max').text().toLowerCase()); deviceCap.autoclose = $(xmlDoc).find('WDR').eq(0).find('Close').text().toLowerCase(); if (deviceCap.LightAlarm == "true") { $("#Lightingconfigdiv").show() } else { $("#Lightingconfigdiv").hide() } if (deviceCap.Voicealarm == "true") { $("#face_voicealarmdiv").show() } else { $("#face_voicealarmdiv").hide() } }, error: function(xhr) { } }) }; function getDeviceinfo() { $.ajax({ url: m_Http + m_HostName + ":" + m_HttpPort + "/System/DeviceInfo", type: "GET", async: true, timeout: 15000, beforeSend: function(xhr) { xhr.setRequestHeader("If-Modified-Since", "0"); }, success: function(xmlDoc, textStatus, xhr) { var DeviceTypeName = $(xmlDoc).find('DeviceInfo').eq(0).find('DeviceTypeName').eq(0).text(); if (DeviceTypeName == "IPG-7920PSS-AI/FD/T6" || DeviceTypeName == "IPG-7920PSS-AI" || DeviceTypeName == "IPG-7920PHS-AI/T7H") { $(".3msg").show(); }; }, error: function(xhr, textStatus, errorThrown) {} }); } function macadress() { $.ajax({ url: m_Http + m_HostName + ":" + m_HttpPort + "/Network/Interfaces", type: "GET", async: false, timeout: 15000, beforeSend: function(xhr) { xhr.setRequestHeader("If-Modified-Since", "0"); }, success: function(xmlDoc, textStatus, xhr) { MacAddress = $(xmlDoc).find('InterfaceList').find('Interface').eq(0).find('MacAddress').eq(0).text(); }, error: function(xhr, textStatus, errorThrown) {} }); }; function deviceStatus() { $.ajax({ url: m_Http + m_HostName + ":" + m_HttpPort + "/System/DeviceStatus", type: "GET", async: false, timeout: 15000, beforeSend: function(xhr) { xhr.setRequestHeader("If-Modified-Since", "0"); }, success: function(xmlDoc, textStatus, xhr) { MainBitrate = $(xmlDoc).find('DeviceStatusList').find('DeviceStatus').eq(0).find('MainStreamVideoBitrate').eq(0).text(); FirstBitrate = $(xmlDoc).find('DeviceStatusList').find('DeviceStatus').eq(0).find('FirstSubStreamVideoBitrate').eq(0).text(); SecondBitrate = $(xmlDoc).find('DeviceStatusList').find('DeviceStatus').eq(0).find('SecondSubStreamVideoBitrate').eq(0).text(); }, error: function(xhr, textStatus, errorThrown) {} }); }; function getParameter(callback, url, flag) { $.ajax({ url: url, type: "GET", async: false, timeout: 15000, beforeSend: function(xhr) { xhr.setRequestHeader("If-Modified-Since", "0"); }, success: function(xml, xhr) { callback(xml, xhr); }, error: function(xhr) { } }) } function setParameter(callback, url, type, xml, flag, nFlag) { $.ajax({ url: url, type: type, async: true, data: xml, processData: false, timeout: 15000, complete: function(xhr) { if (flag === 1) { callback(xhr, nFlag) } }, success: function(xhr) { if (flag === 0) { callback(xhr, nFlag) } }, error: function(xhr) { } }) }