|
Herman v.d. Watt
Joined: Thu Jun 23, 2005 11:26 am Posts: 4 Location: South Africa
|
<HTML>
<HEAD>
<TITLE></TITLE>
<META NAME="Author" CONTENT="ChenXiaohui">
<SCRIPT defer>
var aoCameraUrl = [
''];
var IpAddr=location.protocol+"//"+location.hostname;
var PortNumber=[location.port,0];
var MyPathName;
// Create a cookie with the specified name and value.
// The cookie expires at the end of the 20th century.
function SetCookie(sName, sValue)
{
date = new Date(2050,1,1);
document.cookie = sName + "=" + escape(sValue) + "; expires=" + date.toGMTString();
delete date;
}
// Retrieve the value of the cookie with the specified name.
function GetCookie(sName)
{
// cookies are separated by semicolons
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
// a name/value pair (a crumb) is separated by an equal sign
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0])
{
if (aCrumb.length > 1)
return unescape(aCrumb[1]);
else return "";
}
}
// a cookie with the requested name does not exist
return null;
}
// Delete the cookie with the specified name.
function DelCookie(sName)
{
document.cookie = sName + "=" + escape(sValue) + "; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}
var asNameList = new Array();
var asUrlList = new Array();
var asDespList = new Array();
function ReadCookie()
{
var sName, sUrl, sDescript;
var sPort = GetCookie("P");
var iPort = parseInt((location.port.length==0?"80":location.port), 10);
if (parseInt(sPort, 10) == iPort)
{
sName = GetCookie("N");
sUrl = GetCookie("U");
sDescript = GetCookie("D");
}
else
{
sName = null;
sUrl = null;
sDescript = null;
}
var iMax = 0;
var i, j;
if (sName)
{
sName = sName.split(",");
if (iMax < sName.length) iMax = sName.length;
}
if (sUrl)
{
sUrl = sUrl.split(",");
if (iMax < sUrl.length) iMax = sUrl.length;
}
if (sDescript)
{
sDescript = sDescript.split(",");
if (iMax < sDescript.length) iMax = sDescript.length;
}
for (j=0, i=0; j<20 && j<iMax; j++)
{
asNameList[i] = "";
if (sName)
{
if (i < sName.length)
asNameList[i] = unescape(sName[i]);
}
asUrlList[i] = "";
if (sUrl)
{
if (i < sUrl.length)
asUrlList[i] = unescape(sUrl[i]);
}
asDespList[i] = "";
if (sDescript)
{
if (i < sDescript.length)
asDespList[i] = unescape(sDescript[i]);
}
if (asNameList[i].length > 0 || asUrlList[i].length > 0 || asDespList.length > 0)
i++;
}
for (j=0; j<i; j++)
aoCameraUrl[j] = asUrlList[j];
if (j == 0) aoCameraUrl[j++] = location.protocol + "//" + location.host;
aoCameraUrl[j] = "";
}
function WriteCookieUrl()
{
var sName, sUrl, sDescript;
var i;
for (i=0, sName=""; i<asNameList.length; i++)
{
if (i!=0) sName += ",";
sName += escape(asNameList[i])
}
for (i=0, sUrl=""; i<asUrlList.length; i++)
{
if (i!=0) sUrl += ",";
sUrl += escape(asUrlList[i])
}
for (i=0, sDescript=""; i<asDespList.length; i++)
{
if (i!=0) sDescript += ",";
sDescript += escape(asDespList[i])
}
SetCookie("N", sName);
SetCookie("U", sUrl);
SetCookie("D", sDescript);
SetCookie("P", (location.port.lenght==0?"80":location.port));
}
function RecordUrl()
{
delete asNameList;
delete asNameList;
delete asNameList;
asNameList = new Array();
asUrlList = new Array();
asDespList = new Array();
for (var i=2; i<document.all.oCamCtl.length; i++)
{
asNameList[i-2] = "";
asUrlList[i-2] = document.all.oCamCtl[i].URL;
asDespList[i-2] = "";
}
WriteCookieUrl();
}
</SCRIPT>
<SCRIPT>
function CalcSqrt(iTotal)
{
var iN;
iN = Math.sqrt(iTotal);
if (Math.floor(iN) != iN) iN = Math.floor(iN) + 1;
return iN;
}
function GetCtlNumber()
{
return document.all.oCamCtl.length - 2;
}
function CalcCamWidth(iNTable)
{
var iShowWidth = document.body.clientWidth - document.body.leftMargin - document.body.rightMargin;
var iCtlTotalWidth = iShowWidth>200 ? iShowWidth : 200;
var iCtlWidth = Math.floor(iCtlTotalWidth / iNTable);
return iCtlWidth>100 ? iCtlWidth : 100;
}
function CalcCamHeight(iNTable)
{
var iShowHeigh = document.body.clientHeight - document.body.topMargin - document.body.bottomMargin;
var iCtlTotalHeight = iShowHeigh>200 ? iShowHeigh : 200;
var iCtlHeight = Math.floor(iCtlTotalHeight / iNTable);
return iCtlHeight>75 ? iCtlHeight : 75;
}
function IsExistUrl(sCameraUrl)
{
return false;
for (var i=2; i<document.all.oCamCtl.length; i++)
if (document.all.oCamCtl[i].URL == sCameraUrl)
return true;
return false;
}
function AddNewCtl(sCameraUrl, bFocus, bResize)
{
if (sCameraUrl.length <= 0)
return;
for (i=0; i<sCameraUrl.length; i++)
{
if (sCameraUrl.charAt(i) == '\''
|| sCameraUrl.charAt(i) == '\"'
|| sCameraUrl.charAt(i) == '\\')
{
alert('Invalid URL!');
return;
}
}
var iCamCtlLen = GetCtlNumber();
if (iCamCtlLen >= 9)
{
alert("Too many watch windows!\n");
return;
}
if (IsExistUrl(sCameraUrl))
{
alert("IP Kamera on " + sCameraUrl + "has been added watching.");
return;
}
document.all.oCamCtl[iCamCtlLen + 1].insertAdjacentHTML('afterEnd',
'<OBJECT onreadystatechange="if(this.readyState == 4) {this.URL=\''+sCameraUrl+'\';' + (bResize?'BodyResize();':'') + (bFocus?'SetFocusLastCtl();':'') + '}" style="{border: solid 1 white;}" ID=oCamCtl CODEBASE="WinWebPush.cab#version=1,0,1,5" CLASSID="CLSID:7876E4A5-78B7-4020-B08F-C960A1ED54C9" onfocus="SetFocusCtl(this);"></OBJECT>');
RecordUrl();
}
var oFocusCtl = null;
function DelExistCtl(oWhich)
{
if (oWhich == null) return;
oWhich.removeNode(true);
var iCamCtlLen = GetCtlNumber();
if (iCamCtlLen > 0) SetFocusCtl(document.all.oCamCtl[2]);
else
{
oFocusCtl = null;
top.rbottom.document.Add.AddUrl.value = '';
top.left.document.all.oPos.innerText = '';
RecordUrl();
return;
}
BodyResize();
RecordUrl();
}
function DeleteCurCtl()
{
if (oFocusCtl) DelExistCtl(oFocusCtl);
}
function SetFocusCtl(oWhich)
{
for (var i=2; i<document.all.oCamCtl.length; i++)
{
if (oWhich == document.all.oCamCtl[i])
document.all.oCamCtl[i].style.borderColor = "blue";
else
document.all.oCamCtl[i].style.borderColor = "white";
}
if (i == 2) return;
oFocusCtl = oWhich;
top.rbottom.document.Add.AddUrl.value = oWhich.URL;
top.left.SetFocusCtl(oFocusCtl);
}
function SetFocusLastCtl1()
{
var iLast = document.all.oCamCtl.length - 1;
if (iLast >=2 ) SetFocusCtl(document.all.oCamCtl[iLast]);
}
function SetFocusLastCtl()
{
setTimeout("SetFocusLastCtl1()", 0);
}
function Init()
{
top.owMain = true;
}
function TempCtlRSChange()
{
if (event.srcElement.readyState == 4)
{
if (isNaN(parseInt(event.srcElement.Layout, 10)))
{
top.sErr = "ActiveX can not be initialized!";
}
else Init();
}
}
function InitBackCall()
{
ReadCookie();
oTempCtl.removeNode();
for (var i=0; i<aoCameraUrl.length-1; i++)
AddNewCtl(aoCameraUrl[i], false, false);
if (aoCameraUrl.length > 1)
{
BodyResize();
SetFocusCtl(document.all.oCamCtl[2]);
}
}
function BodyResize()
{
setTimeout("BodyResize1();", 0);
}
function BodyResize1()
{
var iCtlNumber = GetCtlNumber();
if (iCtlNumber == 0) return;
var iCols = CalcSqrt(iCtlNumber);
var iRows = Math.floor((iCtlNumber + iCols - 1) / iCols);
var iBorder = parseInt((document.all.oCamCtl[2].style.borderWidth?document.all.oCamCtl[2].style.borderWidth:0), 10);
var iCtlWidth = CalcCamWidth(iCols) - 2 * iBorder;
var iCtlHeight = CalcCamHeight(iRows) - 2 * iBorder;
var iCtlSizeX = Math.floor((iCtlWidth) / 4);
var iCtlSizeY = Math.floor((iCtlHeight) / 3);
if (iCtlSizeX > iCtlSizeY) iCtlSizeX = iCtlSizeY;
for (var i=2; i<document.all.oCamCtl.length; i++)
{
document.all.oCamCtl[i].CamWidth = iCtlSizeX * 4 - 6;
// document.all.oCamCtl[i].CamHeight = iCtlSizeX * 3;
}
}
</SCRIPT>
<SCRIPT defer>
var iEventShowArrayMaxLength = 80;
var asEventShowArray = new Array();
var iEventShowArray = 0;
var iEventShowLine = 0;
var iEventColorTb = ["red", "blue", "#CC00CC", "#008080", "#D9AD00"];
function AppendEventShowArray(s)
{
s = "<font color="+iEventColorTb[iEventShowLine]+">"+s+"</font>";
iEventShowLine++;
if (iEventShowLine >= iEventColorTb.length) iEventShowLine = 0;
if (iEventShowArray >= iEventShowArrayMaxLength)
{
for (var i=1; i<asEventShowArray.length; i++)
asEventShowArray[i-1] = asEventShowArray[i];
asEventShowArray[i-1] = s;
}
else
{
asEventShowArray[iEventShowArray] = s;
iEventShowArray++;
}
return asEventShowArray.join("<br>");
}
var tMotion = null;
</script>
<SCRIPT FOR=oCamCtl EVENT="MotionDetect()" defer>
if (tMotion == null)
{
tMotion = setTimeout('tMotion = null;', 1200);
var date = new Date();
top.rbottom.document.all.EventShow.innerHTML = AppendEventShowArray("Motion: " + this.URL + " ("+date+")");
top.rbottom.document.all.EventShow.scrollTop = window.parent.rbottom.document.all.EventShow.scrollHeight;
delete date;
}
</SCRIPT>
<SCRIPT FOR=oCamCtl EVENT="Resolution(reso)" defer>
if (oFocusCtl == null) return;
if (oFocusCtl == this)
{
top.left.SetResValue(reso);
top.left.ShowAdminCtl(this);
}
</SCRIPT>
<SCRIPT FOR=oCamCtl EVENT="Frequency(freq)" defer>
if (oFocusCtl == null) return;
if (oFocusCtl == this)
{
top.left.SetFreqValue(freq);
top.left.ShowAdminCtl(this);
}
</SCRIPT>
<SCRIPT FOR=oCamCtl EVENT="Quality(quality)" defer>
if (oFocusCtl == null) return;
if (oFocusCtl == this)
{
top.left.SetQuaValue(quality);
}
</SCRIPT>
<SCRIPT FOR=oCamCtl EVENT="Layout(newlay)" defer>
if (oFocusCtl == null) return;
if (oFocusCtl == this)
{
top.left.SetLayout(newlay);
}
</SCRIPT>
<SCRIPT FOR=oCamCtl EVENT="CamVer(ver)" defer>
if (oFocusCtl == null) return;
if (oFocusCtl == this)
{
top.left.SetResolution(ver);
}
</SCRIPT>
<SCRIPT FOR=oCamCtl EVENT="GetCamName(name)" defer>
if (oFocusCtl == null) return;
if (oFocusCtl == this)
{
try
{
top.rinfo.SetCameraName(name);
} catch (e) {};
}
</SCRIPT>
<SCRIPT FOR=oCamCtl EVENT="ServerAudio(enable)" defer>
if (oFocusCtl == null) return;
if (oFocusCtl == this)
{
try
{
top.iBool = enable;
top.rinfo.ServerAudioEvent(enable);
} catch (e) {
top.iBool = enable;
};
}
</SCRIPT>
</HEAD>
<BODY background="I-cam-9000.jpg" onresize="BodyResize();">
<input id=oCamCtl type=hidden><input id=oCamCtl type=hidden>
<OBJECT onreadystatechange="TempCtlRSChange();" style="{visibility:hidden;}" ID=oTempCtl CODEBASE="WinWebPush.cab#version=1,0,1,5" CLASSID="CLSID:7876E4A5-78B7-4020-B08F-C960A1ED54C9"></OBJECT>
</BODY>
</HTML>
|