Skip to content

Instantly share code, notes, and snippets.

@asafd1
Created May 1, 2010 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asafd1/386513 to your computer and use it in GitHub Desktop.
Save asafd1/386513 to your computer and use it in GitHub Desktop.
goto url commands
CmdUtils.CreateCommand({
names: ["goto-url", "לך-לכתובת"],
homepage: "http://sites.google.com/site/ubiquityisrael",
author: {name: "Asaf David"},
description: "Opens a new tab with the selected URL",
takes: {"URL": noun_type_url},
preview: function(pblock, url) {
var template = "Open a new tab with " + url.text;
pblock.innerHTML = template;
},
execute: function(url) {
Utils.openUrlInBrowser(url.text);
}
});
//CmdUtils.CreateAlias({names: ["goto-url"], verb: "url-go"});
CmdUtils.CreateCommand({
names: ["feeling-lucky", "יותר-מזל-משכל"],
url: "http://ajax.googleapis.com/ajax/services/search/web",
icon: "http://www.google.com/favicon.ico",
description: "Searches Google (while feeling-lucky) for your words.",
homepage: "http://sites.google.com/site/ubiquityisrael",
author: { name: "Asaf David", email: "asafd1@gmail.com"},
arguments: [
{role: "object", label: 'what', nountype: noun_arb_text}
],
license: "GPL",
preview: function(pblock, args) {
var searchTerm = jQuery.trim( args.object.text );
var params = { v: "1.0", q: searchTerm, btnI: "kudos" };
jQuery.get( this.url, params, function(data) {
var numToDisplay = 1;
var results = data.responseData.results.splice( 0, numToDisplay );
var i = 0;
var text = '<h3>' + (i+1) + '. ' + '<a href="' + results[i].unescapedUrl + '">' + results[i].titleNoFormatting + '</a><br></h3>';
text += results[i].content;
args.object.data = results[i].unescapedUrl;
pblock.innerHTML = text;
}, "json");
},
execute: function(args) {
Utils.openUrlInBrowser(args.object.data);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment