Created
January 16, 2009 20:05
-
-
Save jackowayed/48091 to your computer and use it in GitHub Desktop.
This file contains 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
//"<table//"<table//"<table//"<table//"<table//"<table//"<table//"<table//"<table//"<table//"<table//"<table//"<table | |
border="1"><tr><td>hello</td><td><world></td></tr><tr><td>1</td><td>2</td></tr></table>", | |
//"Displays a <i>salutary</i> greeting to the planet.", | |
CmdUtils.CreateCommand({ | |
name: "hello-world", | |
preview: "hello", | |
execute: function() { | |
displayMessage( "Hello, World!" ); | |
} | |
}) | |
CmdUtils.CreateCommand({ | |
name: "date", | |
execute: function() { | |
var date = new Date(); | |
CmdUtils.setSelection( date.toLocaleDateString() ); | |
} | |
}) | |
makeSearchCommand({ | |
name: "rubyforge", | |
author: {name: "Daniel Jackoway", email: "jackowayed@gmail.com", twitter: "jackowayed"}, | |
homepage: "http://jackowayed.wordpress.com/", | |
takes: {"Query": noun_arb_text}, | |
license: "MIT", | |
url: "http://rubyforge.org/search/?type_of_search=soft&Search=Search&words={QUERY}", | |
description: "searches rubyforge.org, a rubygem hosting site", | |
help: "Type 'rubyforge foo bar' to search rubyforge projects for 'foo bar'", | |
preview: function(pblock, directObject){ | |
if (directObject.text<1){pblock.innerHTML = "Search <b>RubyForge</b>"; return;} | |
jQuery.get(this.url.replace("{QUERY}", directObject.text), function(doc){ | |
var tempElement = CmdUtils.getHiddenWindow().document.createElementNS("http://www.w3.org/1999/xhtml", "div"); | |
tempElement.innerHTML = doc.replace(/href=\"\/, "href=\"http://rubyforge.org/"); | |
results = jQuery("table[cellspacing='2']:first", tempElement); | |
pblock.innerHTML=results.html(); | |
}) | |
} | |
/*execute: function(directObject) { | |
Utils.openUrlInBrowser(this.url.replace("{QUERY}",directObject.text)); | |
}*/ | |
}) | |
//https://ubiquity.mozilla.com/herd/all-feeds/eb1376ef1b314f5b3bfcd595c94e5c6e77149b01-20704/ | |
// Firefox Addons Begin | |
CmdUtils.CreateCommand({ | |
name: "firefox addons", | |
icon: "https://addons.mozilla.org/favicon.ico", | |
takes: {"Query": noun_arb_text}, | |
preview: function(pblock, directObject) { | |
searchText = jQuery.trim(directObject.text); | |
if(searchText.length < 1) { | |
var previewTemplate = "Searches for Firefox Addons"; | |
return; | |
} | |
var previewTemplate = "Searches Firefox Addons for ${query}"; | |
var previewData = {query: searchText}; | |
pblock.innerHTML = CmdUtils.renderTemplate(previewTemplate, previewData); | |
}, | |
execute: function(directObject) { | |
var url = "https://addons.mozilla.org/en-US/firefox/search/?q={QUERY}" | |
var query = directObject.text | |
var urlString = url.replace("{QUERY}", query); | |
Utils.openUrlInBrowser(urlString); | |
} | |
}) | |
// Firefox Addons End | |
/* This is a template command */ | |
CmdUtils.CreateCommand({ | |
name: "example", | |
icon: "http://example.com/example.png", | |
homepage: "http://example.com/", | |
author: { name: "Your Name", email: "you@example.com"}, | |
license: "GPL", | |
description: "A short description of your command", | |
help: "how to use your command", | |
takes: {"input": noun_arb_text}, | |
preview: function( pblock, input ) { | |
var template = "Hello ${name}"; | |
pblock.innerHTML = CmdUtils.renderTemplate(template, {"name": "World!"}); | |
}, | |
execute: function(input) { | |
CmdUtils.setSelection("You selected: "+input.html); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment