focus after click-update; fix space-dropping on typed entry
authorMike Shaver <shaver@mozilla.org>
Wed, 09 Feb 2011 04:47:46 +0000
changeset 41 673ed6975d58
parent 40 b3ab76d708dc
child 42 ad1a64fce944
push id32
push usershaver@mozilla.com
push dateWed, 09 Feb 2011 04:49:16 +0000
focus after click-update; fix space-dropping on typed entry
server/static/search.js
--- a/server/static/search.js
+++ b/server/static/search.js
@@ -3,16 +3,17 @@ var results;
   $("#keywords").focus();
 
   $(window).bind("focus", function(){
     $("#keywords").focus();
   });
 
   function sendmsg(){
     var terms = $("#keywords").val();
+    if ("console" in window) console.log("terms: |" + terms + "|");
     location.hash = "#" + encodeURIComponent(terms);
     var xhr = new XMLHttpRequest();
     xhr.open("GET", "/json?" + encodeURI(terms), true);
     xhr.onreadystatechange = function() {
         if (xhr.readyState != 4 || xhr.status != 200)
             return;
         var results = JSON.parse(xhr.responseText);
         var div = $("#matchingbugs");
@@ -30,17 +31,17 @@ var results;
 
   $("#submitton").bind("click", sendmsg);
 
   $(window).bind("hashchange", function() {
       $("#keywords").val(decodeURIComponent(location.hash.substring(1)));
       sendmsg();      
   });
   
-  $("#keywords").bind("keydown", function(e){
+  $("#keywords").bind("keyup", function(e){
 
  if(e.keyCode == 32 || e.keyCode == 13 ||
    (e.keyCode == 8 && $("#keywords").val().substr(-2, 1) == " "))
 {
       sendmsg();
   }});
 
   if (location.hash) {
@@ -80,16 +81,17 @@ var results;
     var s = window.getSelection();
     if (s.anchorNode && s.anchorNode.nodeValue) {
       var word = findWord(s.anchorNode.nodeValue, s.focusOffset);
       $("#keywords").val(function(index, value) {
         return word.length ? value + ' ' + word : value;
       });
 
       sendmsg();
+      $("#keywords").focus();
     }
   });
 
   function log(data){
     $("#matchingbugs").html(data);
   };
 
 });