// Framework and action class
var version = "";
var g_device = null;
var pageNum = 0;
var volume=0;
var perIds = [];
var backup = [];
var backUpList=[];
var checkedNum = 0;
var _commonCount = 0;
var ua = navigator.userAgent;
var bs=[];
var getRstValue_CH1;
var getRstValue_CH2;
var getRstValue_CH3;
var getRstValue_CH4;
var getRstValue_CH5;
var getRstValue_CH6;
var getRstValue_CH7;
var getRstValue_CH8;
var getRstValue_CH9;
var getRstValue_CH10;
var getRstValue_CH11;
var getRstValue_CH12;
var getRstValue_CH13;
var getRstValue_CH14;
var getRstValue_CH15;
var getRstValue_CH16;
var getRstValue_ch = [];
var getSavedRstValue_ch = [];
var currUserRole = 1;
var curPwd = "";
var allCurUserInfo;
var videoArray;
var resolutionBitrate = [{"max":1024,"min":32}, {"max":1536,"min":32}, {"max":2048,"min":32}, {"max":512,"min":32}, {"max":512,"min":32}, {"max":2048,"min":32}, {"max":6000,"min":500}, {"max":6000,"min":500}, {"max":0,"min":0}, {"max":0,"min":0}, {"max":665,"min":32}, {"max":1331,"min":32},{"max":1996,"min":32}, {"max":2662,"min":32}];
var resolutionSubBitrate = [{"max":1024,"min":32}, {"max":1536,"min":32}, {"max":2048,"min":32}, {"max":512,"min":32}, {"max":512,"min":50}, {"max":1600,"min":150}, {"max":3072,"min":32}, {"max":6144,"min":32}, {"max":0,"min":0}, {"max":0,"min":0}, {"max":665,"min":32}, {"max":1331,"min":32},{"max":1996,"min":32}, {"max":2662,"min":32}];
var checkedRemote = [];
var digitalNum = 0;
getRemoteOnlineState();
function getHeight()
{
return $(window).height();
}
function getWidth()
{
return $(window).width();
}
var _width;
var _height;
function getWidthAndHeighta() {
document.getElementById("head-border").className = "head-border2";
if( rsp_getCookie("maxbol") == "true" )
{
_height = getHeight()-12;
_width = getWidth()-4;
//document.getElementById("head-border").style.border = "3px solid #353535";
//document.getElementById("head-border").style.borderBottom = "none";
//document.getElementById("content_body_border_playback").style.border = "3px solid #353535";
//document.getElementById("content_body_border_playback").style.borderTop = "none";
if( parseInt(((_width-216)*3)/4) <= (_height - 115))
{
_height = parseInt(((_width-216)*3)/4);
}
else
{
_width = parseInt(((_height - 115)*4/3)+216);
}
if( _height < 645 )
{
_height = 645;
}
if (_width < 1110) {
_width = 1110;
}
}
else
{
_height = getHeight()-12;
_width = getWidth() - 4;
//document.getElementById("head-border").style.border = "0px";
//document.getElementById("content_body_border_playback").style.border = "0px";
if( _height < 500)
{
_height = 500;
}
if(_width < 980 )
{
_width = 980;
}
}
}
//COOKIE
function rsp_getCookie( name ){
var arg = name + "=";
var cookie = document.cookie;
var index = cookie.indexOf(arg);
if( index >= 0 ) {
if( index > 0 )
{
var check = cookie.substr(index-1, 1);
if( check != " " && check != ";" && check != "&" )
{
index = cookie.indexOf(arg, index+2);
if( index < 0 )
{
return '';
}
}
}
var indexEnd = cookie.indexOf("&", index);
if( indexEnd < 0 ) {
indexEnd = cookie.indexOf(";", index);
if( indexEnd < 0 )
{
indexEnd = cookie.length;
}
}
var len = arg.length;
var value = cookie.substr(index + len, indexEnd - index - len);
var sepflag = value.indexOf(';');
if (sepflag>0) {
value = value.split(';')[0];
}
return value;
}
return '';
}
function rsp_setCookie( name, value )
{
var Days = 3650; //ten years
var exp = new Date();
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape(value) +";expires="+ exp.toGMTString();
}
function sleep(n) {
var start = new Date().getTime();
while (true) {
if (new Date().getTime() - start > n) {
break;
}
}
}
if( typeof(RM) == 'undefined' )
{
RM = {};
}
RM.frame = {
initPage: function() {getWidthAndHeighta();
document.getElementById("content_body_border_playback").style.height = (_height - 60) + "px";
document.getElementById("content_body_border_liveview").style.height = (_height - 60) + "px";
document.getElementById("content_body_border_configure").style.height = (_height - 60) + "px";
var gParamReq = '{"MODULE":"CONFIGMODEL","OPERATION":"GET","PARAMETER":{"NWSM":{"PORT":{"PORTLIST":["?","?"]}},"AVSM":{"VIP":[{"CRM":"?","LUM":"?","CONT":"?","SAT":"?"},{"CRM":"?","LUM":"?","CONT":"?","SAT":"?"},{"CRM":"?","LUM":"?","CONT":"?","SAT":"?"},{"CRM":"?","LUM":"?","CONT":"?","SAT":"?"}]},"SESSION":"98190dc2-0890-4ef8-ac9a-5940995e6119"}';
jQuery.getJSON('./getparameter.json'
, { REQ: gParamReq }
, function callback(data) {
var port = data.PARAMETER.NWSM.PORT.PORTLIST[1];
var host = location.host.split(":")[0];
var username = rsp_getCookie("uid");
var usersession = rsp_getCookie("session");
g_device = new device(host, port, RM.SYS.MAX_CHL_NUM, username, usersession);
}
);
},
loadPage: function(url) {
if (url.indexOf("liveView.rsp") >= 0) {
document.getElementById("content_body_border_playback").style.display = 'none';
document.getElementById("content_body_border_configure").style.display = 'none';
document.getElementById("content_body_border_liveview").style.display = '';
showLiveViewPage();
}
else if (url.indexOf("playback.rsp") >= 0) {
document.getElementById("content_body_border_liveview").style.display = 'none';
document.getElementById("content_body_border_configure").style.display = 'none';
document.getElementById("content_body_border_playback").style.display = '';
showPlaybackPage();
}
else {
document.getElementById("content_body_border_liveview").style.display = 'none';
document.getElementById("content_body_border_playback").style.display = 'none';
document.getElementById("content_body_border_configure").style.display = '';
showConfigurePage();
}
// $('#content_body_border').load(url);
},
changeUrl: function(url, level) {
var urls = document.URL.split("#");
if (urls.length < level) {
return;
}
urls[level] = url;
var newurl = urls.join("#");
window.location = newurl;
},
getDevice: function(ip, port) {
return g_device;
},
getpos :function(element) {
if (arguments.length != 1 || element == null) {
return null;
}
var elmt = element;
var offsetTop = elmt.offsetTop;
var offsetLeft = elmt.offsetLeft;
var offsetWidth = elmt.offsetWidth;
var offsetHeight = elmt.offsetHeight;
while (elmt = elmt.offsetParent) {
// add this judge
if (elmt.style.position == 'absolute'
|| (elmt.style.overflow != 'visible' && elmt.style.overflow != '')) {
break;
}
offsetTop += elmt.offsetTop;
offsetLeft += elmt.offsetLeft;
}
return { top: offsetTop, left: offsetLeft, right: offsetWidth + offsetLeft, bottom: offsetHeight + offsetTop };
}
}
RM.power = {
rview: parseInt(rsp_getCookie("rview")), //Preview
playback: parseInt(rsp_getCookie("playback")),//Playback
backup: parseInt(rsp_getCookie("backup")), //Backup
ptz: parseInt(rsp_getCookie("ptz")),
talk: ((parseInt(rsp_getCookie("opt")) >> 9) & 1),
log: ((parseInt(rsp_getCookie("opt")) >> 0) & 1), //Log
restart: ((parseInt(rsp_getCookie("opt")) >> 1) & 1),//Reboot
disk: ((parseInt(rsp_getCookie("opt")) >> 2) & 1),//Disk
maintain: ((parseInt(rsp_getCookie("opt")) >> 3) & 1), //Equipment maintenance
devopt: ((parseInt(rsp_getCookie("opt")) >> 4) & 1),//Equipment operation
systemset: ((parseInt(rsp_getCookie("opt")) >> 5) & 1),//System set
timeset: ((parseInt(rsp_getCookie("opt")) >> 6) & 1),//Time set
display: ((parseInt(rsp_getCookie("opt")) >> 7) & 1),//Display Set
recordset: ((parseInt(rsp_getCookie("opt")) >> 8) & 1),//Record Set
streamset: ((parseInt(rsp_getCookie("opt")) >> 10) & 1),//Stream Set
userset: ((parseInt(rsp_getCookie("opt")) >> 11) & 1),// User Set
alarmset: ((parseInt(rsp_getCookie("opt")) >> 12) & 1),//Alarm Set
networkset: ((parseInt(rsp_getCookie("opt")) >> 13) & 1),//Network Set
ptzset: ((parseInt(rsp_getCookie("opt")) >> 14) & 1), //YT Set
ptzcontor:((parseInt(rsp_getCookie("opt")) >> 15) & 1),//YT Control
remotedevice:((parseInt(rsp_getCookie("opt")) >> 16) & 1),//Remote device Set
C_role:parseInt(rsp_getCookie("Crole")),
role: parseInt(rsp_getCookie("role"))==1?2:parseInt(rsp_getCookie("role")),
forceChangePwd: parseInt(rsp_getCookie("forceChangePwd"))
}
RM.plug = {
m_plug: null,
getPlug: function() {
if (this.m_plug == null) {
this.m_plug = document.getElementById("dvrplug");
}
return this.m_plug;
},
loadLiveViewPlug: function(left, top, width, height) {
this.getPlug();
if (!this.m_plug) {
return;
}
document.getElementById("dvrplug").SwitchPage(0);
this.movePlug(left, top, width, height);
},
loadPlaybackPlug: function(left, top, width, height) {
this.getPlug();
if (!this.m_plug) {
return;
}
document.getElementById("dvrplug").SwitchPage(3);
this.movePlug(left, top, width, height);
// RM.frame.getDevice().stopPreviewAll();
},
disPlayViewPlug: function(left, top, width, height) {
this.getPlug();
if (!this.m_plug) {
return;
}
document.getElementById("dvrplug").SwitchPage(1);
this.movePlug(left, top, width, height);
// RM.frame.getDevice().stopPreviewAll();
},
movePlug: function(left, top, width, height) {
this.getPlug();
if (!this.m_plug) {
return;
}
if(!($.browser.msie) && version.indexOf("rv:11.0") <= 0){
document.getElementById("aa").style.width = width + "px";
document.getElementById("aa").style.height = height + "px";
document.getElementById("aa").style.left = left + "px";
document.getElementById("aa").style.top = top + "px";
}else{
document.getElementById("dvrplug").style.left = left + "px";
document.getElementById("dvrplug").style.top = top + "px";
document.getElementById("dvrplug").style.width = width + "px";
document.getElementById("dvrplug").style.height = height + "px";
}
},
hidePlug: function() {
this.getPlug();
if (document.getElementById("dvrplug")) {
document.getElementById("dvrplug").style.height = "0px";
document.getElementById("dvrplug").style.width = "0px";
if(!($.browser.msie) && version.indexOf("rv:11.0") <= 0){
document.getElementById("aa").style.height = "0px";
document.getElementById("aa").style.width = "0px";
}
while(RM.frame.getDevice() == null);
//RM.frame.getDevice().stopPreviewAll();
RM.frame.getDevice().stopPlayback();
}
}
}
function getRemoteOnlineState()
{
$.getJSON('./device.rsp?opt=getRemoteStreamState',callback_getRemoteOnline);
function callback_getRemoteOnline(data)
{
if(data.result == 0)
{
checkedRemote = data.data;
}
}
}
function getStreamType(initP,id1,id2,id3,videostandard ){
var cc=0;
var qicfCount = 0;
for(var i=0;i 25 )
{
tempValue = 25;
}
}
else
{
if( tempValue > 30 )
{
tempValue = 30;
}
}
switch (sub_c)
{
case 0:
case 11:
cc = cc + parseInt(tempValue);
break;
case 1:
case 12:
cc = cc + parseInt(tempValue * 2);
break;
case 2:
case 13:
cc = cc + parseInt(tempValue * 4);
break;
case 3:
case 10:
qicfCount += tempValue;
break;
case 6:
case 19:
cc = cc + parseInt(tempValue * 8);
break;
case 7:
cc = cc + parseInt(tempValue * 20);
break;
case 18:
cc = cc + parseInt(tempValue * 40);
break;
case 20:
cc = cc + parseInt(tempValue * 52);
break;
case 21:
cc = cc + parseInt(tempValue * 81);
break;
default:
break;
}
}
}
qicfCount =( (qicfCount%4)>0)?(parseInt((qicfCount/4))+1):parseInt((qicfCount/4));
return (cc + qicfCount);
}
function getCurrUserRole(){
jQuery.getJSON('./device.rsp?opt=user&cmd=list', getCurrUserRole_callback);
function getCurrUserRole_callback(userList){
if (userList.result == 0) {
if(userList.list.length > 0){
allCurUserInfo = userList.list;
for (var i = 0; i < userList.list.length; i++){
if(rsp_getCookie("uid") == userList.list[i].uid){
currUserRole = parseInt(userList.list[i].role);
curPwd = userList.list[i].pwd;
}
}
}
}
}
}
function IsHisRestoreParam(){
if(currUserRole == 2){
return true;
}
return false;
}
function GetVideoDevice(){
if(RM.SYS.product_type=='9204XH_VA'
|| RM.SYS.product_type=='9208XH_VA' || RM.SYS.product_type=='9208XC_VA'
|| RM.SYS.product_type=='9216XH_VA' || RM.SYS.product_type=='9216XD_VA'
|| RM.SYS.product_type=='9204XC_VA' || RM.SYS.product_type=='9204XD_VA'){
$.getJSON("./device.rsp?opt=deviceVideo",diviceVideoCallBack);
function diviceVideoCallBack(data){
if(data.result == 0){
videoArray = data.data;
}
}
}
}
function OriginalNum(){
if(RM.SYS.custName == "105"){
return {"width":16,"height":9};
}
return {"width":4,"height":3};;
}
function IsHisRSTChangeReboot(){
if(RM.SYS.product_type == "8616XH_VA" || RM.SYS.product_type == "8816XH_VA" || RM.SYS.product_type == "8632XH_VA" || RM.SYS.product_type == "8832XH_VA"){
return true;
}
return false;
}
function getDisabledChl(_ch, _box_arr,_input_arr){
var _remote;
regStr = '{"MODULE":"CONFIGMODEL","SESSION":"FROMIE","OPERATION":"GET","PARAMETER":{"DEVEMM":{"REDEV":"?"}}}';
$.ajax({ type: 'POST', url: './getparameter.json', data: {REQ: regStr}, dataType: "json", success: get_Redev_callback });
function get_Redev_callback(data){
_remote = data["PARAMETER"]["DEVEMM"]["REDEV"];
var _select = [];
if(_remote != undefined){
for(var _r=0;_r<_remote.length;_r++)
{
if(parseInt(_ch) == _r){
if(parseInt(_remote[_r].EN) == 0){
if(parseInt(_box_arr.length) != 0){
for(var i=0; i parseInt(resolutionBitrate[i].max))
{
document.getElementById(bitId).value = parseInt(resolutionBitrate[i].max);
}else{
if(bitValue < parseInt(resolutionBitrate[i].min)){
document.getElementById(bitId).value = parseInt(resolutionBitrate[i].min);
}else{
document.getElementById(bitId).value = bitValue;
}
}
}else{
if( bitValue > parseInt(resolutionSubBitrate[i].max))
{
document.getElementById(bitId).value = parseInt(resolutionSubBitrate[i].max);
}else{
if(bitValue < parseInt(resolutionSubBitrate[i].min)){
document.getElementById(bitId).value = parseInt(resolutionSubBitrate[i].min);
}else{
document.getElementById(bitId).value = bitValue;
}
}
}
}
}
}