[Ubiquity] use Google’s built-in calculator function
Here’s a script to plugin google’s calculator. Does conversions too (Try “5 feet in inches” for example).
Here’s the script:
CmdUtils.CreateCommand({
name: "mycalculator",
takes: {"statusText": noun_arb_text},
description: "Calculates the value of a mathematical expression.",
icon: "chrome://ubiquity/content/icons/calculator.png",
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"));
}
})

hey Dav.
how come ubiquity doesnt bring up a popup or something to load these from?
any ideas?
ian holsman
September 2, 2008 at 5:16 pm
ian, I haven’t set up the herd functionality yet.
Davanum Srinivas
September 2, 2008 at 9:01 pm