Mercurial > my-ubiquity-commands
comparison chromeless-browsing/chromeless.js @ 9:6b955e36a9e9
The 'go' command now reports if there are no search results.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Fri, 27 Mar 2009 17:38:30 -0700 |
parents | abe54fcda16c |
children | 8e00d50976d9 |
comparison
equal
deleted
inserted
replaced
8:abe54fcda16c | 9:6b955e36a9e9 |
---|---|
1 CmdUtils.CreateCommand( | 1 CmdUtils.CreateCommand( |
2 {name: "go", | 2 {name: "go", |
3 takes: {"search terms": /.*/}, | 3 takes: {"search terms": /.*/}, |
4 preview: function(pblock, dobj) { | 4 preview: function(pblock, dobj) { |
5 if (dobj.text.length == 0) { | 5 if (dobj.text.length == 0) { |
6 pblock.innerHTML = "<b>Please enter a search term</b>"; | 6 pblock.innerHTML = "<b>Please enter a search term.</b>"; |
7 return; | 7 return; |
8 } | 8 } |
9 | 9 |
10 var history = Cc["@mozilla.org/autocomplete/search;1?name=history"] | 10 var history = Cc["@mozilla.org/autocomplete/search;1?name=history"] |
11 .createInstance(Ci.nsIAutoCompleteSearch); | 11 .createInstance(Ci.nsIAutoCompleteSearch); |
12 | 12 |
13 var observer = { | 13 var observer = { |
14 onSearchResult: function onSearchResult(search, result) { | 14 onSearchResult: function onSearchResult(search, result) { |
15 if (result.searchResult == result.RESULT_SUCCESS || | 15 if (result.searchResult == result.RESULT_NOMATCH) { |
16 pblock.innerHTML = "<b>No matches were found.</b>"; | |
17 } else if (result.searchResult == result.RESULT_NOMATCH_ONGOING) { | |
18 pblock.innerHTML = "<b>Please wait...</b>"; | |
19 } else if (result.searchResult == result.RESULT_SUCCESS || | |
16 result.searchResult == result.RESULT_SUCCESS_ONGOING) { | 20 result.searchResult == result.RESULT_SUCCESS_ONGOING) { |
17 var html = ""; | 21 var html = ""; |
18 for (var i = 0; i < result.matchCount; i++) { | 22 for (var i = 0; i < result.matchCount; i++) { |
19 var image = result.getImageAt(i); | 23 var image = result.getImageAt(i); |
20 var title = result.getCommentAt(i); | 24 var title = result.getCommentAt(i); |