make the search more interactive and less cpu hangry with a timeout and closure.
authorBarış Metin <Talip-Baris.Metin@sophia.inria.fr>
Thu, 9 Apr 2009 15:19:25 +0000 (15:19 +0000)
committerBarış Metin <Talip-Baris.Metin@sophia.inria.fr>
Thu, 9 Apr 2009 15:19:25 +0000 (15:19 +0000)
plekit/table/table.js

index 8656af9..14c7220 100644 (file)
@@ -102,9 +102,18 @@ function plekit_tr_text (tr) {
   return text;
 }
 
+var plekit_table_filter_timeout = null;
 /* scan the table, and mark as visible 
    the rows that match (either AND or OR the patterns) */
-function plekit_table_filter (table_id,pattern_id,and_id) {
+function plekit_table_filter(table_id,pattern_id,and_id) {
+  clearTimeout(plekit_table_filter_timeout);
+  plekit_table_filter_timeout = setTimeout(function() {
+                                             plekit_lazy_table_filter(table_id,pattern_id,and_id)
+                                           },
+                                           200);
+}
+
+function plekit_lazy_table_filter (table_id,pattern_id,and_id) {
   var table=$(table_id);
   var css='#'+table_id+'>tbody';
   var rows = $$(css)[0].rows;