3 /* set or clear the ' invisibleRow' in the tr's classname, according to visible */
4 function plc_table_row_visible (row,visible) {
7 cn=cn.replace(" invisibleRow","");
8 if (! visible) cn += " invisibleRow";
12 /* maintain the number of matching entries in the <tbody> element's classname */
13 function plc_table_tbody_matching (tbody, matching) {
14 var new_cn="matching-" + matching;
15 var cn=tbody.className;
16 if (cn.match("matching-")) {
17 cn=cn.replace(/matching-\d+/,new_cn);
21 cn=cn.replace(/^ +/,"");
25 // /* scan the table, and mark as visible the rows that have at least one cell that contains the pattern */
26 function plc_table_filter (table_id,pattern_id) {
27 var tbody = document.getElementById(table_id).getElementsByTagName("tbody")[0];
29 var pattern_text = document.getElementById(pattern_id).value;
30 var row_index, row, cells, cell_index, cell, visible;
32 var matching_entries=0;
34 // remove whitespaces at the beginning and end
35 pattern_text = pattern_text.replace(/[ \t]+$/,"");
36 pattern_text = pattern_text.replace(/^[ \t]+/,"");
38 var patterns = pattern_text.split(" ");
40 for (row_index = 0; row=rows[row_index]; row_index++) {
42 /* xxx deal with empty patterns and whitespaces */
43 if (patterns.length == 0) {
48 for (cell_index = 0; cell=cells[cell_index]; cell_index++) {
51 if (cell.innerHTML.match(pattern)) visible=true;
55 plc_table_row_visible(row,visible);
56 if (visible) matching_entries +=1;
58 plc_table_tbody_matching(tbody,matching_entries);
59 tablePaginater.init(table_id);
62 function plc_table_filter_reset (table_id, pattern_id) {
64 document.getElementById(pattern_id).value="";
65 plc_table_filter (table_id, pattern_id);