Skip to content

Instantly share code, notes, and snippets.

@Schnubby
Created March 26, 2009 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Schnubby/85963 to your computer and use it in GitHub Desktop.
Save Schnubby/85963 to your computer and use it in GitHub Desktop.
Ubiquity: Google Images search including search for colors
noun_type_color = new CmdUtils.NounType( "Color",
["red", "orange", "yellow", "green", "blue", "black", "white", "grey", "brown", "purple", "magenta", "indigo", "pink"] );
CmdUtils.CreateCommand({
name: "google-images",
synonyms: ["pic", "image", "color"],
takes: {search: noun_arb_text},
modifiers: {in: noun_type_color},
author: {name: "Christian Roth", email: "schnubby@traces-of-nuts.eu"},
icon: "http://www.google.de/favicon.ico",
description: "Searches Google Images , in a given color.",
preview: function(pblock, directObject, mods) {
var color = mods.in.text;
var searchterm = directObject.text;
if(searchterm.length < 1) {
pblock.innerHTML = "Searches Google for images.";
return;
}
if(color.length < 1) {
pblock.innerHTML = "Searches Google Images for <b>" + searchterm + "</b>.";
return;
}
pblock.innerHTML = "Searches Google Images for <b>" + searchterm + "</b> in <b>" + color + "</b>."
},
execute: function(directObject, mods, search) {
var color = mods.in.text;
var searching = directObject.text;
var searchUrl = "http://images.google.de/images?imgcolor=" + color + "&q=" + searching
if(color.length < 1) {
var searchUrl = "http://images.google.de/images?q=" + searching;
}
Utils.openUrlInBrowser(searchUrl);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment