X-Git-Url: http://git.shiar.net/sheet.git/blobdiff_plain/217c6fda0be7b212d58da7c9edaba58dbe6d788c..d2ca80f8d1714a6ea6f8184cfa58b67bf0720f2c:/searchlocal.js diff --git a/searchlocal.js b/searchlocal.js index 8741044..eb284b7 100644 --- a/searchlocal.js +++ b/searchlocal.js @@ -26,6 +26,26 @@ function filtercell(el, set, action) { } } +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; for (var i = 0; i < rows.length; i++) { @@ -47,6 +67,14 @@ function filtertable(query, action) { query = match[2]; } + if (document.querySelector('.b-a-'+query)) { + // column if class b-a-* exists + var match = function(th) { + return new RegExp('-'+query+'\\b').test(th.className); + } + return filtercols(table, match, action || 'toggle'); + } + if (/^[A-Z0-9 ]{2,}$/.test(query)) { // category title if all uppercase var match = function(row) {