Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--
- var fps = 30;
- var quality = 30;
- var timeout = 33;
- var baseURL = "{$url}";
- var xmlHttpOk = "{$xmlHttpOk}";
- var t_;
- var i_;
- var ct_;
- var id;
- var xmlHttp;
- var firstReq=true;
- var state = "null";
- function showErrorImage()
- {
- clearTimeout(t_);
- clearInterval(i_);
- document.images.cctv.onload = "";
- document.images.cctv.src = "http://www.yawcam.com/offline.jpg";
- window.status = "Webcam offline";
- }
- function showStatusImage(imgUrl)
- {
- clearTimeout(t_);
- clearInterval(i_);
- document.images.cctv.onload = "";
- document.images.cctv.src = imgUrl;
- }
- function reloadImage()
- {
- var theDate = new Date();
- var url = baseURL;
- url += "&time=";
- url += theDate.getTime();
- document.images.cctv.src = url;
- window.status = "Yawcam streaming...";
- }
- function fixImageTimeout()
- {
- t_ = setTimeout("reloadImage();",timeout);
- }
- function cTO()
- {
- if(state=="running")
- {
- clearTimeout(t_);
- reloadImage();
- }
- }
- function startPoll()
- {
- document.images.cctv.onload=fixImageTimeout
- fixConnectTimeout();
- getStatus();
- }
- function fixStatusTimeout()
- {
- ts_ = setTimeout("getStatus();",2000);
- }
- function fixConnectTimeout()
- {
- ct_ = setTimeout("showErrorImage();",45000);
- }
- function getStatus()
- {
- xmlHttp=GetXmlHttpObject()
- if(xmlHttp==null)
- {
- alert("Browser does not support HTTP Request")
- return
- }
- var url= xmlHttpOk
- xmlHttp.onreadystatechange=stateChanged
- xmlHttp.open("GET",url,true)
- xmlHttp.send(null)
- }
- function sendPass()
- {
- xmlHttp=GetXmlHttpObject()
- if(xmlHttp==null)
- {
- alert("Browser does not support HTTP Request")
- return
- }
- var user = document.getElementById('user').value;
- var pass = document.getElementById('pass').value;
- var url=baseURL+"get?id="+id+"&u="+user+"&p="+pass+"&r="+Math.random()
- xmlHttp.onreadystatechange=stateChanged
- xmlHttp.open("GET",url,true)
- xmlHttp.send(null)
- }
- function stateChanged()
- {
- if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
- {
- if(xmlHttp.status==200)
- {
- if(xmlHttp.responseText=="ok")
- {
- if(firstReq)
- {
- i_ = setInterval("getStatus();",2000);
- clearTimeout(ct_);
- //hideLayer('passLyr');
- firstReq=false;
- state="running";
- document.images.cctv.onload=fixImageTimeout
- reloadImage();
- }
- }
- else if(xmlHttp.responseText=="2many")
- {
- clearTimeout(ct_);
- state="2many";
- showStatusImage("img/toomany.jpg");
- window.status = "Try later...";
- }
- else if(xmlHttp.responseText=="banned")
- {
- clearTimeout(ct_);
- state="banned";
- showStatusImage("img/banned.jpg");
- window.status = "You are banned.";
- }
- else if(xmlHttp.responseText=="dataLimit")
- {
- state="datalimit";
- showStatusImage("img/datalimit.jpg");
- window.status = "You hit data limit.";
- }
- else if(xmlHttp.responseText=="timeLimit")
- {
- state="timelimit";
- showStatusImage("img/timelimit.jpg");
- window.status = "You hit time limit.";
- }
- else if(xmlHttp.responseText=="kicked")
- {
- state="kicked";
- showStatusImage("img/kicked.jpg");
- window.status = "You are kicked.";
- }
- else if(xmlHttp.responseText=="passErr")
- {
- state="passErr";
- document.getElementById('passHeading').innerHTML = '<font color="#FF0000">Login Error!</font>';
- window.status = "Login Error!";
- }
- else if(xmlHttp.responseText=="pass")
- {
- clearTimeout(ct_);
- state="pass";
- showStatusImage("img/pass.jpg");
- setLyr(document.getElementById('cctv'),'passLyr',false,0);
- showLayer('passLyr');
- }
- else if(xmlHttp.responseText=="playing sound")
- {
- /* Do nothing */
- }
- else if(xmlHttp.responseText=="playing sound failed")
- {
- alert("Failed to play sound!");
- }
- else
- {
- state="error";
- showErrorImage();
- window.status = "Error...";
- alert("Unknown response: "+xmlHttp.responseText);
- }
- }
- else if (xmlHttp.status==404)
- {
- //alert("Got 404");
- }
- }
- }
- function GetXmlHttpObject()
- {
- var XMLHttp_=null
- try
- {
- XMLHttp_=new ActiveXObject("Msxml2.XMLHTTP")
- }
- catch(e)
- {
- try
- {
- XMLHttp_=new ActiveXObject("Microsoft.XMLHTTP")
- }catch(e){}
- }
- if (XMLHttp_==null)
- {
- XMLHttp_=new XMLHttpRequest()
- }
- return XMLHttp_;
- }
- -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement