clean of string stream added (we still need <script> objects clean) master
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.com>
Wed, 25 Apr 2012 15:48:24 +0000 (17:48 +0200)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.com>
Wed, 25 Apr 2012 15:48:24 +0000 (17:48 +0200)
TODO.stream_iframe
web/xynt/xynt-http-streaming-ifra.js
web/xynt/xynt-http-streaming.js

index e93ec9e..1824fab 100644 (file)
@@ -1,14 +1,10 @@
-- resize the ctx_new var
-
-ABRT - stop js into iframe when the page is stopped
+- clean the DOM during the streaming
 
+DONE - resize the ctx_new var
 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
+ABRT - stop js into iframe when the page is stopped
 
index 7b4124f..2450adf 100644 (file)
@@ -1,6 +1,14 @@
-var ctx_new = "";
-
+var ctx_new     = "";
+var ctx_old_len = 0;
 function push(s) {
+    // FIXME: remove this barbarian log
+    window.parent.console.log("ctx_new.length: "+ctx_new.length+"  ctx_old_len: "+ctx_old_len);
+    if (ctx_new.length == ctx_old_len && ctx_old_len > 0) {
+        // FIXME: remove this barbarian log
+        window.parent.console.log("NOW clean");
+        ctx_new = "";
+        ctx_old_len = 0;
+    }
     if (s != null) {
         ctx_new += "@BEGIN@"+s+"@END@";
     }
index f414a56..130af82 100644 (file)
@@ -60,9 +60,6 @@ http_streaming.prototype = {
     cmdproc:           null,
     comm_match:        /_*@BEGIN@(.*?)@END@/g, 
     comm_clean:        /_*@BEGIN@(.*?)@END@/,
-    // ctx_old_len:       0,
-    // ctx_new:           "",
-    // ctx_new_len:       0,
     stream:            "",
 
     start: function(page) {
@@ -125,16 +122,17 @@ http_streaming.prototype = {
         do {
            // CHECK: maybe again here isn't needed 
             again = 0;
-            if (typeof(this.ifra.contentWindow.ctx_new) == 'undefined')
+            if (typeof(this.ifra.contentWindow.ctx_new)     == 'undefined' ||
+                typeof(this.ifra.contentWindow.ctx_old_len) == 'undefined')
                 break;
             
             ctx_new_len = this.ifra.contentWindow.ctx_new.length;
-            if (ctx_new_len == this.ctx_old_len) {
+            if (ctx_new_len <= this.ifra.contentWindow.ctx_old_len) {
                 break;
             }
-            this.log("new: "+ ctx_new_len + "  old: "+this.ctx_old_len);
+            this.log("new: "+ ctx_new_len + "  old: "+this.ifra.contentWindow.ctx_old_len);
             this.keepalive_new++;            
-            for (i = this.ctx_old_len ; i < ctx_new_len ; i++) {
+            for (i = this.ifra.contentWindow.ctx_old_len ; i < ctx_new_len ; i++) {
                if (this.ifra.contentWindow.ctx_new.charAt(i) != '_') {
                     this.log("ctx_new.char(i) != '_' ["+this.ifra.contentWindow.ctx_new.charAt(i)+"]");
                    break;
@@ -143,7 +141,7 @@ http_streaming.prototype = {
                     this.log("ctx_new.charAt(i) == '_'");
                 }
            }
-           this.ctx_old_len = i;
+           this.ifra.contentWindow.ctx_old_len = i;
            if (i == ctx_new_len) {
                 this.log("old_len == i");
                break;
@@ -151,7 +149,7 @@ http_streaming.prototype = {
             else {
                 this.log("old_len != i: "+i);
             }
-            comm_newpart = this.ifra.contentWindow.ctx_new.substr(this.ctx_old_len);    
+            comm_newpart = this.ifra.contentWindow.ctx_new.substr(this.ifra.contentWindow.ctx_old_len);    
             comm_len = 0;
            comm_arr = comm_newpart.match(this.comm_match);
 
@@ -165,7 +163,7 @@ http_streaming.prototype = {
                }
                again = 1;
            }
-            this.ctx_old_len += comm_len;
+            this.ifra.contentWindow.ctx_old_len += comm_len;
         } while (again);
         
 
@@ -226,7 +224,6 @@ http_streaming.prototype = {
             delete this.ifra;
             this.ifra = null;
         }
-        this.ctx_old_len = 0;
     },
 
     reload: function () {