-/* $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) {
function plekit_table_row_visible (row,visible) {
var cn=row.className;
/* clear */
- cn=cn.replace(" invisibleRow","");
+ cn=cn.replace("invisibleRow","");
+ cn.strip();
if (! visible) cn += " invisibleRow";
row.className=cn;
}
// 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
}
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;
return;
}
- // re compile all patterns
- var pattern_texts = pattern_text.strip().split(" ");
+ if (debug) plc_message ('inside plekit_lazy_table_filter');
+
var searches=new Array();
var patterns=new Array();
- for (var i=0; i < pattern_texts.length; i++) {
- // ignore case
- searches[i]=pattern_texts[i].toLowerCase();
- patterns[i]=new RegExp(pattern_texts[i],"i");
+ if (pattern_text.length > 0) {
+ // re compile all patterns
+ var pattern_texts = pattern_text.strip().split(" ");
+ for (var i=0; i < pattern_texts.length; i++) {
+ // ignore case
+ searches[i]=pattern_texts[i].toLowerCase();
+ patterns[i]=new RegExp(pattern_texts[i],"i");
+ }
}
// scan rows, elaborate 'visible'
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) {
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) {