Skip to content

Instantly share code, notes, and snippets.

@wbamberg
Last active December 15, 2015 05:08
Show Gist options
  • Save wbamberg/5206280 to your computer and use it in GitHub Desktop.
Save wbamberg/5206280 to your computer and use it in GitHub Desktop.
/****data/page.html*******/
<html>
<head></head>
<body>
<input id="fileBrowser" type="file"/>
</body>
</html>
/******data/script.js*******/
var fileBrowser = document.getElementById("fileBrowser");
fileBrowser.addEventListener("change", function() {
self.port.emit("file-selected", fileBrowser.value);
}, false);
/*******lib/main.js******/
var data = require("sdk/self").data;
require("tabs").open({
url: data.url("page.html"),
onReady: function(tab) {
worker = tab.attach({
contentScriptFile: data.url("script.js")
});
initializeWorker(worker);
}
});
function initializeWorker(worker) {
worker.port.on("file-selected", function(file) {
console.log(file);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment