/[meteor]/googlecode.com/svn/trunk/public_html/poll.html
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /googlecode.com/svn/trunk/public_html/poll.html

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 23 by andrew.betts, Sun May 20 14:03:10 2007 UTC revision 26 by andrew.betts, Mon Jun 25 10:37:57 2007 UTC
# Line 1  Line 1 
 <html>  
 <body>  
 <script type="text/javascript">  
 window.onError = null;  
 var domainparts = document.domain.split(".");  
 var thisdomain = document.domain;  
 var topdomain = domainparts[domainparts.length-2]+"."+domainparts[domainparts.length-1];  
 document.domain = topdomain;  
 var lastrequesttime = 0;  
 var pollreq = false;  
 var polltimer = false;  
 var i=0;  
 var isaborted = 0;  
 parent.Meteor.register(this);  
   
 Function.prototype.bind = function(obj) {  
         var method = this,  
         temp = function() {  
                 return method.apply(obj, arguments);  
         };  
         return temp;  
 }  
   
 function newXmlHttp() {  
         var xmlhttp;  
         /*@cc_on @*/  
         /*@if (@_jscript_version >= 5)  
                 try {  
                         xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");  
                 } catch (e) {  
                         try {  
                                 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");  
                         } catch (E) {  
                                 xmlhttp = false;  
                         }  
                 }  
         @end @*/  
         if (!xmlhttp && typeof XMLHttpRequest!='undefined') {  
                 xmlhttp = new XMLHttpRequest();  
         }  
         return xmlhttp;  
 }  
   
 function poll() {  
         isaborted = 0;  
         try {  
                 clearTimeout(polltimer);  
         } catch (e) {}  
         var byteoffset = 0;  
         var newdata;  
         document.domain = topdomain;  
         var url = get("subsurl");  
         if (typeof(url)!="undefined") {  
                 var now = new Date();  
                 var t = now.getTime();  
                 url += "&template=2&nocache="+t;  
                 try {  
                         document.domain = thisdomain;  
                 } catch (e) {}  
                 pollreq = newXmlHttp();  
                 pollreq.onreadystatechange = handleresponse;  
                 pollreq.open("GET", url, true);  
                 lastrequesttime = t;  
                 if (get("polltimeout")) polltimer = setTimeout(ptimeout, get("polltimeout"));  
                 pollreq.send(null);  
         }  
         document.domain=topdomain;  
 }  
   
 function handleresponse() {  
         if (typeof(pollreq) == "object" && pollreq.readyState == 4 && !isaborted) {  
                 try {  
                         clearTimeout(polltimer);  
                 } catch (e) {}  
                 if (typeof(topdomain) == "undefined") return false;  
                 document.domain=topdomain;  
                 newdata = pollreq.responseText;  
                 var x = newdata.indexOf("parent.Meteor.setServerTime(");  
                 if (x != -1) {  
                         y = newdata.indexOf(");", x);  
                         if (y != -1) eval(newdata.substring(x,y+2));  
                 }  
                 while (1) {  
                         var x = newdata.indexOf("<s"+"cript>p(");  
                         if (x != -1) {  
                                 y = newdata.indexOf("</"+"script>", x);  
                                 if (y != -1) {  
                                         eval(newdata.substring((x+8),y));  
                                         newdata = newdata.substring(y+9);  
                                 } else {  
                                         break;  
                                 }  
                         } else {  
                                 break;  
                         }  
                 }  
                 var now = new Date();  
                 var t = now.getTime();  
                 var x = get("pollfreq") - (t-lastrequesttime);  
                 if (x < 10) x = 10;  
                 setTimeout(poll, x);  
         }  
 }  
   
 function ptimeout() {  
         isaborted = 1;  
         pollreq.abort();  
         delete pollreq;  
         clearTimeout(polltimer);  
         var now = new Date();  
         var t = now.getTime();  
         var x = get("pollfreq") - (t-lastrequesttime);  
         if (x < 10) x = 10;  
         setTimeout(poll, x);  
 }  
   
 poll();  
   
 </script>  
 </body>  
 </html>  
1    <html>
2    <body>
3    <script type="text/javascript">
4    window.onError = null;
5    var domainparts = document.domain.split(".");
6    var thisdomain = document.domain;
7    var topdomain = domainparts[domainparts.length-2]+"."+domainparts[domainparts.length-1];
8    document.domain = topdomain;
9    var lastrequesttime = 0;
10    var pollreq = false;
11    var polltimer = false;
12    var i=0;
13    var isaborted = 0;
14    parent.Meteor.register(this);
15    
16    Function.prototype.bind = function(obj) {
17            var method = this,
18            temp = function() {
19                    return method.apply(obj, arguments);
20            };
21            return temp;
22    }
23    
24    function newXmlHttp() {
25            var xmlhttp;
26            /*@cc_on @*/
27            /*@if (@_jscript_version >= 5)
28                    try {
29                            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
30                    } catch (e) {
31                            try {
32                                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
33                            } catch (E) {
34                                    xmlhttp = false;
35                            }
36                    }
37            @end @*/
38            if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
39                    xmlhttp = new XMLHttpRequest();
40            }
41            return xmlhttp;
42    }
43    
44    function poll() {
45            isaborted = 0;
46            try {
47                    clearTimeout(polltimer);
48            } catch (e) {}
49            var byteoffset = 0;
50            var newdata;
51            document.domain = topdomain;
52            var url = get("subsurl");
53            if (typeof(url)!="undefined") {
54                    var now = new Date();
55                    var t = now.getTime();
56                    url += "&template=2&nocache="+t;
57                    try {
58                            document.domain = thisdomain;
59                    } catch (e) {}
60                    pollreq = newXmlHttp();
61                    pollreq.onreadystatechange = handleresponse;
62                    pollreq.open("GET", url, true);
63                    lastrequesttime = t;
64                    if (get("polltimeout")) polltimer = setTimeout(ptimeout, get("polltimeout"));
65                    pollreq.send(null);
66            }
67            document.domain=topdomain;
68    }
69    
70    function handleresponse() {
71            if (typeof(pollreq) == "object" && pollreq.readyState == 4 && !isaborted) {
72                    try {
73                            clearTimeout(polltimer);
74                    } catch (e) {}
75                    if (typeof(topdomain) == "undefined") return false;
76                    document.domain=topdomain;
77                    newdata = pollreq.responseText;
78                    var x = newdata.indexOf("parent.Meteor.setServerTime(");
79                    if (x != -1) {
80                            y = newdata.indexOf(");", x);
81                            if (y != -1) eval(newdata.substring(x,y+2));
82                    }
83                    while (1) {
84                            var x = newdata.indexOf("<s"+"cript>p(");
85                            if (x != -1) {
86                                    y = newdata.indexOf("</"+"script>", x);
87                                    if (y != -1) {
88                                            eval(newdata.substring((x+8),y));
89                                            newdata = newdata.substring(y+9);
90                                    } else {
91                                            break;
92                                    }
93                            } else {
94                                    break;
95                            }
96                    }
97                    var now = new Date();
98                    var t = now.getTime();
99                    var x = get("pollfreq") - (t-lastrequesttime);
100                    if (x < 10) x = 10;
101                    setTimeout(poll, x);
102            }
103    }
104    
105    function ptimeout() {
106            isaborted = 1;
107            pollreq.abort();
108            delete pollreq;
109            clearTimeout(polltimer);
110            var now = new Date();
111            var t = now.getTime();
112            var x = get("pollfreq") - (t-lastrequesttime);
113            if (x < 10) x = 10;
114            setTimeout(poll, x);
115    }
116    
117    poll();
118    
119    </script>
120    </body>
121    </html>

Legend:
Removed from v.23  
changed lines
  Added in v.26

  ViewVC Help
Powered by ViewVC 1.1.26