-
-
Save bbbco/19153 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
CmdUtils.CreateCommand({ | |
name: "websource", | |
homepage: "http://www.briandgoad.com/blog/", | |
author: { name: "Brian D. Goad", email: "[email protected]"}, | |
description: "Checks Websource.It for a comparison between two terms throughout the web.", | |
help: "Compares the popularity of two terms using Websource.It Example: try 'websource google and yahoo'", | |
takes: {"first": noun_arb_text}, | |
modifiers: {and: noun_arb_text}, | |
preview: function( pblock, first, mods ) { | |
var msg = "Compares the popularity of two or more (a limit of 5) terms seperated by 'and'."; | |
msg += "<br /> Example: try '<i>google and yahoo</i>'"; | |
msg += "<br />"; | |
if (first && first.text) { | |
msg += first.text; | |
} | |
if (mods.and && mods.and.text){ | |
msg += " and " + mods.and.text; | |
} | |
pblock.innerHTML = CmdUtils.renderTemplate( msg ); | |
}, | |
execute: function(first, mods) { | |
if (mods.and && mods.and.text) { | |
var url = "http://websource.it/search/"; | |
var query = url + first.text + '/' | |
if (mods.and.text){ | |
if(mods.and.text.match("and")){ | |
var pdString = mods.and.text.split(" and ", 4); | |
var t = 0; | |
for (t; t<=pdString.length-1; t++) { | |
query += pdString[t] + '/'; | |
} | |
} else { | |
query += mods.and.text; | |
} | |
} | |
Utils.openUrlInBrowser(query); | |
} else { | |
displayMessage("You must include two (or more) entries"); | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment