-// from a cell, extract visible text by removing <> and cache in 'plc_text' attribute
-var re_brackets = new RegExp ('<[^>]*>','g');
-
-function plc_table_cell_text (cell) {
- if (cell['plc_text']) return cell['plc_text'];
- var text = cell.innerHTML;
- // remove what's between <>
- text = text.replace(re_brackets,'');
- cell['plc_text'] = text;
+// Working around MSIE...
+if ('undefined' == typeof Node)
+ Node = { ELEMENT_NODE: 1, TEXT_NODE: 3 };
+
+// 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;
+} // getInnerText
+
+// cache in the <tr> node the concatenation of the innerTexts of its cells
+function plekit_tr_text (tr) {
+ // if cached, use it
+ if (tr['text_to_match']) return tr['text_to_match'];
+ // otherwise compute it
+ var text="";
+ var cells=tr.cells;
+ for (var i=0; i<cells.length; i++)
+ text += getInnerText(cells[i]) + " ";
+ text = text.strip().toLowerCase();
+ tr['text_to_match'] = text;