From 21c02bb6fd2f83f18a8f3ac9023478e6670aa7f7 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Wed, 8 Dec 2010 00:27:29 +0100 Subject: [PATCH] browser: disable search features dependent on classList --- searchlocal.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/searchlocal.js b/searchlocal.js index 8ac328d..0989971 100644 --- a/searchlocal.js +++ b/searchlocal.js @@ -1,4 +1,5 @@ var filterupdate; +var filtertoggles = document.body.classList !== undefined; function filtercell(el, set, action) { if (set === undefined) return; @@ -20,8 +21,7 @@ function filtercell(el, set, action) { break; case 'filter': el.style.display = set ? '' : 'none'; - if (!Element.prototype.hasOwnProperty('classList')) return; - el.classList.remove('focus'); + if (filtertoggles) el.classList.remove('focus'); break; default: // reset el.classList.remove('focus'); @@ -116,7 +116,7 @@ function newelement(tagname, attrlist, childlist) { for (var name in attrlist) el.setAttribute(name, attrlist[name]); if (childlist) for (var i = 0; i < childlist.length; i++) - el.appendChild(childlist[i]); + if (childlist[i]) el.appendChild(childlist[i]); return el; } @@ -131,10 +131,10 @@ function prependsearch(target) { newelement('input', { type: 'search', name: 'q', - onkeyup: "if (!filterupdate) filterupdate = " + onkeyup: "if (filtertoggles && !filterupdate) filterupdate = " + "window.setTimeout(filtertable, 300, undefined, 'focus')", }), - newelement('input', { + filtertoggles && newelement('input', { type: 'button', value: 'toggle', onclick: "filtertable(this.form.q.value, 'target')", -- 2.30.0