full url bug (ffox 3.5 was affected) for forever iframe streaming fixed
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.com>
Thu, 19 Apr 2012 06:50:18 +0000 (08:50 +0200)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.com>
Thu, 19 Apr 2012 06:50:18 +0000 (08:50 +0200)
TODO.stream_iframe [new file with mode: 0644]
web/test-hs.php
web/xynt/xynt-commons.js
web/xynt/xynt-http-streaming.js

diff --git a/TODO.stream_iframe b/TODO.stream_iframe
new file mode 100644 (file)
index 0000000..e93ec9e
--- /dev/null
@@ -0,0 +1,14 @@
+- resize the ctx_new var
+
+ABRT - stop js into iframe when the page is stopped
+
+DONE - fix "full path problem"
+
+DONE - clean the DOM at each reload
+    
+DONE - iframe + index_rd that: push forever commands AND watchdog system 
+
+DONE - use watchdog to prevent hang of the stream (reload and full reset of objects)
+
+DONE - executed commands
+
index c09c75c..8711ef9 100644 (file)
@@ -23,9 +23,7 @@ window.onload = function () {
     createCookie('sess', sess, 24*365,cookiepath);
     gst = new globst();
     hs = new http_streaming(window, gst, sess, console);
-    // FIXME: with relative path not work!
-    hs.start('http://dodo.birds.lan/xynt/test-hs-rd.php');
-    // hs.start('test-hs-rd.php');
+    hs.start('test-hs-rd.php');
 };
 <?php
     }
index 45b5c85..9af0555 100644 (file)
@@ -169,4 +169,45 @@ function url_append_args(url)
     }
 
     return (ret);
+}
+
+function url_complete(parent, url)
+{
+    var p, p2, rest;
+    var host = "", path = "";
+
+    // host extraction
+    p = parent.indexOf("://");
+    if (p > -1) {
+        rest = parent.substring(p+3);
+        p2 = rest.indexOf("/");
+        if (p2 > -1) {
+            host = parent.substring(0, p+3+p2);
+            rest = parent.substring(p+3+p2);
+        }
+        else {
+            host = rest;
+            rest = "";
+        }
+    }
+    else {
+        rest = parent;
+    }
+
+    // path extraction
+    p = rest.lastIndexOf("/");
+    if (p > -1) {
+        path = rest.substring(0, p+1);
+    }
+
+    // alert("host: ["+host+"]  path: ["+path+"]");
+    if (url.substring(0,6) == 'http:/' || url.substring(0,7) == 'https:/') {
+        return (url);
+    }
+    else if (url.substring(0,1) == '/') {
+        return (host+url);
+    }
+    else {
+        return (host+path+url);
+    }
 }
\ No newline at end of file
index 477e754..a9ccdcd 100644 (file)
@@ -73,9 +73,9 @@ http_streaming.prototype = {
         this.ifra.style.visibility = "hidden";
         this.doc.body.appendChild(this.ifra);
         if (page != null)
-            this.page = page;
+            this.page = url_complete(this.win.location.href, page);
         this.page = url_append_args(this.page, "sess", this.sess, "st", gst.st);
-        this.log(this.page);
+        // this.log("http_streaming::start:this.page "+this.page);
         this.ifra.contentWindow.location.href = this.page;
         this.watchdog_ct  = 0;
         this.watchdog_hdl = setTimeout(function(obj) { obj.log("tout1"); obj.watchdog(); }, this.watchdog_timeout, this);