Shift-click to refine (too many accidental clicks).
authorMike Shaver <shaver@mozilla.org>
Thu, 17 Feb 2011 20:08:57 +0000
changeset 45 9f5840f3a1b0
parent 44 2f3d0f15dd96
child 46 81a637791dcf
push id34
push usershaver@mozilla.com
push dateThu, 17 Feb 2011 20:10:49 +0000
Shift-click to refine (too many accidental clicks). Don't split on hyphen, because the index doesn't.
server/static/search.js
--- a/server/static/search.js
+++ b/server/static/search.js
@@ -13,17 +13,17 @@ var results;
     var xhr = new XMLHttpRequest();
     xhr.open("GET", "/search?" + encodeURI(terms), true);
     xhr.onreadystatechange = function() {
         if (xhr.readyState != 4 || xhr.status != 200)
             return;
         var results = JSON.parse(xhr.responseText);
         var div = $("#matchingbugs");
         div.html(results.bugs.length + " results for '" + $("#keywords").val() + "' in " +  (Date.now() - xhr.sendTime) + " (total)/" +
-                 results.times.server + " (server)/" + results.times.redis + " (redis) ms<br><i>Click words to refine search</i><br>");
+                 results.times.server + " (server)/" + results.times.redis + " (redis) ms<br><i>Shift-click words to refine search</i><br>");
 
         results.bugs.forEach(function (v) { div.append("<a href='https://bugzilla.mozilla.org/show_bug.cgi?id=" + v.id + "'>" + v.id + "</a>: ");
         div.append(document.createTextNode(v.summary)); div.append("<br>"); });
         if (results.hasMore)
             div.append("<br>(Showing " + results.bugs.length + " of " + results.totalResults + " results)<br>");
         };
     xhr.sendTime = Date.now();
     xhr.send(null);
@@ -50,17 +50,17 @@ var results;
 
   if (location.hash) {
       $("#keywords").val(decodeURIComponent(location.hash.substring(1)));
       sendmsg();
   }
 
   var findWord = (function() {
     function isChar(c){
-      return 'A' <= c && c <= 'z';
+      return ('A' <= c && c <= 'z') || c == '-';
     }
 
     return function(text, offset) {
       if (!text || text.length <= offset) {
         return '';
       }
 
       var preoffset = offset;
@@ -73,19 +73,18 @@ var results;
         postoffset++;
       }
 
       return text.substring(preoffset, postoffset + 1) || '';
     };
   })();
 
   $('body').bind('click', function(e) {
-    if (e.target.nodeName !== 'DIV') {
+    if (e.target.nodeName !== 'DIV' || !e.shiftKey)
       return;
-    }
 
     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;
       });