Prev: Getting there....
Next: pink ghd kiss
From: Mel Smith on 10 Aug 2010 17:11 Hi Richard: I implemented your suggestions (i.e., a second Timer, and using the visibility property); This new version (relevant portions pasted below) works correctly on IE7 and Chrome and (almost correctly) on Firefox. (The timimng of FF seems a little bit 'off'' but will investigate further over next several days It took me a bit of testing (i.e., about two frustrating hours) to get the positioning of the showarning(true[false]) function calls. (btw, the ciurrent table I'm searching is 5,211 rows x 5 columns. The actual production table will have approx 14000 rows. On my old Dell Laptop with SUSE Linux and Firefox and 2 Gig of RAM, the searching portion is *very* slow ! I have to learn more how to optimize the searchtable() ode. ) Thanks again for the guidance ! -Mel Smith ****************************************** function startTimer() { if (TIMER) { clearTimeout(TIMER); } TIMER = setTimeout(search, 600); // waits 6/10 second (until user has apparently stopped typing) } function search() { showarning(true) ; // show 'Searching Please Wait ...' message here if (TIMER2) { clearTimeout(TIMER2) ; } TIMER2 = setTimeout(tablesearch,800); // call the actual table search in 8/10 second after warning message displays } function tablesearch() { var i,tr,tds,td ; var term = SEARCH_INPUT.value.toLowerCase(); // skip first few rows // Have to find a way to speed up this long search loop! for (i = SKIP_ROW_COUNT; i < nrows; i++) { tr = rows[i]; // hide row if it doesn't contain the search term tds = tr.getElementsByTagName("td"); if (!tds || tds.length < 2) continue; td = tds[SEARCH_COLUMN] ; tr.style.display = (term == "" || doesNodeContain(td, term)) ? "" : "none"; } clearTimeout(TIMER2) ; showarning(false) ; // hide the 'searching' message again } function doesNodeContain(node, term) { if (node.nodeType == TEXT_NODE && node.nodeValue.toLowerCase().indexOf(term) >= 0) { return true; } var child = node.firstChild; while (child) { if (doesNodeContain(child, term)) { return true; } child = child.nextSibling; } return false; } function showarning(onoff) { var el = document.getElementById("ishomsg") ; if (onoff) { el.style.visibility = "visible" ; // show the 'searching' message } else { el.style.visibility = "hidden"; // hide it now } }
|
Pages: 1 Prev: Getting there.... Next: pink ghd kiss |