browser: disable search features dependent on classList
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 7 Dec 2010 23:27:29 +0000 (00:27 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Wed, 15 Dec 2010 21:40:44 +0000 (22:40 +0100)
searchlocal.js

index 8ac328dfe200c1fbb956ea17913779b9125989a3..09899710cac5731d1276aa1ee538f4154a60985f 100644 (file)
@@ -1,4 +1,5 @@
 var filterupdate;
 var filterupdate;
+var filtertoggles = document.body.classList !== undefined;
 
 function filtercell(el, set, action) {
        if (set === undefined) return;
 
 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';
                        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');
                        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++)
        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;
 }
 
        return el;
 }
 
@@ -131,10 +131,10 @@ function prependsearch(target) {
                        newelement('input', {
                                type: 'search',
                                name: 'q',
                        newelement('input', {
                                type: 'search',
                                name: 'q',
-                               onkeyup: "if (!filterupdate) filterupdate = "
+                               onkeyup: "if (filtertoggles && !filterupdate) filterupdate = "
                                        + "window.setTimeout(filtertable, 300, undefined, 'focus')",
                        }),
                                        + "window.setTimeout(filtertable, 300, undefined, 'focus')",
                        }),
-                       newelement('input', {
+                       filtertoggles && newelement('input', {
                                type: 'button',
                                value: 'toggle',
                                onclick: "filtertable(this.form.q.value, 'target')",
                                type: 'button',
                                value: 'toggle',
                                onclick: "filtertable(this.form.q.value, 'target')",