]> Dogcows Code - chaz/chatty/blobdiff - extra/cometd/public_html/stream.html
import meteord-1.06
[chaz/chatty] / extra / cometd / public_html / stream.html
diff --git a/extra/cometd/public_html/stream.html b/extra/cometd/public_html/stream.html
new file mode 100644 (file)
index 0000000..8c64275
--- /dev/null
@@ -0,0 +1,72 @@
+<html>\r
+<body>\r
+<script type="text/javascript">\r
+window.onError = null;\r
+var domainparts = document.domain.split(".");\r
+document.domain = domainparts[domainparts.length-2]+"."+domainparts[domainparts.length-1];\r
+parent.Meteor.register(this);\r
+var streamreq;\r
+var byteoffset;\r
+var newdata;\r
+\r
+function abort() {\r
+       streamreq.abort();\r
+}\r
+\r
+function newXmlHttp() {\r
+    try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}\r
+    try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}\r
+    try { return new XMLHttpRequest(); } catch(e) {}\r
+    return null;\r
+}\r
+\r
+function startstream() {\r
+       streamreq = newXmlHttp();\r
+       byteoffset = 0;\r
+       newdata = "";\r
+       var url = parent.Meteor.getSubsUrl();\r
+       streamreq.open("GET", url, true);\r
+       streamreq.onreadystatechange = function() {\r
+               if (typeof streamreq == "undefined") return;\r
+               if (streamreq.readyState == 3) {\r
+                       extractEvents(streamreq.responseText);\r
+               } else if (streamreq.readyState == 4) {\r
+                       extractEvents(streamreq.responseText);\r
+                       delete streamreq;\r
+                       if (typeof(r)=="function") {\r
+                               r();\r
+                       }\r
+               }\r
+       }\r
+       streamreq.send(null);\r
+}\r
+\r
+function extractEvents(responsestr) {\r
+       newdata += responsestr.substring(byteoffset);\r
+       byteoffset = responsestr.length;\r
+       while (1) {\r
+               var x = newdata.indexOf("<s"+"cript>");\r
+               if (x != -1) {\r
+                       y = newdata.indexOf("</"+"script>", x);\r
+                       if (y != -1) {\r
+                               eval(newdata.substring((x+8),y));\r
+                               newdata = newdata.substring(y+9);\r
+                       } else {\r
+\r
+                               // Last message is incomplete.  Ignore it and it will be processed next time\r
+                               break;\r
+                       }\r
+               } else {\r
+\r
+                       // No more messages\r
+                       break;\r
+               }\r
+       }\r
+}\r
+\r
+\r
+\r
+startstream();\r
+</script>\r
+</body>\r
+</html>
\ No newline at end of file
This page took 0.018327 seconds and 4 git commands to generate.