# HG changeset patch # User Maria Emerson # Date 1216834190 25200 # Node ID 5388c9950377d87ac929c7982fa786daf648be76 # Parent 4d223fd05668f365006e2cebc0b99f1cf83f4a2e preview appears for main input box, timed diff -r 4d223fd05668 -r 5388c9950377 preview/hip.css --- a/preview/hip.css Tue Jul 22 15:39:31 2008 -0700 +++ b/preview/hip.css Wed Jul 23 10:29:50 2008 -0700 @@ -1,3 +1,9 @@ +#searchbar { + display: none !important; +} + + + #search-box { border: 1px solid #000000; background: #272727; diff -r 4d223fd05668 -r 5388c9950377 preview/hip.js --- a/preview/hip.js Tue Jul 22 15:39:31 2008 -0700 +++ b/preview/hip.js Wed Jul 23 10:29:50 2008 -0700 @@ -77,7 +77,11 @@ function makeSuggestionHtml( tagName, list, hilitedNumber ) { var result = ""; - for (var i = 0; i < list.length; i++) { + if (hilitedNumber == -1) { + result += "
"; + } + + for (var i = 0; i < list.length; i++) { if ( i == hilitedNumber ) { result += "<" + tagName + " class=\"hilited suggestion\">" + list[i] + ""; result += "
" @@ -266,7 +270,31 @@ } } - +var timeoutId; +var doneTyping = true; +function timeInput ( event ) { + window.clearTimeout(timeoutId); + doneTyping = false; + timeoutId = setTimeout("afterTimeout()", 250 ); +} +function afterTimeout() { + doneTyping = true; + var input = $("#search-box").val(); + var object = getSelection(); + if (!object && input.match(" ")) { + object = input.substring(input.indexOf(" ")); + } + if (object && object != " ") { + if (input.match("google")) { + $("#preview-pane").show(); + setPreview("google", object); + } + else if (input.match("map")) { + $("#preview-pane").show(); + setPreview("map", object); + } + } +} function updateDisplay( number ) { var suggestions = gQs.getSuggestionsAsHtml(); @@ -279,18 +307,25 @@ // PREVIEW PANE STUFF // This should be done based on command and sentence structure above, not string parsing... yuck if (selection != "") { - var curSuggestion = suggestions[hilitedSuggestion]; - if (curSuggestion) { - var object = curSuggestion.substring(curSuggestion.indexOf(" ")); - - if (curSuggestion.match("google") && !object.match("needarg")) { - setPreview("google", object); + if (hilitedSuggestion == -1) { + if (!doneTyping) + window.clearTimeout(timeoutId); + $("#preview-pane").hide(); + } + else { + var curSuggestion = suggestions[hilitedSuggestion]; + if (curSuggestion) { + var object = curSuggestion.substring(curSuggestion.indexOf(" ")); + + if (curSuggestion.match("google") && !object.match("needarg")) { + setPreview("google", object); + } + else if (curSuggestion.match("map") && !object.match("needarg")) { + setPreview("map", object); + } + else + $("#preview-pane").height("0px"); } - else if (curSuggestion.match("map") && !object.match("needarg")) { - setPreview("map", object); - } - else - $("#preview-pane").height("0px"); } } @@ -343,6 +378,7 @@ $("#status-line").html( "All you gotta do is rub that lamp." ); $("#search-box").focus(); $("#search-box").keyup( searchBoxQuery ); + $("#search-box").keyup( timeInput ); $("#autocomplete-popup").css( "width", $("#search-box").css("width")