rename search URL to prepare for more JSONery
authorMike Shaver <shaver@mozilla.org>
Thu, 17 Feb 2011 20:03:13 +0000
changeset 44 2f3d0f15dd96
parent 43 b5b7850447e9
child 45 9f5840f3a1b0
push id34
push usershaver@mozilla.com
push dateThu, 17 Feb 2011 20:10:49 +0000
rename search URL to prepare for more JSONery
server/static/search.js
server/websocket.js
--- a/server/static/search.js
+++ b/server/static/search.js
@@ -6,17 +6,17 @@ var results;
     $("#keywords").focus();
   });
 
   function sendmsg(){
     var terms = $("#keywords").val();
     if ("console" in window) console.log("terms: |" + terms + "|");
 
     var xhr = new XMLHttpRequest();
-    xhr.open("GET", "/json?" + encodeURI(terms), true);
+    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>");
 
--- a/server/websocket.js
+++ b/server/websocket.js
@@ -118,17 +118,17 @@ function handleRequest(req, res)
             fs.createReadStream(pathname.substr(1), { flags: 'r', bufferSize: 4*1024 }).
                 addListener('data', function(chunk) { res.write(chunk); }).
                 addListener('end', res.end.bind(res)).
                 addListener('error', function (err) { util.log(err); send404(); });
             return;
         });
     }
     
-    if (req.method == "GET" && pathname == "/json") {
+    if (req.method == "GET" && pathname == "/search") {
         terms = decodeURIComponent(urlx.query);
         res.writeHead(200, {'Content-Type': 'text/plain'});
         runSearch(terms, function (data) { res.write(data); res.end(); });
         return;
     }
     
     // fall through to socket.io's handling
 }