I am using Addon SDK. I am confused on how to pass user input to my addon index.js. I looked at Content Script but it is not exactly what I look for. I have an HTML page that pops up when the user clicks on the Addon button. Here is the HTML code:
<html>
<head>
<style type="text/css" media="all">
textarea {
margin: 10px;
}
body {
background-color:#b3dbfa;
}
</style>
</head>
<body>
<form>
Enter URL: <br>
<input type="text" id="txt-field">
<input type="submit" value="Add">
</form>
</body>
</html>
Once the user clicks add, I need to pass the text that the user entered to my main.js file then I want to store it permanently unless the user deleted it manually. Here is the index.js:
var { ToggleButton } = require('sdk/ui/button/toggle');
var sdkPanels = require("sdk/panel");
var self = require("sdk/self");
var storage = require("sdk/simple-storage");
var button = ToggleButton({
id: "my-button",
label: "my button",
icon: {
"16": "./icon-16.png",
"32": "./icon-32.png",
"64": "./icon-64.png"
},
onChange: handleChange
});
var myPanel = sdkPanels.Panel({
contentURL: "./text-entry.html",
onHide: handleHide
});
function handleChange(state) {
if (state.checked) {
myPanel.show({
position: button
});
}
}
function handleHide() {
button.state('window', {checked: false});
}