bugfix: the slice page was broken when nobody is in slice
[plewww.git] / plekit / table / table.js
index b7d4ac4..f0b0bb3 100644 (file)
@@ -1,4 +1,14 @@
-/* $Id$ */
+var debug=false;
+
+/* for debugging purposes */
+function plc_timestamp () {
+  var now = new Date();
+  return now.getMinutes() + ':' + now.getSeconds() + '.' + now.getMilliseconds() ; 
+}
+
+function plc_message (message) {
+  console.log ( plc_timestamp() + ' : ' + message);
+}
 
 /* when a table gets paginated, displays context info */
 function plekit_table_paginator (opts,table_id) {
@@ -79,14 +89,15 @@ if ('undefined' == typeof Node)
 
 // Extract actual text from a DOM node (remove internal tags and so on)
 function getInnerText(node) {
-       var result = '';
-       if (Node.TEXT_NODE == node.nodeType)
-               return node.nodeValue;
-       if (Node.ELEMENT_NODE != node.nodeType)
-               return '';
-       for (var index = 0; index < node.childNodes.length; ++index)
-               result += getInnerText(node.childNodes.item(index));
-       return result;
+    if (node==undefined) return "";
+    var result = '';
+    if (Node.TEXT_NODE == node.nodeType)
+       return node.nodeValue;
+    if (Node.ELEMENT_NODE != node.nodeType)
+       return '';
+    for (var index = 0; index < node.childNodes.length; ++index)
+       result += getInnerText(node.childNodes.item(index));
+    return result;
 } // getInnerText
 
 // cache in the <tr> node the concatenation of the innerTexts of its cells
@@ -115,6 +126,9 @@ function plekit_table_filter(table_id,pattern_id,and_id) {
 }
 
 function plekit_lazy_table_filter (table_id,pattern_id,and_id) {
+
+  if (debug) plc_message ('entering plekit_lazy_table_filter');
+
   var table=$(table_id);
   var css='#'+table_id+'>tbody';
   var rows = $$(css)[0].rows;
@@ -149,6 +163,8 @@ function plekit_lazy_table_filter (table_id,pattern_id,and_id) {
     return;
   }
 
+  if (debug) plc_message ('inside plekit_lazy_table_filter');
+
   var searches=new Array();
   var patterns=new Array();
   if (pattern_text.length > 0) {
@@ -205,6 +221,8 @@ function plekit_lazy_table_filter (table_id,pattern_id,and_id) {
   var end=(new Date).getTime();
   var match_ms=end-start;
 
+  if (debug) plc_message ('almost at end of plekit_lazy_table_filter');
+
   // optimize useless calls to init, by comparing # of matching entries
   var previous_matching=table['previous_matching'];
   if (matching_entries == previous_matching) {
@@ -216,7 +234,9 @@ function plekit_lazy_table_filter (table_id,pattern_id,and_id) {
   tablePaginater.init(table_id);
   var end2=(new Date).getTime();
   var paginate_ms=end2-end;
-  
+
+  if (debug) plc_message ('exiting plekit_lazy_table_filter with paginate_ms=' + paginate_ms);
+
 }
 
 function plekit_table_filter_reset (table_id, pattern_id,and_id) {