Fandom

The Sysadmin Wiki

Ubiquity/Google search

< Ubiquity

157pages on
this wiki
Add New Page
Talk0 Share

This page should present you the Ubiquity command, if you have the extension installed and you don't have the command already.

Source code Edit

The code is saved in a .js file on this wiki. For security reasons, the .js files on the wiki are only editable by users with sysop access.

CmdUtils.makeSearchCommand({
 names: ["g"],
 url: "http://www.google.com/search?q={QUERY}",
 license: "Derived from the built-in feeds in Ubiquity. Somebody please update the license here.",
 icon: "chrome://ubiquity/skin/icons/google.ico",
 description: "Searches Google for your words.",
 help: "You can use the keyboard shortcut ctrl + alt + number to open one " +
       "of the Google results shown in the preview.",
 preview: function(pblock, {object}) {
   var searchTerm = object.text;
   // Don't even display any text before fetching search results,
   // since the results come back nearly instantaneously. In the
   // future, we can display a throbber.
   if(searchTerm.length < 1) {
     pblock.innerHTML = _("Searches Google for your words.");
     return;
   }
   
   var url = "http://ajax.googleapis.com/ajax/services/search/web";
   var params = { v: "1.0", q: searchTerm };
   
   CmdUtils.previewGet( pblock, url, params, function(data) {
     var numToDisplay = 3;
     var results = data.responseData.results.splice( 0, numToDisplay );
     
     //for access keys
     for(var i=0;i<results.length;i++){
       var result = results[i];
       result.key = i+1;
     }
     
     var noResultsMessage = _("Your search - ${searchTerm} - did not match any documents.",
                             {searchTerm:searchTerm});
     var tipsMessage = _("Tip: You can go to any result in this preview by pressing control, alt, and the result number at the same time.");
     
     pblock.innerHTML = CmdUtils.renderTemplate(
       jQuery("#google-search", feed.dom).html(),
         { results:results,
           searchTerm:searchTerm,
           noResultsMessage:noResultsMessage,
           tipsMessage:tipsMessage
         });
     }, "json");
 }
});


Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.