var gVar; //全局变量 var gDvr; //设备信息类对象 var UI; //UI包对象 var lg; //语言包对象 var lgCls; var timeout; var m_cyUserPwdValue = ""; var tabkey = 1; var selChannel = 0; var osdChannel = 0; var gHttp = ""; var ColorSetMax = ""; var ColorSetCube = ""; var sliderVolume = null; //音量条 var timeFlag = 0; var downloadFlag = 0; var deviceList = []; var sliderback = []; sliderback[0] = 0; sliderback[1] = 0; sliderback[2] = 0; sliderback[3] = 0; sliderback[4] = 0; sliderback[5] = 0; sliderback[6] = 0; sliderback[7] = 0; var gStreamSet = 0; var curChid = 0; //当前选中的通道ID var curWinid = 0; //当前选中的窗口ID var g_bClickDefBtn = false; var SelDate = ""; var m_bIsPlaying = false; //回放播放状态:播放/停止 var m_bWndPause = false; //播放/暂停 var m_bWndFrame = false; //单帧 var m_bSound = false; var m_iWndSpeed = 1; var tTimeBar = null; //时间条对象 var m_szTime = []; var m_szStartTimeSet = []; //开始时间集合 var m_szEndTimeSet = []; //结束时间集合 var m_szStartTimeSeconds = 0; var m_szEndTimeSeconds = 0; var plkSelChn = 0; var selclkTime = 0; var privacyFlag = false; var playFlag = false; var osdFlag = false; var motionFlag = false; var detectFlag = false; var devName, ipChannel, analog; var deviceCap; var gs_arrResolution = []; var gs_language; var languages = [{ "lang": "zh-cn", "value": "CHS" }, { "lang": "zh-tw", "value": "CHT" }, { "lang": "en", "value": "ENU" }, { "lang": "fr", "value": "FRA" }, { "lang": "de", "value": "DEU" }, { "lang": "es", "value": "ESN" }, { "lang": "el", "value": "GRE" }, { "lang": "pl", "value": "PLK" }, { "lang": "it", "value": "ITA" }]; function InitWeb() { //站点初始化 //////////////////////////////////////初始化全局数据//////////////////////////////////////////////////// //初始化数据 lgCls = new LgClass(); gDvr = new DvrInfo(); //创建设备对象 gVar = new GlobarVar(); //初始化全局类对象 lg = new HashmapCom(); //创建语言包哈希表 selChannel = gDvr.nChannel; gHttp = window.location.href; gVar.ip = gHttp.split("//")[1].split("/")[0]; if (gVar.ip.indexOf("]") !== -1) { //IPv6 if (gVar.ip.indexOf("]:") !== -1) { //有端口 gVar.port = gVar.ip.split("]:")[1]; gVar.ip = gVar.ip.split("]:")[0] + "]"; } } else { //IPv4 if (gVar.ip.indexOf(":") !== -1) { //有端口 gVar.port = gVar.ip.split(":")[1]; gVar.ip = gVar.ip.split(":")[0]; } } UI = new UIReg(); gVar.mediaport = ""; lgCls.defaultLg = "ENU"; gVar.lg = $.cookie("language"); initLanguage(); $(window).resize(function () { changeWndSize(); }); } function initLanguage() { var defaultLan = "", lang; $.ajax({ type: "GET", dataType: "json", url: "lg/LanList.json", async: true, success: function (data) { gs_language = data; for (var m = 0; m < data.length; m++) { defaultLan += data[m].languageL; } if (gVar.lg == null) { if ((navigator.userAgent.indexOf('MSIE') >= 0) && (navigator.userAgent.indexOf('Opera') < 0)) { lang = navigator.systemLanguage.toLowerCase(); } else { lang = navigator.language.toLowerCase(); } for (var i = 0; i < languages.length; i++) { if (languages[i].lang == lang) { gVar.lg = languages[i].value; } } if (defaultLan.indexOf(gVar.lg) == -1) { gVar.lg = "ENU"; } } LanguageCall(gVar.lg); } }) } //语言处理 function LanguageCall(lag) { gVar.Ajax({ type: "GET", url: "lg/" + lag + ".xml", suc: function success(data) { gVar.XmlParsing(lg, data, "StringTable"); LoadLoginPage(); WebProc(); } }) } function WebProc() { //------live页面Button注册------ $(".liveBtnBt1").click(function () { var nRet = gDvr.OpenAllChannels(gVar.nStreamType); $(this).css("background-position", "-64px 0px").attr("name", "active"); $(".liveBtnBt2").css("background-position", "0px -31px").attr("name", ""); for (var i = 0; i < gDvr.nChannel; i++) { if (0 == nRet.getItem(i)) { channelPlay[i] = 1; $("#liveChn_Play_" + (i + 1)).css("background-position", "-31px 0px").attr("name", "active"); getOSDName(i); } } }) $(".liveBtnBt2").click(function () { //视频全关 //点击全开、全关,图标都要变到off状态 gDvr.CloseAllChannels(); $(".liveBtnBt1").css("background-position", "0px 0px").attr("name", ""); $(this).css("background-position", "-64px -31px").attr("name", "active"); for (var i = 0; i <= gDvr.nChannel; i++) { channelPlay[i] = 0; $("#liveChn_Play_" + (i + 1)).css("background-position", "0px 0px").attr("name", ""); } if ($(".liveBtnBt9").attr("name") == "active") { $(".liveBtnBt9").mousedown(); } if ($(".liveBtnBt11").attr("name") == "active") { $(".liveBtnBt11").css("background-position", "-32px 0px").attr("name", ""); } }); $(".liveBtnBt5").click(function () { //全屏按钮 gDvr.FullScreen(); }); UI.Button("div[class^='liveBtnSbt']", 25, null, function (e, p) { //分屏按钮 var $p = $(p); if (e.type == "mousedown") { var $x = $("div[class^='liveBtnSbt']"); $x.css("background-position-x", "0px"); $x.attr("name", ""); $x.mouseover(); $p.attr("name", "active"); gDvr.ChangeLayout($p.attr("flag").split("_")[0] * 1); selChannel = $p.attr("flag").split("_")[0] * 1; return true; } else { return (($p.attr("name") != "active") ? true : false); } }); $(".liveBtnBt6").click(function () { //live页面底部收起栏 var $p = $(".liveSSBtn"); if ($(this).attr("tag") == 'open') { $p.animate({ width: "0px" }, 200); $(this).attr("tag", "close"); } else { $(this).attr("tag", "open"); $p.animate({ width: $p.attr("widthR") }, $p.attr("widthR") * 1); } }); //------live页面Button注册完毕------ //////////////////////////////////控制////////////////////////////////////////////////////////////////// //页面切换 var clickState = 1; //clickState的值 1:点击LiveMenu 2:点击playBackMenu 3:点击LogMenu 4:点击ConfigMenu 5:点击PathMenu 6:点击LogoutMenu $(function () { $(".Menu1").click(function () { //live gVar.ChangPage("live"); tabkey = 0; clickState = 1; }); $(".Menu2").click(function () { //playback gVar.ChangPage("playback"); tabkey = 1; clickState = 2; }); $(".Menu3").click(function () { //log gVar.ChangPage("log"); tabkey = 1; clickState = 3; }); $(".Menu4").click(function () { //ConfigMenu gVar.ChangPage("config"); tabkey = 1; clickState = 4; }); $(".Menu5").click(function () { //PathMenu gVar.ChangPage("configPage"); tabkey = 1; clickState = 5; }); $(".Menu6").click(function () { //LogoutMenu menutitle(6); window.location.href = "index.html"; clickState = 5; }); $(".paopao_close").click(function () { $("#MsgPaop").css("display", "none").attr("name", "out"); }) }); } function LoadLoginPage() { //载入页面 $.get("html/login.html?t=" + gVar.nDate, "", function (data) { $("#login").prop("innerHTML", data).css("display", "block"); getDownloadURL(); getDeviceCap(); getResolutionURL(); lan("login"); if ($.cookie("userInfo")) { gVar.user = Base64.decode($.cookie("userInfo")).split(":")[0]; $("#username").val(gVar.user); } $("#login_language").empty(); for (var m = 0; m < gs_language.length; m++) { $("#login_language").append(''); } $("#login_language").val(gVar.lg); $("#login_language").change(function () { lg.refresh(); gVar.lg = $(this).val(); LanguageCall($(this).val()); }); if ($.cookie("remember") == 1 && $.cookie("userInfo")) { if (Base64.decode($.cookie("userInfo")).split(":")[1]) { $("#passwd").val(Base64.decode($.cookie("userInfo")).split(":")[1]); } else { $("#passwd").val(""); } $("#rememberText").prop("checked", 1); } if (gVar.mediaport == null) { gVar.mediaport = 6060; } $("#username, #passwd").keydown(function (e) { if (e.keyCode == 13) { Login(); } }); }, "html"); } var newMon = ''; var newYear = ''; var m_year, m_month, m_day; var m_dtSearchDate = ''; var m_dtCalendarDate = ''; var RecordInfos = ""; var gs_RecordInfo = []; var langList = [{ name: 'ENU', lan: 'en' }, { name: 'CHS', lan: 'zh-cn' }, { name: 'CHT', lan: 'zh-tw' } ]; function playbackCalendar() { var myDate = new Date(); newMon = myDate.getMonth() + 1; newYear = myDate.getFullYear(); getRecordInfoByMonth(newYear, newMon); m_year = newYear; m_month = newMon; m_day = myDate.getDate(); var date = new Time(); m_dtSearchDate = date.getStringTime().split(" ")[0]; m_dtCalendarDate = m_dtSearchDate; var szLanguage = $.cookie("language"); for (var i = 0; i < langList.length; i++) { if (szLanguage == langList[i].name) { szLanguage = langList[i].lan; } } WdatePicker({ minDate: '1970-01-01 00:00:00', maxDate: '2037-12-31 23:59:59', lang: szLanguage, eCont: 'div1', onpicked: function (dp) { m_dtCalendarDate = dp.cal.getDateStr(); m_day = dp.cal.getDateStr().substr(8, 2); }, //日期格式为xxxx-xx-xx 个位数写为0x specialDates: gs_RecordInfo, Mchanged: function (dp) { gs_RecordInfo = []; newMon = dp.cal.newdate['M']; getRecordInfoByMonth(newYear, newMon); for (var i = 0; i < gs_RecordInfo.length; i++) { dp.specialDates.push(gs_RecordInfo[i]); } return dp; }, ychanged: function (dp) { gs_RecordInfo = []; newYear = dp.cal.newdate['y']; getRecordInfoByMonth(newYear, newMon); for (var i = 0; i < gs_RecordInfo.length; i++) { dp.specialDates.push(gs_RecordInfo[i]); } return dp; } }); } function LoadLeftPage(func) { tabkey = 0; $.get("html/left.html?" + gVar.nDate, "", function (data) { $(".mclcontainer").prop("innerHTML", data).attr("name", "isDown"); lan("left"); CreateLiveBtn(); //创建左边栏按钮,注册左边栏按钮事件 $.getScript("js/left.js", function () { func(); }); }, "html"); } function LoadOtherPage() { $.get("html/right.html?" + gVar.nDate, "", function (data) { $(".mcrcmain").html(data); lan("right"); SilderGetCall(); UI.Slider("gsliderCov", "gsliderBtn", "gslider"); $(".rtstyle1_1").mousedown(function(){ var cruise = $("#cruise").val() * 1; var pos = $("#preset").val() * 1; if ($(this).attr("id") == "pre_set") { gDvr.PTZPresetSet(pos - 1); } else if ($(this).attr("id") == "pre_call") { gDvr.PTZPresetCall(pos - 1); } else if ($(this).attr("id") == "StartCruise") { gDvr.PTZadjust(cruise, "StartCruiseStartCruise"); } else if ($(this).attr("id") == "StopCruise") { gDvr.PTZadjust(cruise, "StopCruise"); } }) $(".liveBtnBt9").mouseover(function () { if ($(this).attr("name") != "active") { $(this).attr("title", lg.get("IDS_SOUND_OPEN")); } else { $(this).attr("title", lg.get("IDS_SOUND_OFF")); } }).mousedown(function () { if ($(this).attr("name") != "active") { gDvr.AudioControl(-1, 1); //预览声音按钮是全局的,和通道无关 audioControl = true; $(this).css("background-position", "0px 0px").attr("name", "active"); } else { gDvr.AudioControl(-1, 0); audioControl = false; $(this).css("background-position", "32px 0px").attr("name", ""); } }); //点击Zoom图标,调用插件接口 $(".liveBtnBt11").mousedown(function () { if ($(this).attr("name") != "active") { gDvr.OpenElectronicZoomout(); $(this).css("background-position", "0px 0px").attr("name", "active"); //off-->on } else { gDvr.CloseElectronicZoomout(); $(this).css("background-position", "32px 0px").attr("name", ""); //on-->off } }); //点击扬声器图标,调用插件接口 $(".liveBtnBt12").mouseover(function () { if ($(this).attr("name") != "active") { $(this).attr("title", lg.get("IDS_TALKBACK_ON")); } else { $(this).attr("title", lg.get("IDS_TALKBACK_OFF")); } }).mousedown(function () { if ($(this).attr("name") != "active") { //对讲接口 gDvr.StartVoiceStream(); $(this).css("background-position", "-64px -256px").attr("name", "active"); //off-->on } else { gDvr.StopVoiceStream(); $(this).css("background-position", "0px -256px").attr("name", ""); //on-->off } }); $(".liveBtnBt10").mouseover(function (e) { if (autoSize[curSelChn] == 1) { $(".liveBtnBt10").attr("title", lg.get("IDS_BESPREAD")) $(this).css("background-position", "-32px -160px"); } else { $(".liveBtnBt10").attr("title", lg.get("IDS_PREVIEW_MENUSIZE")) $(this).css("background-position", "-96px -160px"); } }).mouseout(function (e) { if (autoSize[curSelChn] == 1) { $(this).css("background-position", "-0px -160px"); } else { $(this).css("background-position", "-64px -160px"); } }).mousedown(function (e) { if (autoSize[curSelChn] == 1) { gDvr.AspectRatioControl(0, -1); $(this).css("background-position", "-64px -160px"); autoSize[curSelChn] = 0; } else { gDvr.AspectRatioControl(1, -1); $(this).css("background-position", "-0px -160px"); autoSize[curSelChn] = 1; } }); $("#image_default").click(function () { setImgDefault() }); /************************************************* Function: setImgDefault Description: 保存ImgDefault信息 *************************************************/ function setImgDefault() { var cyXmlirc = "initiative07:00:0019:00:00503"; var cyURL = 'http://' + gVar.ip + ':' + gVar.port + "/Images/" + ptzSelChn + "/Restore"; $.ajax({ type: "PUT", url: cyURL, processData: false, data: cyXmlirc, beforeSend: function (xhr) { xhr.setRequestHeader("If-Modified-Since", "0"); }, complete: function (xhr, textStatus) { getColor(ptzSelChn); } }); } //云台 $("#TurnUp_1_0").mouseover(function () { $("#LIVE_YT").css("background-position", "-160px 0px"); }).mouseout(function () { $("#LIVE_YT").css("background-position", "0px 0px"); }); $("#TurnLeft_1_0").mouseover(function () { $("#LIVE_YT").css("background-position", "-480px -160px"); }).mouseout(function () { $("#LIVE_YT").css("background-position", "0px 0px"); }); $("#TurnRight_1_0").mouseover(function () { $("#LIVE_YT").css("background-position", "-480px 0px"); }).mouseout(function () { $("#LIVE_YT").css("background-position", "0px 0px"); }); $("#TurnDown_1_0").mouseover(function () { $("#LIVE_YT").css("background-position", "-160px -160px"); }).mouseout(function () { $("#LIVE_YT").css("background-position", "0px 0px"); }); $(".ptzDirctory").mousedown(function () { var param1 = $(this).attr("id").split("_")[1]; var cmd = $(this).attr("id").split("_")[0]; gDvr.PTZcontrol(param1, cmd, Math.round($("#gsliderCov").attr("speed") / 10)); }).mouseup(function (e) { var param2 = $(this).attr("id").split("_")[2]; var cmd = $(this).attr("id").split("_")[0]; gDvr.PTZcontrol(param2, cmd, Math.round($("#gsliderCov").attr("speed") / 10)); }) //预置点 for (var i = 1; i < 256; i++) { $("#preset").append(''); } //提示语 $(".liveBtnBt1").attr("title", lg.get("IDS_OPEN_ALL_CHANNEL")); $(".liveBtnBt2").attr("title", lg.get("IDS_CLOSE_ALL_CHANNEL")); $(".liveBtnBt5").attr("title", lg.get("IDS_FULLSCREEN")); $(".liveBtnBt6").attr("title", lg.get("IDS_TIP_SPLITER")); $(".liveBtnBt11").attr("title", lg.get("IDS_ELEC_AMPLIFICATION")); $("#ZoomIn_1_0").attr("title", lg.get("IDS_PTZ_ZOOMUP")); $("#ZoomOut_1_0").attr("title", lg.get("IDS_PTZ_ZOOMDOWN")); $("#FocusFar_1_0").attr("title", lg.get("IDS_PTZ_FOCUSUP")); $("#FocusNear_1_0").attr("title", lg.get("IDS_PTZ_FOCUSDOWN")); $("#ApertureBigger_1_0").attr("title", lg.get("IDS_PTZ_IRIUP")); $("#ApertureSmaller_1_0").attr("title", lg.get("IDS_PTZ_IRIDOWN")); $("#ytctrl_5").attr("title", lg.get("IDS_PTZ_AUTO")); $("#TurnUp_1_0").attr("title", lg.get("IDS_PTZ_UP")); $("#live_yt2_5").attr("title", lg.get("IDS_PTZ_LEFTUP")); $("#live_yt3_6").attr("title", lg.get("IDS_PTZ_RIGHTUP")); $("#TurnLeft_1_0").attr("title", lg.get("IDS_PTZ_LEFT")); $("#live_yt6_21").attr("title", lg.get("IDS_PTZ_AUTO")); $("#TurnRight_1_0").attr("title", lg.get("IDS_PTZ_RIGHT")); $("#live_yt2_7").attr("title", lg.get("IDS_PTZ_LEFTDOWN")); $("#live_yt3_8").attr("title", lg.get("IDS_PTZ_RIGHTDOWN")); $("#TurnDown_1_0").attr("title", lg.get("IDS_PTZ_DOWN")); $(".ptzLine").mousedown(function () { var param1 = $(this).attr("id").split("_")[1]; var cmd = $(this).attr("id").split("_")[0]; gDvr.PTZset(param1, cmd, Math.round($("#gsliderCov").attr("speed") / 10)); }).mouseup(function (e) { var param2 = $(this).attr("id").split("_")[2]; var cmd = $(this).attr("id").split("_")[0]; gDvr.PTZset(param2, cmd, Math.round($("#gsliderCov").attr("speed") / 10)); }) $("#live_wd_ld1").attr("title", lg.get("IDS_CONSTRAST")); $("#live_wd_dbd1").attr("title", lg.get("IDS_LIGHT")); $("#live_wd_bhd1").attr("title", lg.get("IDS_SATURATION")); $("#live_wd_sj1").attr("title", lg.get("IDS_HUE")); $("#live_wd_sh1").attr("title", lg.get("IDS_ACUTANCE")); $("#pre_set").attr("title", lg.get("IDS_SET_PRESET")); $("#pre_call").attr("title", lg.get("IDS_CALL_PRESET")); $("#StopCruise").attr("title", lg.get("IDS_STOP_CURISE")); $("#StartCruise").attr("title", lg.get("IDS_CALL_CURISE")) }, "html"); } //登陆函数 function Login() { gVar.nOpenPreView = $("#openPreview").prop("checked"); gVar.user = $("#username").val(); gVar.passwd = $("#passwd").val(); gVar.nStreamType = $("#login_ml").val(); if (gVar.user == "") { Web_prompt(lg.get("IDS_NO_USERNAME")); return; } UserLoginEvent(); } function UserLoginEvent() { $.ajax({ url: 'http://' + gVar.ip + ':' + gVar.port + "/Security/UserAuth", type: "PUT", timeout: 15000, data: 'Username=' + gVar.user + '&Password=' + gVar.passwd, beforeSend: function (xhr) { xhr.setRequestHeader("If-Modified-Since", "0"); }, success: function (xmlDoc, textStatus) { var loginState = $(xmlDoc).find('ResponseStatus').find('statusCode').text(); if (loginState == 0) { loginLoad(); } else if (-17 == loginState) { Web_prompt(lg.get("IDS_PASSWORD_ERROR")); //密码错误 } else if ("timeout" == textStatus) { Web_prompt(lg.get("IDS_LINK_TIMEOUT")); //连接超时 } else { Web_prompt(lg.get("IDS_NETWORK_EXCEPTION")); //网络异常 } }, error: function (xhr, textStatus, errorThrown) { } }); } /************************************************* Function: loginLoad Description: 初始化登陆数据 **************************************************/ function loginLoad() { $.ajax({ url: 'http://' + gVar.ip + ':' + gVar.port + "/Network/Port", type: "GET", username: gVar.user, password: gVar.passwd, timeout: 15000, beforeSend: function (xhr) { xhr.setRequestHeader("If-Modified-Since", "0"); }, success: function (xmlDoc) { var option = { expires: 10 }; m_cyUserPwdValue = Base64.encode(gVar.user + ":" + gVar.passwd); var cPort = $(xmlDoc).find('Port').eq(0).find('Command').text(); $.cookie('userInfo', m_cyUserPwdValue); $.cookie("language", $("#login_language").val(), option); if ($("#rememberText").prop("checked")) { $.cookie("remember", 1, option); } else { $.cookie("remember", 0, option); $("#rememberText").prop("checked", 0); } gDvr.GetDvrInfo(); //初始化控件,获取设备信息 LoadOtherPage(); //载入其他页面 //进入live页面 LoadLeftPage(function () { LoadLiveTile(); $("#login").remove(); $(".header").css("height", "54px"); $("#dvrocx").css({ width: "100%", height: "100%" }); $(".main").css("height", "auto"); $("#LoginLOGO").css("height", "40px"); $("#live_ptz_show").css("display", "block"); if (gDvr.nTalkBack == "false") { $(".liveBtnBt12").css("display", "none"); } if ($.browser.msie) { gDvr.SetActiveXType(0); gDvr.DeviceLogin(gVar.ip, cPort, gVar.user, gVar.passwd); gDvr.RealtimeViewInitialize(); var xml = ""; gDvr.SetLanaguageResource(xml); } initPlayback(); //界面显示处理 switch (gDvr.nChannel * 1) { case 36: $(".liveSSBtn").attr("widthR", 225).css("width", 225); $(".liveBtnSbt14").mousedown(); break; case 25: $(".liveSSBtn").attr("widthR", 200).css("width", 200); $(".liveBtnSbt13").mousedown(); break; case 16: $(".liveSSBtn").attr("widthR", 175).css("width", 175); $(".liveBtnSbt12").mousedown(); break; case 10: $(".liveSSBtn").attr("widthR", 150).css("width", 150); $(".liveBtnSbt6").mousedown(); break; case 9: $(".liveSSBtn").attr("widthR", 125).css("width", 125); $(".liveBtnSbt5").mousedown(); break; case 8: $(".liveSSBtn").attr("widthR", 125).css("width", 125); $(".liveBtnSbt5").mousedown(); break; case 6: $(".liveSSBtn").attr("widthR", 75).css("width", 75); $(".liveBtnSbt3").mousedown(); break; case 4: $(".liveSSBtn").attr("widthR", 50).css("width", 50); $(".liveBtnSbt2").mousedown(); break; default: $(".liveSSBtn").attr("widthR", 275).css("width", 275); $(".liveBtnSbt12").mousedown(); break; } if (gVar.nOpenPreView) { $(".liveBtnBt1").click(); } else { $(".liveBtnBt2").css("background-position", "-64px -31px").attr("name", "active"); } }); }, error: function (xhr, textStatus, errorThrown) { } }); } function LoadLiveTile() { document.getElementById("LiveMenu_1").innerHTML = lg.get("IDS_LIVE_PAGE"); document.getElementById("PlayBackMenu_1").innerHTML = lg.get("IDS_REPLAY"); document.getElementById("LogMenu_1").innerHTML = lg.get("IDS_SYS_LOG"); document.getElementById("ConfigMenu_1").innerHTML = lg.get("IDS_SYS_SET"); document.getElementById("PathMenu_1").innerHTML = lg.get("IDS_PATH_PATH"); document.getElementById("LogoutMenu_1").innerHTML = lg.get("IDS_SERVER_LOGOUT"); //初始化设备方法 if (g_bIsIE) { menutitle(1); } else { menutitle(4); $(".Menu4").click(); $("#LiveMenu").hide(); $("#PlayBackMenu").hide(); $("#PathMenu").hide(); } } function LoadLogPage() { document.getElementById("laLogNum").innerHTML = lg.get("IDS_LOG_NUM"); document.getElementById("laLogEvent").innerHTML = lg.get("IDS_LOG_EVENT"); document.getElementById("laLogTime").innerHTML = lg.get("IDS_LOG_TIME"); } function changeWndSize() { var canvas = document.getElementById("timebar"); if (canvas.getContext) { //判断浏览器是否支持canvas获取上下文 tTimeBar = new TimeBar(canvas, $("#playbackbar").width(), 60); tTimeBar.setMidLineTime(m_year + '-' + m_month + '-' + m_day + ' ' + '00:00:00'); for (var k = 0; k < m_szTime.length; k++) { tTimeBar.addFile(m_szTime[k].start, m_szTime[k].end, m_szTime[k].type); } tTimeBar.m_tClickCurTime = selclkTime; tTimeBar.repaint(); } else { $("#timebar").html(''); } } function getOSDName(ch) { $.ajax({ type: "GET", url: 'http://' + gVar.ip + ':' + gVar.port + "/Pictures/" + (ch + 1) + "/OSD", processData: false, beforeSend: function (xhr) { xhr.setRequestHeader("If-Modified-Since", "0"); }, success: function (xmlDoc) { var osdName = $(xmlDoc).find('OSD').eq(0).find('DisplayName').eq(0).find('Name').eq(0).text(); gDvr.SetChannelShowText(ch, osdName); } }); } //初始化回放界面 function initPlayback() { var selChid = 0; var enDown = false; GetNowTime(); initMouseHover(); initVolumeSlider(); //------playback页面Button注册------ changeWndSize(); $("div[id^='playbackBtn_']").unbind('click'); $("div[id^='pbCheck']").each(function () { if ($(this).css("background-image").indexOf("cbox_on.png") >= 0) { selChid = $(this).attr("id").split("pbCheck")[1] * 1 - 1; } }); $("#DownloadBtn").click(function () { if ($("#path").val() == "") { ShowPaop(lg.get("IDS_BTN_PLAYBACK"), lg.get("IDS_NO_PATH_PLAYBACK")); return; } var xml = "" + "" + "" + $("#RecordChannel").val() + "" + "" + $("#VideoType").val() + "" + "1" + "" + $("#beginTime").val() + "" + "" + $("#endTime").val() + "" + "" + $("#dataType").val() + "" + "31457280" + "" + $("#path").val() + "" + "1" + "0" + ""; var nRet = gDvr.StartHistroyStreamDownload(xml); if (nRet == 1) { ShowPaop(lg.get("IDS_BTN_PLAYBACK"), lg.get("IDS_NO_PLAYBACK")); return; } if (nRet == 0) { enDown = true; ShowPaop(lg.get("IDS_REPLAY"), lg.get("IDS_PLAYBACK_DOWNLOAD_START")); downloadFlag = setInterval("getRemoteDownloadPercent()", 3000); } else { ShowPaop(lg.get("IDS_REPLAY"), lg.get("IDS_PLAYBACK_DOWNLOAD_FAILED")); } }); $("#StopDownload").click(function () { if (enDown) { var nRet = gDvr.StopHistroyStreamDownload($("#RecordChannel").val()); if (nRet == 0) { $("#downProgress").width(0); clearInterval(downloadFlag); ShowPaop(lg.get("IDS_REPLAY"), lg.get("IDS_STOP_DOWNLOAD_SUCCESS")); } else { ShowPaop(lg.get("IDS_REPLAY"), lg.get("IDS_STOP_DOWNLOAD_FAILED")); } } }); $("#playbackBtn_1").click(function () { StartPlayBack(plkSelChn - 1); return false; }); $("#playbackBtn_2").click(function () { StopPlayBack(); return false; }); $("#playbackBtn_3").click(function () { PlayBackSlowly(); return false; }); $("#playbackBtn_4").click(function () { PlayBackFast(); return false; }); $("#playbackBtn_5").click(function () { if (m_bIsPlaying) { gDvr.CaptureImageRemotePlayback(plkSelChn - 1); var str = gDvr.GetLocalSettings(); var xmlDoc = parseXmlFromStr(str); var strTemp = xmlDoc.getElementsByTagName("LocalSettings")[0].getAttribute("SelectDiskDriver"); ShowPaop(lg.get("IDS_IMAGE_SAVE_PATH"), "
" + strTemp + ":\\webclient2\\images" + "
" + lg.get("IDS_PREVIEW") + "   " + lg.get("IDS_PATH") + ""); } return false; }); $("#playbackBtn_6").click(function () { PlayBackFrame(plkSelChn - 1); return false; }); $("#playbackBtn_7").click(function () { PlaySoundRemotePlayback(plkSelChn - 1); return false; }); function initMouseHover() { for (var i = 0; i < gDvr.nChannel; i++) { $("").appendTo("#RecordChannel"); } $(".buttonmouseout").each(function () { $(this).hover(function () { if ($(this).children().hasClass("") || $(this).children().hasClass("stopdisable") || $(this).children().hasClass("slowlyforwarddisable") || $(this).children().hasClass("fastforwarddisable") || $(this).children().hasClass("singleframedisable") || $(this).children().hasClass("capturedisable") || $(this).children().hasClass("recorddisable") || $(this).children().hasClass("sounddisable")) { } else { $(this).removeClass().addClass("buttonmouseover"); } }, function () { $(this).removeClass().addClass("buttonmouseout"); }); }); $("#playdisable").attr("title", lg.get("IDS_PLAYBACK_PLAY")); $("#stop").attr("title", lg.get("IDS_PLAYBACK_STOP")); $("#SlowlyForward").attr("title", lg.get("IDS_PLAYBACK_SLOW")); $("#FastForward").attr("title", lg.get("IDS_PLAYBACK_FAST")); $("#capture").attr("title", lg.get("IDS_PLAYBACK_CAPTURE")); $("#SingleFrame").attr("title", lg.get("IDS_PLAYBACK_SINGLE")); $("#playbackBtn_7").attr("title", lg.get("IDS_PLAYBACK_SOUND1")); $("#timeNarrow").attr("title", lg.get("IDS_PLAYBACK_NARROW")); $("#timeExpand").attr("title", lg.get("IDS_PLAYBACK_EXPAND")); } function StartPlayBack(ch) { if (m_szStartTimeSet.length == 0) { return } var strRemotePlaybackRequest = "" + ch + "0false" + m_szTime[0].start.substr(0, 4) + "" + m_szTime[0].start.substr(5, 2) + "" + m_szTime[0].start.substr(8, 2) + "" + m_szTime[0].start.substr(11, 2) + "" + m_szTime[0].start.substr(14, 2) + "" + m_szTime[0].start.substr(17, 2) + "" + m_szTime[0].start.substr(0, 4) + "" + m_szTime[0].start.substr(5, 2) + "" + m_szTime[0].start.substr(8, 2) + "" + m_szTime[0].start.substr(11, 2) + "" + m_szTime[0].start.substr(14, 2) + "" + m_szTime[0].start.substr(17, 2) + ""; if (!m_bIsPlaying) { playFlag = true; try { gDvr.StartRemotePlayback(strRemotePlaybackRequest) } catch (e) {} tTimeBar.m_tClickCurTime = m_szStartTimeSeconds; selclkTime = m_szStartTimeSeconds; tTimeBar.repaint(); $("#playdisable").removeClass().addClass("pause").attr("title", lg.get("IDS_PLAYBACK_PAUSE")); $("#stop").removeClass().addClass("stop"); $("#SlowlyForward").removeClass().addClass("slowlyforward"); $("#FastForward").removeClass().addClass("fastforward"); $("#SingleFrame").removeClass().addClass("singleframe"); $("#capture").removeClass().addClass("capture"); $("#playbackBtn_7").removeClass().addClass("closesound"); $(".toolright").show(); $("#speedLogo").text("1X"); m_bIsPlaying = true; m_bWndPause = false; } else { if (!m_bWndPause && !m_bWndFrame) { gDvr.RemotePlaybackSuspend(1, ch); $("#playdisable").removeClass().addClass("playdisable").attr("title", lg.get("IDS_PLAYBACK_PLAY")); $("#SlowlyForward").removeClass().addClass("slowlyforwarddisable"); $("#FastForward").removeClass().addClass("fastforwarddisable"); $("#SingleFrame").removeClass().addClass("singleframedisable"); $("#capture").removeClass().addClass("capture"); m_bIsPlaying = true; m_bWndPause = true; } else { if (m_bWndPause && !m_bWndFrame) { gDvr.RemotePlaybackSuspend(0, ch); $("#playdisable").removeClass().addClass("pause").attr("title", lg.get("IDS_PLAYBACK_PAUSE")); $("#SlowlyForward").removeClass().addClass("slowlyforward"); $("#FastForward").removeClass().addClass("fastforward"); $("#SingleFrame").removeClass().addClass("singleframe"); $("#capture").removeClass().addClass("capture"); m_bIsPlaying = true; m_bWndPause = false; } else { gDvr.PlayByFrameRemotePlayback(ch, 1); $("#playdisable").removeClass().addClass("pause").attr("title", lg.get("IDS_PLAYBACK_PAUSE")); $("#SlowlyForward").removeClass().addClass("slowlyforward"); $("#FastForward").removeClass().addClass("fastforward"); $("#SingleFrame").removeClass().addClass("singleframe"); $("#capture").removeClass().addClass("capture"); m_bWndPause = false; m_bWndFrame = false; } } } } function PlayBackSlowly() { if (m_bIsPlaying && !m_bWndPause && !m_bWndFrame) { if (m_iWndSpeed > 1 / 16) { gDvr.SetSpeedRemotePlayback(0, plkSelChn - 1); m_bWndFrame = false; m_iWndSpeed = 1 / 2 * m_iWndSpeed; } if (m_iWndSpeed < 1) { $("#speedLogo").text("1/" + (1 / m_iWndSpeed) + "X"); } else { $("#speedLogo").text(m_iWndSpeed + "X"); } } } function PlayBackFast() { if (m_bIsPlaying && !m_bWndPause && !m_bWndFrame) { if (m_iWndSpeed < 16) { gDvr.SetSpeedRemotePlayback(1, plkSelChn - 1); m_bWndFrame = false; m_iWndSpeed = 2 * m_iWndSpeed; } if (m_iWndSpeed < 1) { $("#speedLogo").text("1/" + (1 / m_iWndSpeed) + "X"); } else { $("#speedLogo").text(m_iWndSpeed + "X"); } } } function PlayBackFrame(ch) { gDvr.PlayByFrameRemotePlayback(ch, 0); $("#playdisable").removeClass().addClass("playdisable").attr("title", lg.get("IDS_PLAYBACK_PLAY")); m_bWndFrame = true; } function PlaySoundRemotePlayback(ch) { if (m_bIsPlaying && !m_bSound) { gDvr.PlaySoundRemotePlayback(1, ch); m_bSound = true; $("#playbackBtn_7").removeClass().addClass("volume"); $("#playbackBtn_7").attr("title", lg.get("IDS_PLAYBACK_SOUND2")); } else if (m_bIsPlaying) { gDvr.PlaySoundRemotePlayback(0, ch); m_bSound = false; $("#playbackBtn_7").removeClass().addClass("closesound"); $("#playbackBtn_7").attr("title", lg.get("IDS_PLAYBACK_SOUND1")); } } } function initVolumeSlider() { var iVol; sliderVolume = new neverModules.modules.slider({ targetId: "volumeDiv", sliderCss: "imageslider1", barCss: "imageBar2", min: 0, max: 100 }); sliderVolume.onchange = function () { if (m_bIsPlaying && m_bSound) { iVol = sliderVolume.getValue(); if (iVol > 0) { gDvr.RemotePlaybackSetVolume(iVol, plkSelChn - 1); } sliderVolume.setTitle('' + iVol); } else { this.wsetValue(0); } }; sliderVolume.create(); } //停止播放 function StopPlayBack() { if (m_bIsPlaying) { playFlag = false; gDvr.StopRemotePlayback(); $("#playdisable").removeClass().addClass("playdisable").attr("title", lg.get("IDS_PLAYBACK_PLAY")); $("#stop").removeClass().addClass("stopdisable"); $("#SlowlyForward").removeClass().addClass("slowlyforwarddisable"); $("#FastForward").removeClass().addClass("fastforwarddisable"); $("#SingleFrame").removeClass().addClass("singleframedisable"); $("#capture").removeClass().addClass("capturedisable"); $("#playbackBtn_7").removeClass().addClass("sounddisable"); $(".toolright").hide(); $("#speedLogo").text("1X"); m_bIsPlaying = false; m_iWndSpeed = 1; m_bSound = false; m_bWndFrame = false; } } function getRemoteDownloadPercent() { var nCet = gDvr.GetRemoteDownloadPercent(); if (0 < nCet && nCet < 100) { $("#downProgress").width(nCet * 1.6); } else if (nCet == -12) { $("#downProgress").width(0); clearInterval(downloadFlag); ShowPaop(lg.get("IDS_REPLAY"), lg.get("IDS_PLAYBACK_DOWNLOAD_SUCCESS")); } } function GetNowTime() { var myDate = new Date(); var iYear = myDate.getFullYear(); var iMon = myDate.getMonth(); var iDay = myDate.getDate(); iMon = parseInt(iMon) + 1; if (iMon <= 9) { iMon = '0' + iMon; } var szNowTime = iYear + "-" + iMon + "-" + iDay + " 00:00:00"; $("#beginTime").val(szNowTime); $("#endTime").val(iYear + "-" + iMon + "-" + iDay + " 23:59:59"); } function browseFolder() { var nRet = gDvr.FolderPickerDialog(); $("#path").val(nRet); // alert(nRet); // try { // var Message = "\u8bf7\u9009\u62e9\u6587\u4ef6\u5939"; //选择框提示信息 // var Shell = new ActiveXObject("Shell.Application"); // var Folder = Shell.BrowseForFolder(0, Message, 0x0011, 0); //起始目录为:我的电脑 // if (Folder != null) { // Folder = Folder.items(); // 返回 FolderItems 对象 // Folder = Folder.item(); // 返回 Folderitem 对象 // Folder = Folder.Path; // 返回路径 // if (Folder.charAt(Folder.length - 1) != "\\") { // Folder = Folder + "\\"; // } // document.getElementById(path).value = Folder; // alert(Folder); // return Folder; // } // } // catch (e) { // alert(e.message); // } } function GetDataCallBack() {} //回调函数定义 function NotifySelectChannelChanged(data) { GetDataCallBack(data); } function menutitle(n) { var arr = ['LiveMenu', 'PlayBackMenu', 'LogMenu', 'ConfigMenu', 'PathMenu', 'LogoutMenu']; for (var i = 0; i < 6; i++) { $("#" + arr[i]).removeClass(); } $("#" + arr[n - 1]).addClass("selItem"); } document.onkeydown = function (e) { e = e || window.event; if (e.keyCode == 9 && tabkey == 0) { e.keyCode = 0; e.returnValue = false; return false; } }; function SilderGetCall() { hue = new cursor(); Bright = new cursor(); Contrast = new cursor(); Saturation = new cursor(); Sharp = new cursor(); hue.create("live_wd_sj"); Bright.create("live_wd_ld"); Contrast.create("live_wd_dbd"); Saturation.create("live_wd_bhd"); Sharp.create("live_wd_sh"); $("#live_wd_sj1").attr("title", lg.get("IDS_HUE")); $("#live_wd_dbd1").attr("title", lg.get("IDS_LIGHT")); $("#live_wd_ld1").attr("title", lg.get("IDS_CONSTRAST")); $("#live_wd_bhd1").attr("title", lg.get("IDS_SATURATION")); $("#live_wd_sh1").attr("title", lg.get("IDS_ACUTANCE")); Bright.Default(50); Contrast.Default(50); Saturation.Default(50); Sharp.Default(50); hue.Default(50); } //拖动条改变 function cursor() { var $obj = ""; ColorSetMax = 100; var num = 100; //100格子 ColorSetCube = ColorSetMax / num; //1个格子表示的数值 var value = 0; var timeOut; this.val = function () { return value; }; //set line number this.num = function (i) { num = i; }; //create cube this.create = function (id) { $obj = $("#" + id); if ($obj.attr("create") == "down") return; else $obj.attr("create", "down"); $obj.removeClass().addClass("cursorPar"); $obj.empty(); $obj.append("10"); $obj.append("
    ") for (var i = 0; i < num; i++) { $obj.children("ol").prepend("
  1. "); } var down = false; var thisClass = this; $obj.children("ol").children().each(function (i) { var number = $(this).attr("num"); $(this).mousedown(function () { down = true; var tempvalue = number / 100 * (ColorSetMax - 1); if (tempvalue < 0.5) { //最大值为6时的点击精度问题 value = 0; } else if (tempvalue > ColorSetMax - 1.5) { value = ColorSetMax; } else { value = Math.ceil(number / 100 * (ColorSetMax - 1)); } thisClass.Default(value); }).mouseover(function () { if (down == true) { var tempvalue = number / 100 * (ColorSetMax - 1); if (tempvalue < 0.5) { //最大值为6时的点击精度问题 value = 0; } else if (tempvalue > ColorSetMax - 1.5) { value = ColorSetMax; } else { value = Math.ceil(number / 100 * (ColorSetMax - 1)); } thisClass.Default(value); } }).mouseup(function () { if (down == true) { var xml = ""; switch ($obj.attr("flag")) { case "1": xml = "" + "manual" + "" + $("#live_wd_ld em").text() + "" + "" + $("#live_wd_dbd em").text() + "" + "" + $("#live_wd_bhd em").text() + "" + "" + value + "" + "" + $("#live_wd_sh em").text() + "" + ""; break; case "2": xml = "" + "manual" + "" + value + "" + "" + $("#live_wd_dbd em").text() + "" + "" + $("#live_wd_bhd em").text() + "" + "" + $("#live_wd_sj em").text() + "" + "" + $("#live_wd_sh em").text() + "" + ""; break; case "3": xml = "" + "manual" + "" + $("#live_wd_ld em").text() + "" + "" + value + "" + "" + $("#live_wd_bhd em").text() + "" + "" + $("#live_wd_sj em").text() + "" + "" + $("#live_wd_sh em").text() + "" + ""; break; case "4": xml = "" + "manual" + "" + $("#live_wd_ld em").text() + "" + "" + $("#live_wd_dbd em").text() + "" + "" + value + "" + "" + $("#live_wd_sj em").text() + "" + "" + $("#live_wd_sh em").text() + "" + ""; break; case "5": xml = "" + "manual" + "" + $("#live_wd_ld em").text() + "" + "" + $("#live_wd_dbd em").text() + "" + "" + $("#live_wd_bhd em").text() + "" + "" + $("#live_wd_sj em").text() + "" + "" + value + "" + ""; break; } gDvr.GetAndSetVideoInfo(xml, curSelChn + 1); down = false; } }); }); }; // set default value this.Default = function (i) { //选择的部分 $obj.children("em").prop("innerHTML", i); i = parseInt((ColorSetMax - i * 1) / ColorSetCube); $obj.children("ol").children().each(function (j) { if (i <= j && $(this).attr("num") != 0) $(this).css("background", "url(images/bar_cell.png)"); //选择 else { $(this).css("background", "url(images/bar_bg.png)"); //未选择 } }); }; } function getDownloadURL() { $.ajax({ url: 'http://' + gVar.ip + ":" + gVar.port + "/Config.json", type: "get", async: true, timeout: 15000, beforeSend: function (xhr) { xhr.setRequestHeader("If-Modified-Since", "0"); }, success: function (data) { var data = JSON.parse(data); var appUrl = data.P2P ? (data.P2P.AppUrl ? data.P2P.AppUrl : null) : null; var did = data.P2P ? (data.P2P.UID ? data.P2P.UID : null) : null; devName = data.DeviceType ? data.DeviceType : null; ipChannel = data.Channel?(data.Channel.IP?parseInt(data.Channel.IP):null):null; analog = data.Channel?(data.Channel.Analog?parseInt(data.Channel.Analog):null):null; if (devName) { $(document).attr("title", devName); } else { $(document).attr("title", "NVR"); } if (appUrl || did) { $("#p2p_uid").show(); $("#p2pQrcode").empty(); new QRCode("p2pQrcode", { text: did, width: 120, height: 120, colorDark: "#000000", colorLight: "#ffffff", correctLevel: QRCode.CorrectLevel.H }); $("#APPQrcode").empty(); new QRCode("APPQrcode", { text: appUrl, width: 120, height: 120, colorDark: "#000000", colorLight: "#ffffff", correctLevel: QRCode.CorrectLevel.H }); } }, error: function () { ipChannel = null; } }); } function getDeviceCap(){ $.ajax({ url: 'http://' + gVar.ip + ":" + gVar.port + "/DeviceCap.json", type: "GET", async: true, timeout: 15000, beforeSend: function (xhr) { xhr.setRequestHeader("If-Modified-Since", "0"); }, success: function (data) { deviceCap = JSON.parse(data); }, error: function () { } }); } function getResolutionURL() { $.ajax({ url: 'http://' + gVar.ip + ":" + gVar.port + "/ResolutionList.json", type: "get", async: true, timeout: 15000, beforeSend: function (xhr) { xhr.setRequestHeader("If-Modified-Since", "0"); }, success: function (data) { var data = JSON.parse(data); gs_arrResolution = data.ResolutionList ? data.ResolutionList : null; }, error: function () { gs_arrResolution = null; } }); }