Commits

Anonymous committed 67192f9

Get refactored search algorithm working

  • Participants
  • Parent commits 8b68c83

Comments (0)

Files changed (1)

packages/tb-autocomplete/lib/main.js

  *
  * ***** END LICENSE BLOCK ***** */
 
-
 var port = 8777;
 var xhr = require("xhr");
 //var tabBrowser = require("tab-browser");
   this._resultList = resultList; 
 } 
 acResult.prototype = {
-  get matchCount() resultList.length,
+  get matchCount() this._resultList.length,
   getValueAt: function(i) {
     return "this is a value";
   },
     let keyword = searchString.toLowerCase();
     
     var req = new xhr.XMLHttpRequest();
-    //req.open("GET", "http://localhost:" + port + "/search-for-messages?string=" 
-    //         + keyword, true);
+    req.open("GET", "http://localhost:" + port + "/search-for-messages?string=" 
+             + keyword, true);
     req.onreadystatechange = function () {
       if (req.readyState == 4) {
-        if(req.status == 200)
+        if(req.status == 200) {
           console.log(req.responseText);  
-        else
-          console.log("Error loading page\n");  
+          var result = new acResult(searchString, 
+            Ci.nsIAutoCompleteResult.RESULT_SUCCESS, [1]);
+        } else {
+          console.log("Error loading page\n");
+          var result = new acResult(searchString, 
+            Ci.nsIAutoCompleteResult.RESULT_FAILURE, []);
+        }
       }
     };
-    //req.send(null);
+    req.send(null);
 
-    let result = new acResult(searchString, 
-                              Ci.nsIAutoCompleteResult.RESULT_SUCCESS,
-                              [1]);
+
     // Inform the listener of the result
     let done = function() listener.onSearchResult(T, result);