";
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("");
}
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;
}
});
}