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