Index: /trunk/FACT++/www/smartfact/index.js
===================================================================
--- /trunk/FACT++/www/smartfact/index.js	(revision 13934)
+++ /trunk/FACT++/www/smartfact/index.js	(revision 13935)
@@ -9,5 +9,5 @@
 function $new(name) { return document.createElement(name); }
 function $txt(txt) { return document.createTextNode(txt); }
-function trim(str) { return str.replace("/^\s\s*/", '').replace("/\s\s*$/", ''); }
+function trim(str) { return str.replace(/^\s\s*/, "").replace(/\s*\s$/, ""); }
 function valid(str) { if (!str) return false; if (str.length==0) return false; return true;}
 function isSliding() { var z = $("body").getAttribute("data-visible"); return $("table"+z) ? $("table"+z).offsetLeft!=0 : false; }
@@ -191,24 +191,9 @@
         title = title.substr(1);
 
-    var table = $("table"+z);
-    if (table)
-        $("body").removeChild(table);
-
-    table = $new("table");
-    table.setAttribute("class", "tborder");
-    table.id = "table"+z;
-    table.border = 0;
-    table.cellSpacing = 0;
-    table.cellPadding = "0px";
-    /*table.width = "100%";*/
-    //table.setAttribute("style", "overflow:hidden;position:fixed;top:0px;left:"+window.innerWidth+"px;")
-    table.setAttribute("style", "position:absolute;top:0px;left:"+window.innerWidth+"px;width:100%;");
-
-    // -----------------------------------------------------
+    // ==================================================================
 
     var th = $new("thead");
     th.colSpan = 3;
     th.width = "100%";
-    table.appendChild(th);
 
     var htr = $new("tr");
@@ -247,11 +232,5 @@
     hhtr.appendChild(htd1);
     hhtr.appendChild(htd2);
-/*
-    htd0.style.verticalAlign = "middle";
-    htd1.style.verticalAlign = "middle";
-    htd2.style.verticalAlign = "middle";
-    htd3.style.verticalAlign = "middle";
-    htd4.style.verticalAlign = "middle";
-*/
+
     var div1 = $new("div");
     var div2 = $new("div");
@@ -316,13 +295,7 @@
     htd4.appendChild(div4);     // Warning
 
-    // -----------------------------------------------------
-
-    var tbody = $new("tbody");
-    table.appendChild(tbody);
-
-    // -----------------------------------------------------
+    // ==================================================================
 
     var tf = $new("tfoot");
-    table.appendChild(tf);
 
     var ftr = $new("tr");
@@ -344,7 +317,9 @@
     var ftd2 = $new("td");
     var ftd3 = $new("td");
+    var ftd4 = $new("td");
     ftdH.setAttribute("width", "1px");
     ftd2.setAttribute("width", "1px");
     ftd3.setAttribute("width", "1px");
+    ftd4.setAttribute("width", "1px");
 
     ftdH.setAttribute("class", "tcell1");
@@ -353,4 +328,5 @@
     ftd2.setAttribute("class", "tcell2");
     ftd3.setAttribute("class", "tcell2");
+    ftd4.setAttribute("class", "tcell2");
 
     ftab.appendChild(ftdH);
@@ -359,4 +335,5 @@
     ftab.appendChild(ftd2);
     ftab.appendChild(ftd3);
+    ftab.appendChild(ftd4);
 
     var fdivH = $new("div");
@@ -365,10 +342,13 @@
     var fdiv2 = $new("div");
     var fdiv3 = $new("div");
+    var fdiv4 = $new("div");
     ftd0.style.paddingLeft = "5px";
-    fdiv2.id="cmd"+z;
+    fdiv4.id="cmd"+z;
 
     fdiv2.setAttribute("class", "icon_white");
     fdiv3.setAttribute("class", "icon_white");
+    fdiv4.setAttribute("class", "icon_white");
     fdiv2.setAttribute("style", "background-position:-72px 50%;");
+    fdiv4.setAttribute("style", "background-position:-432px 50%;");
     fdiv2.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; sendCommand('stop'); this.style.backgroundColor=''; };
     if (is_cmd)
@@ -395,4 +375,5 @@
         fdivH.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('help-'+name, z, +1); };
     }
+    fdiv4.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('scriptlog', z,  +1); };
 
 
@@ -410,10 +391,15 @@
     if (name!='control')
         ftd3.appendChild(fdiv3);
-
-    $("body").appendChild(table);
+    if (name!='scriptlog')
+        ftd4.appendChild(fdiv4);
+
+    // ==================================================================
+
+    var tbody = $new("tbody");
 
     for (var i=0; i<lines.length; i++)
     {
         lines[i] = trim(lines[i]);
+
         if (lines[i][0] == '#')
             lines.splice(i--, 1);
@@ -440,4 +426,6 @@
     for (var i=1; i<lines.length; i++)
     {
+        lines[i] = trim(lines[i]);
+
         if (lines[i].length==0)
             continue;
@@ -596,30 +584,7 @@
         tbody.appendChild(tr);
     }
-/*
-    if (true)
-    {
-        tr = $new("tr");
-        tr.setAttribute("class", "row");
-
-        td = $new("td");
-        td.colSpan = "3";
-        tr.appendChild(td);
-
-        var sp = $new("div");
-        sp.setAttribute("class", "icon_color");
-        sp.setAttribute("style", "background-position: -144px -14px;");
-        td.appendChild(sp);
-
-        sp = $new("div");
-        sp.setAttribute("class", "icon_color");
-        sp.setAttribute("style", "background-position: -56px -14px;");
-        td.appendChild(sp);
-
-        tr.appendChild(td);
-
-        tbody.appendChild(tr);
-    }
-*/
-    // ---------------------------------------
+
+    // ==================================================================
+
     if (debug == true)
     {
@@ -635,5 +600,42 @@
     }
 
-    // ---------------------------------------
+    // ==================================================================
+
+    var table = $("table"+z);
+    if (table)
+        $("body").removeChild(table);
+
+    table = $new("table");
+    table.id = "table"+z;
+    table.border = 0;
+    table.cellSpacing = 0;
+    table.cellPadding = "0px";
+    //table.setAttribute("style", "overflow:hidden;position:fixed;top:0px;left:"+window.innerWidth+"px;")
+    table.setAttribute("style",
+                       "position:fixed;width:100%;top:0px;"+
+                       "left:"+window.innerWidth+"px;");
+
+    table.appendChild(th);
+    table.appendChild(tbody);
+    table.appendChild(tf);
+
+    $("body").appendChild(table);
+
+    // ==================================================================
+
+    /*
+     // Scrollbar for just the body
+     table.style.position  = "fixed";
+     th.style.position     = "aboslute";
+     tf.style.position     = "aboslute";
+     tbody.style.overflowY = "auto";
+     tbody.style.display   = "block";
+     tbody.style.height    = (window.innerHeight-th.clientHeight-tf.clientHeight)+"px";
+     tbody.id = "tbody"+z;
+     th.id    = "thead"+z;
+     tf.id    = "tfoot"+z;
+     */
+
+    // ==================================================================
 
     table.setAttribute("data-file", name);
@@ -652,4 +654,14 @@
         return;
 
+    // ===========================================
+    /*
+     var tb = $("tbody"+z);
+     var hw = $("thead"+z).clientHeight;
+     var fw = $("tfoot"+z).clientHeight;
+
+     tb.style.height = (window.innerHeight-hw-fw)+"px";
+     */
+    // ===========================================
+
     var fixedw = $("body").getAttribute("data-width");
     var fixedh = $("body").getAttribute("data-height");
@@ -657,35 +669,4 @@
     var W = fixedw>0 ? fixedw : window.innerWidth;
     var H = fixedh>0 ? fixedh : window.innerHeight;
-
-    //alert(window.innerWidth+"/"+$("body").scrollWidth+"/"+$("table"+z).scrollWidth);
-
-    // wIw   bSw   tSw
-    // 430 / 860 / 430
-    // 429 / 430 / 430
-    // 366 / 430 / 430
-
-    // 672 / 1344 /  672
-    // 672 / 1329 / 1329
-
-    // Chrome: needs scrollbar
-    // wiW  bsW  tsW  bcW  tcW  boW  toW
-    // 100  200  100   84  100   84  100
-    // 100   85   85   69   85   79   85
-
-    // Chrome: does not need scrollbar
-    //  100  200  100  84  100   84  100
-    //  100  100  100  84  100   84  100
-
-    // Firefox: does not need scrollbar
-    //  100   84  100  84  100   84  100
-    //  100   84  100  84  100   84  100
-
-    // Firefox: does need scrollbar
-    //  100   84  100  84  100   84  100
-    //  100   69   85  69   85   69   85
-
-    // opera no scrollbar:
-    //  100   84  100  84  100   84  100
-    //  100   84  100  84  100   84  100
 
     var max = $("body").getAttribute("data-max")=="yes";
