Skip to content

Instantly share code, notes, and snippets.

@ecarnevale
Created March 11, 2009 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecarnevale/77483 to your computer and use it in GitHub Desktop.
Save ecarnevale/77483 to your computer and use it in GitHub Desktop.
var noun_type_destination = new CmdUtils.NounType( "destination", ['clipboard', 'selected text', 'displayed message'] );
CmdUtils.CreateCommand({
name: "lmgtfy",
takes: {"Something you have to search about because your friends are lazy": noun_arb_text},
preview: function(pblock, query) {
searchQuery = jQuery.trim(query.text);
if (searchQuery.length < 1) {
pblock.innerHTML = "Gives you a link to a lmgtfy.com search.";
return;
}
pblock.innerHTML = "";
},
modifiers: {to: noun_type_destination},
homepage: "http://lmgtfy.com/",
author: { name: "Emanuel Carnevale", email: "me AT myName myFamilyName DOT com"},
description: "Returns a link to a querysearch at lmgtfy.com",
help: "You can send the result to the clipboard adding <i>to clipboard</i> after the command.",
execute: function(query, destination) {
var baseURL = "http://lmgtfy.com/?q=";
var newURL = baseURL + query.text;
var toDestination = destination.to.text || "selected text";
switch (toDestination){
case "clipboard":
CmdUtils.copyToClipboard(newURL);
displayMessage(newURL + " successfully copied to the clipboard");
break;
case "selected text":
CmdUtils.setSelection(newURL);
break;
default : CmdUtils.setSelection(newURL);
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment