-
-
Save vilterp/60410 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
CmdUtils.CreateCommand({ | |
name: "gcal", | |
takes: {"expression" noun_arb_text}, | |
description: "Uses Google Calculator to evaluate an expression", | |
icon: "http://www.google.com/favicon.ico/", | |
homepage: "http://davanum.wordpress.com/", | |
author: { name: "Davanum Srinivas", email: "davanum AT gmail.com"}, | |
help: "Try it out: issue "calc 22/7 - 1".", | |
preview: function(pblock, statusText) { | |
if (statusText.text != "") { | |
var url = 'http://www.google.com/search?q=' + encodeURI(statusText.text).replace("+", "%2B"); | |
jQuery.get(url, null, function(page) { | |
result = page.match(/<h2 class=r><font size=\+1><b>.*<\/b><\/h2>/i); | |
pblock.innerHTML = 'Result: <h3> ' + (result == null ? "" : result) + '</h3>'; | |
}); | |
} | |
}, | |
execute: function(statusText) { | |
Utils.openUrlInBrowser('http://www.google.com/search?q=' + encodeURI(statusText.text).replace("+", "%2B")); | |
} | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment