Created
January 15, 2009 21:48
-
-
Save netsuke/47647 to your computer and use it in GitHub Desktop.
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
//Ubiquity command to: | |
//1. search for an article on How Stuff Works or | |
//2. look at a random article from How Stuff Works | |
CmdUtils.CreateCommand({ | |
name:"hsw", | |
takes:{"searchTerm":noun_arb_text}, | |
icon:"http://www.howstuffworks.com/favicon.ico", | |
author: { name: "Nanya Bizuidenhoud", email: "netsuke87@yahoo.com"}, | |
description: "Get a random article from <a href=\"http://www.howstuffworks.com\">Howstuffworks.com</a> howstuffworks or search for a given article", | |
help: "Type r or R for a random article or simply enter a keyword to search for a specific article", | |
preview: function(pblock,searchTerm) | |
{ | |
pblock.innerHTML="Type r or R for a random article \n or search howstuffworks.com for: "+searchTerm.text; | |
}, | |
execute: function(searchTerm) | |
{ | |
if(searchTerm.text==="r" || searchTerm.text==="R") | |
{ | |
var rand="http://health.howstuffworks.com/random-article"; | |
Utils.openUrlInBrowser(rand); | |
displayMessage( "Retrieving random article..." ); | |
} | |
else | |
{ | |
var site="http://www.howstuffworks.com/search.php?terms="; | |
Utils.openUrlInBrowser(site+searchTerm.text+"&x=0&y=0"); | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment