http_streaming: gst, target page and myfrom parameters passed at construction time
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.com>
Sat, 17 Dec 2011 18:07:37 +0000 (19:07 +0100)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.com>
Sat, 17 Dec 2011 18:07:37 +0000 (19:07 +0100)
web/briskin5/index.php
web/briskin5/index_rd.php
web/http_streaming.js
web/index.php
web/index_rd.php

index 7ee4a33..2e5c5a0 100644 (file)
@@ -71,7 +71,6 @@ header('Content-type: text/html; charset="utf-8"',true);
    var stat = "table";
    var subst = "none";
    var table_pos = "";
-   var myfrom = "table_php";
    var g_withflash = false;
 
    var asta_ptr;
@@ -101,7 +100,7 @@ window.onload = function() {
   preferences_update();
 
   sess = "<?php echo "$sess"; ?>";
-  hstm = new http_streaming("sess", $('sandbox'));
+  hstm = new http_streaming(gst, 'table_php', 'sess', $('sandbox'), 'index_rd.php');
   hstm.hbit_set(heartbit);
   
   window.onbeforeunload = onbeforeunload_cb;  
index dae16ac..3e7aa04 100644 (file)
@@ -402,11 +402,11 @@ header('Content-type: application/xml; charset="utf-8"',true);
 // header('Content-type: text/plain; charset="utf-8"',true);
 // header('Content-type: text/html; charset="utf-8"',true);
 
-if (!isset($myfrom))
-     $myfrom = "";
+if (!isset($from))
+     $from = "";
 if (!isset($subst))
      $subst = "";
-log_rd2("FROM OUTSIDE - STAT: ".$stat." SUBST: ".$subst." STEP: ".$step." MYFROM: ".$myfrom. "IS_PAGE:" . $is_page_streaming."USER_AGENT:".$HTTP_USER_AGENT."  TABLE:".$table_idx);
+log_rd2("FROM OUTSIDE - STAT: ".$stat." SUBST: ".$subst." STEP: ".$step." FROM: ".$from. "IS_PAGE:" . $is_page_streaming."USER_AGENT:".$HTTP_USER_AGENT."  TABLE:".$table_idx);
 
 
 $endtime = time() + STREAM_TIMEOUT;
index d396324..8029812 100644 (file)
  *   MANDATORY
  *
  *   NOT MANDATORY
- *   - gst management
- *   - myfrom into the constructor
- *   - target page into the constructor
  *   - type of streaming into the constructor
  *   - all iframe related streaming add
  *   - substitute fixed "eval" with a generic command hunks processor
  *
+ *   DONE - myfrom (now from) into the constructor
+ *   DONE - target page into the constructor
+ *   DONE - gst management
  *   DONE - xhr_rd prefix remove from inner class attrs
  *   DONE - move hbit implementation to external file
  *   DONE - sandbox management
  *
  */
 
-function http_streaming(cookiename, sandbox)
+function http_streaming(gst, from, cookiename, sandbox, targetpage)
 {
     this.xhr = createXMLHttpRequest();
     // this.xhr.setRequestHeader("Content-type", "text/html; charset=utf-8");
+
+    this.gst = gst;
+    this.from = from;
     this.cookiename = cookiename;
+    this.sandbox = sandbox;
+    this.targetpage = targetpage;
 }
 
 http_streaming.prototype = {
+    gst: null,
+    from: null,
     cookiename: null,
     sandbox: null,
+    targetpage: null,
 
+    /* cookiepath is automatically customized in installation phase */
     cookiepath: "/brisk/",
     xhr: null,
     watchdog: null,
@@ -117,7 +126,7 @@ http_streaming.prototype = {
             }
            return;
         }
-        createCookie(this.cookie_name, sess, 24*365, this.cookiepath);
+        createCookie(this.cookiename, sess, 24*365, this.cookiepath);
         
         // NOTE: *ctx = "" to prevent konqueror stream commands duplication.
         this.oldctx = "";
@@ -126,7 +135,7 @@ http_streaming.prototype = {
         /* NOTE document.uniqueID exists only under IE  */
         // if (g_is_spawn == 1)
         // alert("di qui3: "+(g_is_spawn == 1 ? "&table_idx="+g_table_idx : ""));
-        this.xhr.open('GET', 'index_rd.php?sess='+sess+"&stat="+stat+"&subst="+subst+"&step="+step+"&onlyone="+(document.uniqueID ? "TRUE" : "FALSE")+"&myfrom="+myfrom, true);
+        this.xhr.open('GET', this.targetpage+'?'+this.cookie_name+'='+sess+"&stat="+stat+"&subst="+subst+"&step="+step+"&onlyone="+(document.uniqueID ? "TRUE" : "FALSE")+"&from="+this.from, true);
         //    try { 
 
         var self = this;
@@ -170,7 +179,7 @@ http_streaming.prototype = {
           }
         */
         if (this.sandbox != null) {
-            var zug = "POLL sess = "+sess+" stat = "+stat+" subst = "+subst+" step = "+gst.st+" step_loc = "+gst.st_loc+" step_loc_new = "+gst.st_loc_new+" STOP: "+this.stopped;
+            var zug = "POLL sess = "+sess+" stat = "+stat+" subst = "+subst+" step = "+this.gst.st+" step_loc = "+this.gst.st_loc+" step_loc_new = "+this.gst.st_loc_new+" STOP: "+this.stopped;
             
             if (zug != this.sandbox.innerHTML)
                this.sandbox.innerHTML = zug;
@@ -180,14 +189,14 @@ http_streaming.prototype = {
         do {
            again = 0;
            xhrrestart = 0;
-           if (gst.st_loc < gst.st_loc_new) {
+           if (this.gst.st_loc < this.gst.st_loc_new) {
                // there is some slow actions running
                break;
            }
-           else if (gst.comms.length > 0) {
+           else if (this.gst.comms.length > 0) {
                var singlecomm;
                 
-               singlecomm = gst.comms.shift();
+               singlecomm = this.gst.comms.shift();
                // alert("EXE"+gugu);
                // $("xhrdeltalog").innerHTML = "EVALL: "+singlecomm.replace("<", "&lt;", "g"); +"<br>";
                this.hbit("+");
@@ -213,13 +222,13 @@ http_streaming.prototype = {
 
                                 this.delayed = setTimeout(
                                     function(f_obj, f_sess, f_stat, f_subst, f_step){ f_obj.run(f_sess, f_stat, f_subst, f_step); },
-                                    this.delay, this, sess, stat, subst, gst.st);
+                                    this.delay, this, sess, stat, subst, this.gst.st);
                                 // console.log("XXX DI QUI post"+this.delayed);
                             }
                         }
                         else {
                             // console.log("yyy DI QUI "+this.delay);
-                            this.run(sess, stat, subst, gst.st);
+                            this.run(sess, stat, subst, this.gst.st);
                         }
                    }
                     
@@ -301,7 +310,7 @@ http_streaming.prototype = {
                        // $("sandbox").innerHTML += "POST COMMARR<br>";
                        for (i = 0 ; i < comm_arr.length ; i++) {
                            var temp = comm_arr[i].replace(comm_clean,"$1").split("|");
-                           gst.comms = gst.comms.concat(temp);
+                           this.gst.comms = this.gst.comms.concat(temp);
                            // XX alert("COMM_ARR["+i+"]: "+comm_arr[i]+"  LEN:"+comm_arr[i].length);
                            comm_len += comm_arr[i].length;
                        }
@@ -325,13 +334,13 @@ http_streaming.prototype = {
                     
                     this.delayed = setTimeout(
                         function(obj, sess, stat, subst, step){ obj.run(sess, stat, subst, step); },
-                        this.delay, this, sess, stat, subst, gst.st);
+                        this.delay, this, sess, stat, subst, this.gst.st);
                     // console.log("XXX DI QUO post"+this.delayed);
                 }
             }
             else {
                 // console.log("yyy DI QUO "+this.delay);
-                this.run(sess, stat, subst, gst.st);
+                this.run(sess, stat, subst, this.gst.st);
             }
             
         }
index 42fa7ac..a2f7bf8 100644 (file)
@@ -1032,7 +1032,6 @@ echo "$body"; ?>
    var g_withflash = false;
    var g_imgct= 0;
    var g_imgtot = g_preload_img_arr.length;
-   var myfrom = "index_php";
    var g_brow = null;
    var spo_slide, sup_slide;
 
@@ -1064,7 +1063,7 @@ else {
 
 ?>
      sess = "<?php echo "$sess"; ?>";
-     hstm = new http_streaming("sess", $('sandbox'));
+     hstm = new http_streaming(gst, 'index_php', 'sess', $('sandbox'), 'index_rd.php');
      hstm.hbit_set(heartbit);
      tra = new train($('room_tit'));
      window.onunload = onunload_cb;
index 4a30371..d7348bb 100644 (file)
@@ -451,11 +451,11 @@ header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
 header('Content-type: application/xml; charset="utf-8"',true);
 
-if (!isset($myfrom))
-     $myfrom = "";
+if (!isset($from))
+     $from = "";
 if (!isset($subst))
      $subst = "";
-log_rd2("FROM OUTSIDE - STAT: ".$stat." SUBST: ".$subst." STEP: ".$step." MYFROM: ".$myfrom. "IS_PAGE:" . $is_page_streaming);
+log_rd2("FROM OUTSIDE - STAT: ".$stat." SUBST: ".$subst." STEP: ".$step." FROM: ".$from. "IS_PAGE:" . $is_page_streaming);
 
 
 $endtime = time() + STREAM_TIMEOUT;