Skip to content

Instantly share code, notes, and snippets.

@OzuYatamutsu
Forked from Schnubby/x
Created May 4, 2011 13:20
Show Gist options
  • Save OzuYatamutsu/955193 to your computer and use it in GitHub Desktop.
Save OzuYatamutsu/955193 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.com/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.com/images?imgcolor=" + color + "&q=" + searching
if(color.length < 1) {
var searchUrl = "http://images.google.com/images?q=" + searching;
}
Utils.openUrlInBrowser(searchUrl);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment