Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@lyhcode
Created January 2, 2012 08:35
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 lyhcode/1549891 to your computer and use it in GitHub Desktop.
Save lyhcode/1549891 to your computer and use it in GitHub Desktop.
Yahoo! Translate Sample for Mozilla Add-on Builder
var contextMenu = require("context-menu");
var panel = require("panel");
exports.main = function(options, callbacks) {
console.log(options.loadReason);
var menuItem = contextMenu.Item({
label: "What's this?",
context: contextMenu.SelectionContext(),
contentScript: 'self.on("click", function () {' +
' var text = window.getSelection().toString();' +
' self.postMessage(text);' +
'});',
onMessage: function (item) {
console.log('looking up "' + item + '"');
lookup(item);
}
});
};
function lookup(item) {
var panel1 = panel.Panel({
width: 320,
height: 240,
contentURL: "http://tw.dictionary.yahoo.com/dictionary?p="+item
});
panel1.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment