Skip to content

Commit

Permalink
Add settings page
Browse files Browse the repository at this point in the history
- closes #144
- #20
  • Loading branch information
lidel committed Sep 20, 2016
1 parent 0c8b147 commit 5015c9f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
6 changes: 5 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"manifest_version": 2,
"name": "IPFS Gateway Redirect 2",
"name": "IPFS Gateway Redirect WX",
"version" : "2.0.0",

"description": "Access IPFS resources via custom HTTP2IPFS gateway",
Expand All @@ -23,6 +23,10 @@
"default_popup": "popup/button-menu.html"
},

"options_ui": {
"page": "settings/options.html"
},

"web_accessible_resources": [
"data/linkify-demo.html",
"icons/ipfs-logo-on.svg",
Expand Down
22 changes: 22 additions & 0 deletions settings/options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8">
</head>

<body>

<form>
<fieldset>
<legend>Options</legend>
<label>Public Gateways <input type="text" id="publicGateways" ></label><br/>
<button type="submit">Save</button>
</fieldset>
</form>

<script src="options.js"></script>

</body>

</html>
14 changes: 14 additions & 0 deletions settings/options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function saveOptions(e) {
chrome.storage.local.set({
publicGateways: document.querySelector("#publicGateways").value
});
}

function restoreOptions() {
chrome.storage.local.get("publicGateways", (res) => {
document.querySelector("#publicGateways").value = res.publicGateways || "ipfs.io gateway.ipfs.io ipfs.pics";
});
}

document.addEventListener("DOMContentLoaded", restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);

0 comments on commit 5015c9f

Please sign in to comment.