// JavaScript Document
//hashmap --
//刷新整个哈希表数据时请先调用refresh()
//跟新数据时请调用up()
//删除对象请调用clear()
//zdy-2011/7/9
function HashmapCom() {
Init(this); //构造函数
function Init(p) {
p.map = new Hashmap();
}
function Hashmap() {
this.length = 0;
this.set = function (key, value) {
this[key] = value;
this[this.length] = key;
this.length++;
};
this.up = function (key, value) {
(typeof this[key] != 'undefined') ? (this[key] = value) : alert("hashmap: key " + key + " undefined");
};
this.get = function (key) {
return ((typeof this[key] == 'undefined') ? null : this[key]);
}
}
this.refresh = function () {
this.map.length = 0;
};
this.clear = function () {
delete this.map;
};
this.length = function () {
return (this.map.length);
};
this.set = function (key, value) {
this.map.set(key, value);
};
this.get = function (key) {
return (this.map.get(key));
};
this.up = function (key, value) {
this.map.up(key, value);
}
}
//UI类
function UIReg() {
//Button按钮
//objStr:被注册按钮对象字符串
//Width:被注册按钮对象事件响应向左偏移量
//top:被注册按钮对象事件响应向上偏移量
this.Button = function (objStr, left, top, callback) {
var MouseDown = false;
if (typeof top == 'undefined' || top == null || top == "") top = false;
if (!($.isFunction(callback))) {
callback = function (a, b) {
return (true);
}
}
$p = $(objStr);
$p.attr("name", "");
$p.mouseover(function (e) {
if (callback(e, this)) {
if ($.browser.mozilla) {
var position = $(this).css("background-position");
top = position.split(" ")[1];
$(this).css("background-position", "-" + left + "px " + top);
} else {
if (top) {
$(this).css("background-position", "-" + left + "px " + top + "px");
}
$(this).css("background-position-x", "-" + left + "px");
}
}
}).mouseout(function (e) {
if (callback(e, this)) {
if ($.browser.mozilla) {
var position = $(this).css("background-position");
top = position.split(" ")[1];
$(this).css("background-position", "0px " + top);
} else {
if (top) {
$(this).css("background-position", "0px " + top + "px");
}
$(this).css("background-position-x", "0px");
}
}
}).mousedown(function (e) {
if (callback(e, this)) {
if ($.browser.mozilla) {
var position = $(this).css("background-position");
top = position.split(" ")[1];
$(this).css("background-position", "-" + left * 2 + "px " + top);
} else {
if (top) {
$(this).css("background-position", "-" + left * 2 + "px " + top + "px");
}
$(this).css("background-position-x", "-" + left * 2 + "px");
}
}
}).mouseup(function (e) {
if (callback(e, this)) {
if ($.browser.mozilla) {
var position = $(this).css("background-position");
top = position.split(" ")[1];
$(this).css("background-position", "-" + left + "px " + top);
} else {
if (top) {
$(this).css("background-position", "-" + left * 2 + "px " + top + "px");
}
$(this).css("background-position-x", "-" + left * 2 + "px");
}
}
})
};
this.Slider = function (sliderCov, sliderBtn, slider) {
var sizemax = $("#" + sliderCov).css("width").split("px")[0] - 1;
var down = false;
var percent = 0;
$("#" + sliderCov).attr("speed", 0);
var left = $("#" + sliderCov).offset().left; //元素相当于窗口的左边的偏移量
$("#" + sliderBtn + ",#" + sliderCov).mouseover(function () {
left = $("#" + sliderCov).offset().left - $(document).scrollLeft();
});
$("#" + sliderCov).mousedown(function (e) {
down = true;
$("#" + sliderBtn).css("margin-left", e.clientX - left);
var offset = $("#" + sliderBtn).css("margin-left").split("px")[0];
$("#" + slider).css("width", offset + "px");
$("#" + sliderCov).attr("speed", (offset / sizemax * 100));
}).mouseup(function () {});
$("#" + sliderBtn).mousedown(function (e) {
down = true;
}).mouseup(function (e) {
down = false;
});
$(document).mousemove(function (e) {
if (down) {
if (e.clientX - left > 0 && e.clientX - left < sizemax) {
$("#" + sliderBtn).css("margin-left", e.clientX - left);
} else if (e.clientX - left <= 0) {
$("#" + sliderBtn).css("margin-left", 0);
} else {
$("#" + sliderBtn).css("margin-left", sizemax);
}
var offset = $("#" + sliderBtn).css("margin-left").split("px")[0];
$("#" + slider).css("width", offset + "px");
$("#" + sliderCov).attr("speed", offset / sizemax * 100);
//如果值为0或100,都让按钮调用mouseup事件
if (e.clientX - left < -20 || e.clientX - left > sizemax)
$("#" + sliderBtn).mouseup();
}
}).mouseup(function (e) {
if (down) {
down = false;
}
});
$(function () {
$("#" + slider).css("width", "50%");
$("#" + sliderBtn).css("margin-left", 67);
$("#" + sliderBtn).css("margin-right", 40);
$("#" + sliderCov).attr("speed", 50);
})
}
////////////////////////////4/////////////////////
this.SliderCam = function (slider, sliderCovCam, sliderBtnCam, sliderCam, sliderValue, saveFunc) {
var sizemax = $("#" + sliderCovCam).css("width").split("px")[0] - 10;
var down = false;
var precent = (sliderValue / 100) * 130;
$("#" + sliderCovCam).attr("speed", 0);
var left = $("#" + sliderCovCam).offset().left; //元素相当于窗口的左边的偏移量
$("#" + sliderBtnCam + ",#" + sliderCovCam).mouseover(function () {
left = $("#" + sliderCovCam).offset().left - $(document).scrollLeft();
});
$("#" + sliderCovCam).mousedown(function (e) {
down = true;
$("#" + sliderBtnCam).css("margin-left", e.clientX - left);
var offset = $("#" + sliderBtnCam).css("margin-left").split("px")[0];
$("#" + sliderCam).css("width", offset + "px");
$("#" + sliderCovCam).attr("speed", (offset / sizemax * 100));
}).mouseup(function () {
setTimeout(function () {
saveFunc();
}, 100);
});
$("#" + sliderBtnCam).mousedown(function (e) {
down = true;
}).mouseup(function (e) {
down = false;
setTimeout(function () {
saveFunc();
}, 100);
});
$(document).mousemove(function (e) {
if (down) {
if (e.clientX - left > 0 && e.clientX - left < sizemax) {
$("#" + sliderBtnCam).css("margin-left", e.clientX - left);
percent = e.clientX - left;
} else if (e.clientX - left <= 0) {
$("#" + sliderBtnCam).css("margin-left", 0);
} else {
$("#" + sliderBtnCam).css("margin-left", sizemax);
}
var offset = $("#" + sliderBtnCam).css("margin-left").split("px")[0];
$("#" + sliderCam).css("width", offset + "px");
$("#" + sliderCovCam).attr("speed", offset / sizemax * 100);
//如果值为0或100,都让按钮调用mouseup事件
delay = ($("#" + sliderCam).css("width").split("px")[0] / 13 * 10) * 1;
if (delay > 100) {
delay = 100;
} else if (delay < 1) {
delay = 1;
}
$("#" + slider).val(Math.round(delay));
if (e.clientX - left < -20 || e.clientX - left > sizemax + 20)
$("#" + sliderBtnCam).mouseup();
}
}).mouseup(function (e) {
if (down) {
down = false;
}
delay = ($("#" + sliderCam).css("width").split("px")[0] / 13 * 10) * 1;
if (delay > 100) {
delay = 100;
} else if (delay < 1) {
delay = 1;
}
$("#" + slider).val(Math.round(delay));
});
$(function () {
$("#" + sliderCam).css("width", precent + "px");
$("#" + sliderBtnCam).css("margin-left", precent);
$("#" + sliderCovCam).attr("speed", 0);
})
};
this.Select = function () {}
this.Input = function () {}
}
//设备信息类
function DvrInfo() {
this.obj = document.getElementById("dvrocx"); //控件对象
//设备属性
this.nChannel = 0;
this.nAlarmIn = 0;
this.nAlarmOut = 0;
this.DevType = 0;
Init(this); //初始化
function Init(p) {
//初始化设备方法
if (g_bIsIE) {
p.SetActiveXType = function (type) {
return p.obj.SetActiveXType(type)
};
p.SetLanaguageResource = function (xml) {
p.obj.SetLanaguageResource(xml)
};
p.DeviceLogin = function (ip, port, username, password) {
p.obj.DeviceLogin(ip, port, username, password)
};
p.DeviceLogout = function () {
p.obj.DeviceLogout()
};
p.RealtimeViewInitialize = function () {
p.obj.RealtimeViewInitialize();
};
p.GetConnectedDeviceList = function () {
return p.obj.GetConnectedDeviceList()
};
p.GetDvrInfo = function () {
$.ajax({
url: 'http://' + gVar.ip + ':' + gVar.port + "/System/DeviceInfo",
type: "GET",
async: false,
timeout: 15000,
datatype: "xml",
beforeSend: function (xhr) {
xhr.setRequestHeader("If-Modified-Since", "0");
},
success: function (xmlDoc, textStatus, xhr) {
gDvr.AnalyLogRes(xmlDoc);
}
})
};
p.PlayVideo = function (channel, streamType) {
return p.obj.PlayVideo(channel, streamType)
};
p.StopVideo = function (channel) {
return p.obj.StopVideo(channel)
};
p.AudioControl = function (chn, st) {
return p.obj.AudioControl(chn, st)
};
p.FullScreen = function () {
return p.obj.FullScreen()
};
p.OpenElectronicZoomout = function () {
return p.obj.OpenElectronicZoomout(-1)
};
p.CloseElectronicZoomout = function () {
return p.obj.CloseElectronicZoomout(-1)
};
p.ChangeLayout = function (NewLayout) {
return p.obj.ChangeLayout(NewLayout)
};
p.StartVoiceStream = function () {
return p.obj.StartVoiceStream(-1)
};
p.StopVoiceStream = function () {
return p.obj.StopVoiceStream(-1)
};
p.GetAndSetVideoInfo = function (xml, chn) {
$.ajax({
type: "PUT",
url: 'http://' + gVar.ip + ':' + gVar.port + "/Images/" + chn + "/Color",
processData: false,
data: xml,
beforeSend: function (xhr) {
xhr.setRequestHeader("If-Modified-Since", "0");
},
success: function (xhr, textStatus) {
}
});
};
p.OpenAllChannels = function (type) {
return p.obj.OpenAllChannels(type)
};
p.CloseAllChannels = function () {
return (p.obj.CloseAllChannels())
};
p.PTZcontrol = function (param, cmd, speed) {
var cyXmlstart = "Param1=" + param + "&Param2=" + speed;
var cyURL = 'http://' + gVar.ip + ':' + gVar.port + "/PTZ/" + ptzSelChn + "/" + cmd;
$.ajax({
type: "PUT",
url: cyURL,
processData: false,
data: cyXmlstart,
beforeSend: function (xhr) {
xhr.setRequestHeader("If-Modified-Since", "0");
},
complete: function (xhr, textStatus) {}
});
};
p.PTZadjust = function (param, cmd) {
var cyXmlstart = "Param1=" + param;
var cyURL = 'http://' + gVar.ip + ':' + gVar.port + "/PTZ/" + ptzSelChn + "/Cruise/" + cmd;
$.ajax({
type: "PUT",
url: cyURL,
processData: false,
data: cyXmlstart,
beforeSend: function (xhr) {
xhr.setRequestHeader("If-Modified-Since", "0");
},
complete: function (xhr, textStatus) {}
});
};
p.StartRecord = function (channel) {
return p.obj.StartRecord(channel)
};
p.StopRecord = function (chanel) {
return p.obj.StopRecord(chanel)
};
p.CaptureImage = function (channel) {
return p.obj.CaptureImage(channel)
};
p.OpenLocalFile = function () {
return p.obj.GetUpgradeFilePath()
};
p.AspectRatioControl = function (ratio, chn) {
return (p.obj.AspectRatioControl(ratio, chn))
};
p.Zoom = function (chid) {
return (p.obj.Zoom(chid))
};
p.PTZset = function (param, cmd, speed) {
var cyXmlstart = "Param1=" + param + "&Param2=" + speed;
var cyURL = 'http://' + gVar.ip + ':' + gVar.port + "/PTZ/" + ptzSelChn + "/" + cmd;
$.ajax({
type: "PUT",
url: cyURL,
processData: false,
data: cyXmlstart,
beforeSend: function (xhr) {
xhr.setRequestHeader("If-Modified-Since", "0");
},
complete: function (xhr, textStatus) {}
});
};
p.PTZPresetSet = function (pos) {
var cyXmlstart = "Param1=" + pos;
var cyURL = 'http://' + gVar.ip + ':' + gVar.port + "/PTZ/" + ptzSelChn + "/Presets/Set";
$.ajax({
type: "PUT",
url: cyURL,
processData: false,
data: cyXmlstart,
beforeSend: function (xhr) {
xhr.setRequestHeader("If-Modified-Since", "0");
},
complete: function (xhr, textStatus) {
}
});
};
p.PTZPresetCall = function (pos) {
var cyXmlstart = "Param1=" + pos;
var cyURL = 'http://' + gVar.ip + ':' + gVar.port + "/PTZ/" + ptzSelChn + "/Presets/Goto";
$.ajax({
type: "PUT",
url: cyURL,
processData: false,
data: cyXmlstart,
beforeSend: function (xhr) {
xhr.setRequestHeader("If-Modified-Since", "0");
},
complete: function (xhr, textStatus) {
}
});
};
p.StartRemotePlayback = function (req) {
return p.obj.StartRemotePlayback(req)
};
p.RemotePlaybackSuspend = function (num, ch) {
p.obj.RemotePlaybackSuspend(num, ch)
};
p.StopRemotePlayback = function () {
return p.obj.StopRemotePlayback()
};
p.PlayByFrameRemotePlayback = function () {};
p.CaptureImageRemotePlayback = function (ch) {
return p.obj.CaptureImageRemotePlayback(ch)
};
p.PlaySoundRemotePlayback = function (Is, ch) {
return p.obj.PlaySoundRemotePlayback(Is, ch)
};
p.RemotePlaybackSetVolume = function (Is, ch) {
return p.obj.RemotePlaybackSetVolume(Is, ch)
};
p.RemotePlaybackSetPos = function () {};
p.GetDrawRegions = function (chn) {
return p.obj.GetDrawRegions(chn)
};
p.SetDisplayRegionsEnable = function (chn, en) {
p.obj.SetDisplayRegionsEnable(chn, en)
};
p.AddDrawRegion = function (ch, left, top, right, bottom) {
p.obj.AddDrawRegion(ch, left, top, right, bottom)
};
p.ClearDrawRegions = function (ch) {
p.obj.ClearDrawRegions(ch)
};
p.GetLocalVolumeList = function () {
return p.obj.GetLocalVolumeList();
};
p.SetLocalSettings = function (xml) {
return p.obj.SetLocalSettings(xml);
};
p.GetLocalSettings = function () {
return p.obj.GetLocalSettings();
};
p.PreviewSpecificChannelInFirstWindow = function (chn, type) {
return p.obj.PreviewSpecificChannelInFirstWindow(chn, type);
};
p.StartDrawRegion = function (ch) {
p.obj.StartDrawRegion(ch)
};
p.StopDrawRegion = function (ch) {
p.obj.StopDrawRegion(ch)
};
p.SetPenColor = function (ch, cl) {
p.obj.SetPenColor(ch, cl);
};
p.SetBrushColor = function (ch, cl) {
p.obj.SetBrushColor(ch, cl)
};
p.FormatDisk = function (id) {
return p.obj.FormatDisk(id);
};
p.PreviewImageCapture = function (ch) {
p.obj.PreviewImageCapture(ch)
};
p.HistroyViewInitialize = function () {
return p.obj.HistroyViewInitialize()
};
p.HistroyViewUninitialize = function () {
return p.obj.HistroyViewUninitialize()
};
p.GetUpgradeStatus = function () {
return p.obj.GetUpgradeStatus()
};
p.StartHistroyStreamDownload = function (xml) {
return p.obj.StartHistroyStreamDownload(xml)
};
p.StopHistroyStreamDownload = function (ch) {
return p.obj.StopHistroyStreamDownload(ch)
};
p.GetRemoteDownloadPercent = function (ch) {
return p.obj.GetRemoteDownloadPercent(ch)
};
p.SetSpeedRemotePlayback = function (sp, ch) {
return p.obj.SetSpeedRemotePlayback(sp, ch)
};
p.PlayByFrameRemotePlayback = function (ch, rn) {
return p.obj.PlayByFrameRemotePlayback(ch, rn)
};
p.MovingMoniterControl = function (ch, bool) {
return p.obj.MovingMoniterControl(ch, bool, 16, 12)
};
p.QueryMovingMoniterArea = function (ch) {
return p.obj.QueryMovingMoniterArea(ch)
};
p.SetMovingMoniterArea = function (ch, xml) {
return p.obj.SetMovingMoniterArea(ch, xml)
};
p.SetChannelShowText = function (ch, text) {
return p.obj.SetChannelShowText(ch, text)
};
p.RemotePlaybackSetPos = function (ch, pos) {
return p.obj.RemotePlaybackSetPos(ch, pos)
};
p.DisplayOsdControl = function (bool, ch, xml) {
return p.obj.DisplayOsdControl(bool, ch, xml)
};
p.GetDisplayOsdPosition = function (ch) {
return p.obj.GetDisplayOsdPosition(ch)
};
p.IEIsRunInProtectedMode = function () {
return p.obj.IEIsRunInProtectedMode()
};
p.JumpToFile = function (ch, type, action) {
p.obj.JumpToFile(ch, type, action)
};
p.FolderPickerDialog = function () {
return p.obj.FolderPickerDialog()
}
} else {
p.SetActiveXType = function (type) {};
p.GetDvrInfo = function () {
$.ajax({
url: 'http://' + gVar.ip + ':' + gVar.port + "/System/DeviceInfo",
type: "GET",
async: false,
timeout: 15000,
datatype: "xml",
beforeSend: function (xhr) {
xhr.setRequestHeader("If-Modified-Since", "0");
},
success: function (xmlDoc, textStatus, xhr) {
gDvr.AnalyLogRes(xmlDoc);
}
})
};
p.DeviceLogin = function (ip, port, username, password) {};
p.PlayVideo = function (channel, streamType) {};
p.StopVideo = function (channel) {};
p.GetAndSetVideoInfo = function (xml, chn) {
$.ajax({
type: "PUT",
url: 'http://' + gVar.ip + ':' + gVar.port + "/Images/" + chn + "/Color",
processData: false,
data: xml,
beforeSend: function (xhr) {
xhr.setRequestHeader("If-Modified-Since", "0");
},
complete: function (xhr, textStatus) {
}
});
};
p.OpenAllChannels = function (type) {};
p.CloseAllChannels = function () {};
p.FullScreen = function () {};
p.OpenElectronicZoomout = function () {};
p.CloseElectronicZoomout = function () {};
p.AudioControl = function (chn, st) {};
p.StartVoiceStream = function () {};
p.GetVolume = function () {
p.obj.GetVolume()
};
p.PTZcontrol = function (param, cmd, speed) {
var cyXmlstart = "Param1=" + param + "&Param2=" + speed;
var cyURL = 'http://' + gVar.ip + ':' + gVar.port + "/PTZ/" + ptzSelChn + "/" + cmd;
$.ajax({
type: "PUT",
url: cyURL,
processData: false,
data: cyXmlstart,
beforeSend: function (xhr) {
xhr.setRequestHeader("If-Modified-Since", "0");
},
complete: function (xhr, textStatus) {}
});
};
p.PTZadjust = function (param, cmd) {
var cyXmlstart = "Param1=" + param;
var cyURL = 'http://' + gVar.ip + ':' + gVar.port + "/PTZ/" + ptzSelChn + "/Cruise/" + cmd;
$.ajax({
type: "PUT",
url: cyURL,
processData: false,
data: cyXmlstart,
beforeSend: function (xhr) {
xhr.setRequestHeader("If-Modified-Since", "0");
},
complete: function (xhr, textStatus) {}
});
};
p.PTZset = function (param, cmd, speed) {
var cyXmlstart = "Param1=" + param + "&Param2=" + speed;
var cyURL = 'http://' + gVar.ip + ':' + gVar.port + "/PTZ/" + ptzSelChn + "/" + cmd;
$.ajax({
type: "PUT",
url: cyURL,
processData: false,
data: cyXmlstart,
beforeSend: function (xhr) {
xhr.setRequestHeader("If-Modified-Since", "0");
},
complete: function (xhr, textStatus) {}
});
};
p.PTZPresetSet = function (pos) {
var cyXmlstart = "Param1=" + pos;
var cyURL = 'http://' + gVar.ip + ':' + gVar.port + "/PTZ/" + ptzSelChn + "/Presets/Set";
$.ajax({
type: "PUT",
url: cyURL,
processData: false,
data: cyXmlstart,
beforeSend: function (xhr) {
xhr.setRequestHeader("If-Modified-Since", "0");
},
complete: function (xhr, textStatus) {
}
});
};
p.PTZPresetCall = function (pos) {
var cyXmlstart = "Param1=" + pos;
var cyURL = 'http://' + gVar.ip + ':' + gVar.port + "/PTZ/" + ptzSelChn + "/Presets/Goto";
$.ajax({
type: "PUT",
url: cyURL,
processData: false,
data: cyXmlstart,
beforeSend: function (xhr) {
xhr.setRequestHeader("If-Modified-Since", "0");
},
complete: function (xhr, textStatus) {
}
});
};
p.OpenLocalFile = function (i) {
if (i >= 1 && i <= 3) {
return p.obj.OpenFileDialog(0, "");
} else if (i == 0) {
return p.obj.OpenFileDialog(1, "sw");
}
};
p.SetDisplayRegionsEnable = function (chn, en) {};
p.MovingMoniterControl = function (ch, bool) {};
p.StopDrawRegion = function (ch) {};
p.ClearDrawRegions = function (ch) {};
p.StartDrawRegion = function (ch) {};
p.SetBrushColor = function (ch, cl) {};
p.ChangeLayout = function (NewLayout) {};
p.PreViewRec = function (n) {
return (p.obj.StartRecord(n * 1))
};
p.PlayStart = function () {
p.obj.PlayStart();
};
p.PlayStop = function () {
p.obj.PlayStop();
};
p.AspectRatioControl = function (ratio, chn) {};
p.openSafariByUrl = function (url) {
return (p.obj.openSafariByUrl(url))
};
p.Zoom = function (chid) {
return (p.obj.Zoom(chid))
};
p.QueryMovingMoniterArea = function (ch) {};
p.SetMovingMoniterArea = function (ch, xml) {};
p.PreviewSpecificChannelInFirstWindow = function (chn, type) {};
p.DisplayOsdControl = function (bool, ch, xml) {};
p.GetDisplayOsdPosition = function (ch) {}
}
}
//类方法
this.AnalyLogRes = function (xml) {
if (xml != null) {
this.nChannel = $(xml).find("VideoInputChannels").text() * 1; //获取设备通道数
this.nAlarmIn = $(xml).find("AlarmInputChannels").text() * 1; //获取报警输入数
this.nAlarmOut = $(xml).find("AlarmOutputChannels").text() * 1; //获取报警输出数
this.nTalkBack = $(xml).find("TwoWayAudio").text(); //是否支持语音对讲
this.chname = new Array();
for (var i = 0; i < this.nChannel; i++) {
if (i < 9) {
this.chname[i] = lg.get("IDS_CH") + "0" + (i + 1);
} else {
this.chname[i] = lg.get("IDS_CH") + (i + 1);
}
}
}
};
this.Sp_Mv = function (Sp_Mv_Obj, offsetObj) {
//初始化设备方法
if (g_bIsIE) {
var $p = $(Sp_Mv_Obj);
var $b = $(offsetObj);
$(gDvr.obj).css({
"left": ($p.offset().left - $b.offset().left + 1),
"top": ($p.offset().top - $b.offset().top + 1),
"width": $p.css("width"),
"height": $p.css("height")
});
} else {
if (Sp_Mv_Obj != "#MotionSP") {
$(gDvr.obj).hide();
$(Sp_Mv_Obj).hide();
}
}
};
this.HideObj = function () {
$(gDvr.obj).css({
"width": 0,
"height": 0
});
};
this.Live_Playback = function (type) {
if (type == 1) {
$(gDvr.obj).css({
"left": 0,
"top": 0
});
$(gDvr.obj).css({
"width": "100%",
"height": "85%"
});
$("#playback_ctl").show();
var canvas = document.getElementById("timebar");
if (canvas.getContext) { //判断浏览器是否支持canvas获取上下文
m_szStartTimeSet.length = 0;
tTimeBar = new TimeBar(canvas, $("#playbackbar").width(), 60);
} else {
$("#timebar").html('');
}
} else {
$(gDvr.obj).css({
"left": 0,
"top": 0
});
$(gDvr.obj).css({
"width": "100%",
"height": "100%"
});
$("#playback_ctl").hide();
}
}
}
//全局变量类
function GlobarVar() {
this.nDate = new Date().Format("yyyy-MM-dd hh:mm:ss");
this.nStreamType = 0;
this.ip = "";
this.port = 80;
this.nport = 6060;
this.mediaport = "";
this.user = "admin";
this.passwd = "";
this.nOpenPrivew = false;
this.lg = 0;
this.nTimer = 0;
this.errTitle = "";
this.errCount = 0;
this.nDevType = 0;
this.ipc = 0;
this.nVideoRatio = 1.383;
this.nLRWidth = 452;
this.sPage = "live";
this.MacPlayReg = false;
this.nWeekStart = 0; //"0"代表从星期天开始,"1"代表从星期一开始,后面依次类推。。。
this.nVideoSize = 0;
//类方法
this.ChangPage;
init(this);
function init(p) { //构造函数
//初始化设备方法
if (g_bIsIE) {
p.ChangPage = function (page) {
var xml = "111001502000abc";
if (gVar.sPage === "live" && page !== "live") {
gDvr.CloseAllChannels();
}
if ("live" === page) {
if (p.sPage === "playback") {
if (playFlag) {
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");
m_bIsPlaying = false;
m_iWndSpeed = 1;
m_bSound = false;
m_bWndFrame = false;
playFlag = false;
}
gDvr.HistroyViewUninitialize();
}
if (privacyFlag || detectFlag) {
gDvr.SetDisplayRegionsEnable(0, false);
gDvr.StopDrawRegion(0);
privacyFlag = false;
detectFlag = false;
}
if (osdFlag) {
gDvr.DisplayOsdControl(0, osdChannel, xml);
osdFlag = false;
}
if (motionFlag) {
gDvr.MovingMoniterControl(0, 0, 16, 12);
motionFlag = false;
}
if (gVar.sPage === "config") {
gDvr.StopVideo(0);
}
if (gVar.sPage === page) {
return false;
}
p.sPage = page;
menutitle(1);
gDvr.ChangeLayout(selChannel);
gDvr.SetActiveXType(0);
$(".mcrcmain").show();
$("#logPage").hide();
$("#configPage").hide();
$(".mcright").css("width", "244px");
$("#playback_right").hide();
$("#pathConfigPage").hide();
$(".mcmcmain").css("right", "244px").css("height", "auto");
$(".mcmbottom").show();
$("#liveleft").show();
$("#playbackleft").hide();
$("#logleft").hide();
$("#configleft").hide();
gDvr.Live_Playback(0);
for (var i = 0; i < channelPlay.length; i++) {
if (channelPlay[i] == 1) {
gDvr.PlayVideo(i, gVar.nStreamType);
getOSDName(i);
$("#liveChn_Play_" + (i + 1)).css("background-position", "-31px 0px").attr("name", "active");
$("#liveChn_Rec_" + (i + 1)).css("background-position", "0px -25px");
$(".liveBtnBt2").css("background-position", "0px -31px");
}
}
if (audioControl) {
gDvr.AudioControl(-1, 1);
$(".liveBtnBt9").css("background-position", "0px 0px").attr("name", "active");
}
} else if ("playback" === page) {
if (gVar.sPage === page) {
return false;
}
if (osdFlag) {
gDvr.DisplayOsdControl(0, osdChannel, xml);
osdFlag = false;
}
if (gVar.sPage === "config") {
gDvr.StopVideo(0);
}
p.sPage = page;
menutitle(2);
lan("playback");
playbackCalendar();
if (motionFlag) {
gDvr.MovingMoniterControl(0, 0, 16, 12);
motionFlag = false;
}
$(".mcrcmain").hide();
$("#logPage").hide();
$("#configPage").hide();
$(".mcright").css("width", "280px");
$("#playback_right").show();
$("#pathConfigPage").hide();
$(".mcmcmain").css("right", "280px").css("height", "100%");
$(".mcmbottom").hide();
gDvr.Live_Playback(1);
gDvr.HistroyViewInitialize();
$("#liveleft").hide();
$("#playbackleft").show();
$("#logleft").hide();
$("#configleft").hide();
} else if ("log" === page) {
if (p.sPage === "playback") {
if (playFlag) {
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");
m_bIsPlaying = false;
m_iWndSpeed = 1;
m_bSound = false;
m_bWndFrame = false;
}
gDvr.HistroyViewUninitialize();
}
if (osdFlag) {
gDvr.DisplayOsdControl(0, osdChannel, xml);
osdFlag = false;
}
if (gVar.sPage === page) {
return false;
}
p.sPage = page;
menutitle(3);
LoadLogPage();
$("#configPage").hide();
$(".mcrcmain").hide();
$("#logPage").show();
$(".logmiddle").height($(".contentleft").height() - 60);
$("#playback_right").hide();
$(".mcmcmain").css("height", "0px");
$(".mcmbottom").hide();
gDvr.Live_Playback(0);
$("#liveleft").hide();
$("#playbackleft").hide();
$("#logleft").show();
$("#configleft").hide();
$.getScript("js/log.js", null);
} else if ("config" === page) {
if (ipChannel == "0") {
$("#IPCan_set").hide();
$("#Img_Ctrl").hide();
}
if (p.sPage === "playback") {
if (playFlag) {
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");
m_bIsPlaying = false;
m_iWndSpeed = 1;
m_bSound = false;
m_bWndFrame = false;
playFlag = false;
}
gDvr.HistroyViewUninitialize();
}
if (gDvr.nAlarmIn == 0) {
$("#alarm_input").hide();
$("#alarm_output").hide();
}
if (gVar.sPage == page) {
return false;
}
if(deviceCap && deviceCap.LionKingEnable){
$("#ams_center").show();
}
p.sPage = page;
menutitle(4);
gDvr.ChangeLayout(1);
$("#liveleft").hide();
$("#playbackleft").hide();
$("#logleft").hide();
$("#configleft").show();
if ($(this).attr("name") != "isDown") {
jQuery("head").append('');
$(this).attr("name", "isDown");
$.getScript("js/divBox.js", null);
}
$(".selectedb").removeClass("selectedb");
if (ipChannel == "0") {
$("#chn_osd").addClass("selectedb");
showConfigChild("chn_osd");
} else {
$("#IPCan_set").addClass("selectedb");
showConfigChild("IPCan_set");
}
gDvr.Live_Playback(0);
$("#pathConfigPage").hide();
$(".mcrcmain").hide();
$("#logPage").hide();
$("#configPage").show();
$("#playback_right").hide();
$(".mcmcmain").css("height", "0px");
$(".mcmbottom").hide();
} else if ("configPage" === page) {
if (p.sPage === "playback") {
if (playFlag) {
gDvr.StopRemotePlayback();
gDvr.MovingMoniterControl(0, 0, 16, 12);
$("#playdisable").removeClass().addClass("playdisable").attr("title", "");
$("#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");
m_bIsPlaying = false;
m_iWndSpeed = 1;
m_bSound = false;
m_bWndFrame = false;
playFlag = false;
}
gDvr.HistroyViewUninitialize();
}
if (gVar.sPage === page) {
return false;
}
if (osdFlag) {
gDvr.DisplayOsdControl(0, osdChannel, xml);
osdFlag = false;
}
p.sPage = page;
menutitle(5);
gDvr.Live_Playback(0);
$("#liveleft").hide();
$("#playbackleft").hide();
$("#logleft").hide();
$("#configleft").hide();
$("#configPage").css("display", "none");
$(".mcrcmain").css("display", "none");
$("#pathConfigPage").css("display", "block");
$("#logPage").css("display", "none");
$("#playback_right").css("display", "none");
$(".mcmcmain").css("height", "0px");
$(".mcmbottom").css("display", "none");
//加载PathConfig
if ($("#pathConfigPage").attr("name") != "isDown") {
$.get("html/pathConfig.html?" + gVar.nDate, "", function (data) {
$("#pathConfigPage").prop("innerHTML", data).attr("name", "isDown");
$.getScript("js/pathConfig.js", null);
lan("pathConfig");
}, "html");
}
}
}
} else {
p.ChangPage = function (page) {
if ("live" == page) {
if (gVar.sPage == page)
return false;
gVar.sPage = page;
menutitle(1);
$("#configPage").css("display", "none");
$("#logPage").css("display", "none");
$("#pathConfigPage").css("display", "none");
$(".mcright").css("width", "244px");
$(".mcmcmain").css("right", "244px").css("height", "auto");
/*height-IE6兼容*/
$(".mcmbottom").css("display", "");
$("#playback_slider").css("display", "none");
$("#live_right").css("display", "block");
$("#IEmcmbottom").css("display", "");
$(".mcrborder").css("display", "block");
$("#playback_slider").css("display", "none");
gDvr.Live_Playback(0);
$("#left").animate({
marginLeft: "0px"
}, 200).focus();
} else if ("playback" == page) {
if (gVar.sPage == page)
return false;
p.sPage = page;
menutitle(2);
$("#configPage").css("display", "none");
$("#logPage").css("display", "none");
$(".mcright").css("width", "18px");
$("#playback_right").css("display", "block");
$(".mcmcmain").css("right", "18px").css("height", "100%");
/*height-IE6兼容*/
$(".mcmbottom").css("display", "none"); //show right border//2011.10.10
$(".mcrborder").css("display", "block");
$("#pathConfigPage").css("display", "none");
gDvr.Live_Playback(1);
$("#left").animate({
marginLeft: "-226px"
}, 200);
} else if ("log" == page) {
if (gVar.sPage == page)
return false;
p.sPage = page;
menutitle(3);
LoadLogPage();
$("#configPage").css("display", "none");
$("#logPage").css("display", "block");
$(".logmiddle").height($(".contentleft").height() - 60);
$(".mcright").css("width", "18px");
$("#playback_right").css("display", "none");
$(".mcmcmain").css("height", "0px");
/*height-IE6兼容*/
$(".mcmbottom").css("display", "none");
$(".leftCenter").css("display", "block");
gDvr.Live_Playback(0);
$("#liveleft").hide();
$("#playbackleft").hide();
$("#logleft").show();
$("#configleft").hide();
$.getScript("js/log.js", null);
} else if ("config" == page) {
if (gVar.sPage == page)
return false;
p.sPage = page;
menutitle(4);
$("#liveleft").hide();
$("#playbackleft").hide();
$("#logleft").hide();
$("#configleft").show();
if ($(this).attr("name") != "isDown") {
jQuery("head").append('');
$(this).attr("name", "isDown");
$.getScript("js/divBox.js", null);
}
if (gDvr.nAlarmIn == 0) {
$("#alarm_input").hide();
$("#alarm_output").hide();
}
if (ipChannel == "0") {
showConfigChild("chn_osd");
} else {
showConfigChild("IPCan_set");
}
if(deviceCap && deviceCap.LionKingEnable){
$("#ams_center").show();
}
gDvr.Live_Playback(0);
$("#chn_sp").hide();
$("#pathConfigPage").css("display", "none");
$("#logPage").css("display", "none");
$("#configPage").css("display", "block");
$(".mcright").css("width", "18px");
$("#playback_right").css("display", "none");
$(".mcmcmain").css("height", "0px");
/*height-IE6兼容*/
$(".mcmbottom").css("display", "none");
$(".leftCenter").css("display", "block");
} else if ("configPage" == page) {
if (gVar.sPage == page)
return false;
p.sPage = page;
menutitle(5);
gDvr.Live_Playback(0);
$("#left").animate({
marginLeft: "-904px"
}, 200);
$("#configPage").css("display", "none");
$("#pathConfigPage").css("display", "block");
$("#logPage").css("display", "none");
$(".mcright").css("width", "18px");
$("#playback_right").css("display", "none");
$(".mcmcmain").css("height", "0px");
/*height-IE6兼容*/
$(".mcmbottom").css("display", "none");
$(".leftCenter").css("display", "none");
//加载PathConfig
if ($("#pathConfigPage").attr("name") != "isDown") {
$.get("html/pathConfig.html?" + gVar.nDate, "", function (data) {
$("#pathConfigPage").prop("innerHTML", data).attr("name", "isDown");
$.getScript("js/pathConfig.js", null);
lan("pathConfig");
}, "html");
}
}
}
}
}
this.XmlParsing = function (obj, xml, parent) {
var $p;
obj.refresh();
if ( /*$.browser.msie && gVar.lg!="KOR" && gVar.lg!="CHT"*/ 0) {
for (var i = 0; i < xml.length; i++) {
obj.set(xml[i].id, xml[i].value);
}
} else {
if ((typeof xml == 'string') && xml.constructor == String) {
xml = ("" + xml + "");
}
var safarilg = {};
if ($.browser.msie && $.browser.version.indexOf("10") == 0) { //IE10有bug
var child = xml.getElementsByTagName(parent)[0].ownerDocument.getElementsByTagName("string");
for (var i = 0; i < child.length; ++i) {
//obj.set(child[i].attributes.getNamedItem("id").text, child[i].text);
obj.set(child[i].attributes[0].nodeValue, child[i].textContent);
}
} else {
$(xml).find(parent).children().each(function () {
$p = $(this);
obj.set($p.attr("id"), $p.text());
safarilg[$p.attr("id")] = $p.text();
});
}
return obj;
}
};
this.Ajax = function (option) {
var opts = $.extend({
type: "POST",
url: "",
contentType: "text/xml",
processData: false,
datatype: "xml",
timeout: 10000,
async: false,
suc: null,
err: function (data, state) {}
}, option);
$.ajax({
type: opts.type,
url: opts.url,
contentType: opts.contentType,
processData: opts.processData,
datatype: opts.datatype,
timeout: opts.timeout,
async: opts.async,
success: function (data, state) {
if ($.isFunction(opts.suc)) {
opts.suc(data, state)
} else {
alert("Globar Ajax Error");
}
},
error: function (data, state) {
opts.err(data, state);
}
});
}
}
function LgClass() {
//多国语言
this.mul = new Array;
this.IpPortInfo = new Array;
this.DevID = new Array;
this.langues = "";
this.UIversion = 1;
//默认语言
this.defaultLg = "";
//版本
this.version = "";
this.logo = "";
this.debug = 0;
}