Created
March 11, 2009 14:21
-
-
Save ecarnevale/77483 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
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