Created
May 1, 2010 17:36
-
-
Save asafd1/386513 to your computer and use it in GitHub Desktop.
goto url commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "[email protected]"}, | |
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