+function filtercell(el, set, action) {
+ switch (action) {
+ case 'focus':
+ el.classList[set ? 'add' : 'remove'](action);
+ break;
+ case 'target':
+ if (set) el.classList.toggle(action);
+ break;
+ case 'remove':
+ if (set) el.style.display = 'none';
+ break;
+ case 'add':
+ if (set) el.style.display = '';
+ break;
+ case 'toggle':
+ if (set) el.style.display = el.style.display == 'none' ? '' : 'none';
+ break;
+ case 'filter':
+ el.style.display = set ? '' : 'none';
+ if (!Element.prototype.hasOwnProperty('classList')) return;
+ el.classList.remove('focus');
+ break;
+ default: // reset
+ el.classList.remove('focus');
+ el.classList.remove('target');
+ }
+}
+
+function filtercols(table, match, action) {
+ var matchloc;
+ for (var y = 0; y < table.rows.length; y++) {
+ var loc = 0;
+ for (var x = 0; x < table.rows[y].cells.length; x++) {
+ var cell = table.rows[y].cells[x];
+ if (y == 0) {
+ if (match(cell)) {
+ if (!matchloc) matchloc = [loc];
+ matchloc[1] = loc + cell.colSpan;
+ filtercell(table.children.item(x+2), true, action); // colgroup
+ }
+ }
+ var keep = matchloc && loc >= matchloc[0] && loc < matchloc[1];
+ filtercell(cell, keep, action);
+ loc += cell.colSpan;
+ }
+ }
+}
+
+function filterrows(table, match, action) {
+ var rows = table.tBodies[0].rows;