Created
January 2, 2012 08:35
-
-
Save lyhcode/1549891 to your computer and use it in GitHub Desktop.
Yahoo! Translate Sample for Mozilla Add-on Builder
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
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