browser: delay automatic search preview
[sheet.git] / searchlocal.js
index 5d7493b100616134bddd693d6cdef245010b2974..6c37fc901362c7f2fbb5b9a4c3d2138e8cb729a6 100644 (file)
@@ -1,3 +1,5 @@
+var filterupdate;
+
 function filtercell(el, set, action) {
        switch (action) {
                case 'focus':
 function filtercell(el, set, action) {
        switch (action) {
                case 'focus':
@@ -54,6 +56,8 @@ function filterrows(table, match, action) {
 }
 
 function filtertable(query, action) {
 }
 
 function filtertable(query, action) {
+       filterupdate = undefined;
+       if (query === undefined) query = document.getElementById('search').q.value;
        var table = document.getElementsByTagName('TABLE')[0];
 
        if (!action) {
        var table = document.getElementsByTagName('TABLE')[0];
 
        if (!action) {
@@ -128,7 +132,8 @@ function prependsearch(target) {
                        newelement('input', {
                                type: 'search',
                                name: 'q',
                        newelement('input', {
                                type: 'search',
                                name: 'q',
-                               onkeyup: "filtertable(this.value, 'focus')",
+                               onkeyup: "if (!filterupdate) filterupdate = "
+                                       + "window.setTimeout(filtertable, 300, undefined, 'focus')",
                        }),
                        newelement('input', {
                                type: 'button',
                        }),
                        newelement('input', {
                                type: 'button',