Skip to content

Instantly share code, notes, and snippets.

@Schnubby Schnubby/x
Created Mar 26, 2009

Embed
What would you like to do?
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
You can’t perform that action at this time.