Mercurial > my-ubiquity-commands
view chromeless-browsing/chromeless.js @ 8:abe54fcda16c
Suggestions for the 'go' command now show up in the preview area rather than as noun suggestions, since async noun suggestions aren't very mature and suggestions don't have much display room.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Fri, 27 Mar 2009 17:31:05 -0700 |
parents | c89423660272 |
children | 6b955e36a9e9 |
line wrap: on
line source
CmdUtils.CreateCommand( {name: "go", takes: {"search terms": /.*/}, preview: function(pblock, dobj) { if (dobj.text.length == 0) { pblock.innerHTML = "<b>Please enter a search term</b>"; return; } var history = Cc["@mozilla.org/autocomplete/search;1?name=history"] .createInstance(Ci.nsIAutoCompleteSearch); var observer = { onSearchResult: function onSearchResult(search, result) { if (result.searchResult == result.RESULT_SUCCESS || result.searchResult == result.RESULT_SUCCESS_ONGOING) { var html = ""; for (var i = 0; i < result.matchCount; i++) { var image = result.getImageAt(i); var title = result.getCommentAt(i); var url = result.getValueAt(i); if (!title) title = url; if (image.indexOf("moz-anno:favicon:") == 0) image = image.slice("moz-anno:favicon:".length); else image = ""; html += '<div class="gresult">'; if (image) html += ('<img src="' + Utils.escapeHtml(image) + '"/> '); html += ('<a href="' + Utils.escapeHtml(url) + '">' + Utils.escapeHtml(title) + "</a>"); html += ('<div class="gresult-url">' + Utils.escapeHtml(url) + '</div'); html += "</div>"; } pblock.innerHTML = html; } } }; history.startSearch( dobj.text, "", null, observer ); pblock.addEventListener( "preview-change", function onPreviewChange() { pblock.removeEventListener("preview-change", onPreviewChange, false); history.stopSearch(); }, false); }, execute: function(dobj) { if (dobj.text) Utils.openUrlInBrowser(dobj.text); else displayMessage("No URL was provided."); }} ); function cmd_show_tabs() { var content = context.chromeWindow.document.getElementById("appcontent"); var browser = content.firstChild; var tabs = browser.tabContainer; tabs.style.height = "25px"; tabs.style.marginTop = "0px"; } function cmd_hide_tabs() { var content = context.chromeWindow.document.getElementById("appcontent"); var browser = content.firstChild; var tabs = browser.tabContainer; tabs.style.height = "0px"; tabs.style.marginTop = "-500px"; }