aboutsummaryrefslogtreecommitdiff
path: root/options
diff options
context:
space:
mode:
authorMark Powers <mark@marks.kitchen>2022-12-29 14:03:57 -0600
committerMark Powers <mark@marks.kitchen>2022-12-29 14:03:57 -0600
commitb5c10718ddeaa8fcac368515ca150705b1a2c5ab (patch)
tree473c6b8197774ed3a29df73821c404381535ccbc /options
parentff9f53e5673d742d155881a2a29f31ba312dce9c (diff)
Refactor scripts, add table preview
Diffstat (limited to 'options')
-rw-r--r--options/index.html39
-rw-r--r--options/index.js23
2 files changed, 62 insertions, 0 deletions
diff --git a/options/index.html b/options/index.html
new file mode 100644
index 0000000..9817b71
--- /dev/null
+++ b/options/index.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <meta charset="UTF-8">
+ <title>Options</title>
+</head>
+
+<body>
+ <form>
+ <table>
+ <tr>
+ <td><label for="rb">rss-bridge instance</label></td>
+ <td><input type="text" id="rb"></td>
+ </tr>
+ <tr>
+ <td><label for="reader">reader type:</label></td>
+ <td>
+ <select name="reader" id="reader">
+ <option value="ttrss">TT-RSS</option>
+ <option value="miniflux">Miniflux</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td><label for="instance">instance URL:</label></td>
+ <td><input type="text" id="instance"></td>
+ </tr>
+ <tr>
+ <td>
+ <button type="submit">Save</button>
+ </td>
+ </tr>
+ </table>
+ </form>
+ <script src="options/index.js"></script>
+</body>
+
+</html>
diff --git a/options/index.js b/options/index.js
new file mode 100644
index 0000000..3d85dbe
--- /dev/null
+++ b/options/index.js
@@ -0,0 +1,23 @@
+function saveOptions(e) {
+ e.preventDefault();
+ browser.storage.sync.set({
+ rb: document.querySelector("#rb").value,
+ reader: document.querySelector("#reader").value,
+ instance: document.querySelector("#instance").value
+ });
+}
+function restoreOptions() {
+ function setCurrentChoice(result) {
+ document.querySelector("#rb").value = result.rb || "";
+ document.querySelector("#reader").value = result.reader|| "";
+ document.querySelector("#instance").value = result.instance || "";
+ }
+ function onError(error) {
+ console.log(`Error: ${error}`);
+ }
+ let getting = browser.storage.sync.get(["rb", "instance", "reader"]);
+ getting.then(setCurrentChoice, onError);
+}
+document.addEventListener("DOMContentLoaded", restoreOptions);
+document.querySelector("form").addEventListener("submit", saveOptions);
+