X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/ff13359d0999d7b29d1326bc3bf63008821f53b6..ec6dc09f261b1810396d7a6d69e8d883dff6657d:/searchlocal.js diff --git a/searchlocal.js b/searchlocal.js index 4de1423..f0036a6 100644 --- a/searchlocal.js +++ b/searchlocal.js @@ -1,7 +1,8 @@ function filtertable(query, action) { var rows = document.getElementsByTagName('TBODY')[0].rows; for (var i = 0; i < rows.length; i++) { - var keep = rows[i].cells[1].textContent.match(query, query.match(/[A-Z]/) ? '' : 'i'); + var keep = query.match(/^[A-Z0-9 ]{2,}$/) ? rows[i].cells[0].title.match(query, 'i') + : rows[i].cells[1].textContent.match(query, query.match(/[A-Z]/) ? '' : 'i'); switch (action) { case 'focus': rows[i].classList[keep ? 'add' : 'remove'](action); @@ -11,6 +12,7 @@ function filtertable(query, action) { break; case 'filter': rows[i].style.display = keep ? '' : 'none'; + if (!Element.prototype.hasOwnProperty('classList')) continue; // continue default: // reset rows[i].classList.remove('focus'); @@ -33,7 +35,7 @@ function prependsearch(target) { target.parentNode.insertBefore(newelement( 'form', { id: 'search', - class: 'aside', + 'class': 'aside', onsubmit: "filtertable(this.q.value, 'filter'); this.q.value = ''; return false", }, [