rj1
about | log | files | refs | license
commit bf0482a4326657ad4c941de9c62e87afe9d7d7fd
parent 8dc2aaa323a98a95ca2e9ef4801188dde6f204d7
author: rj1 <[email protected]>
date:   Sun, 20 Nov 2022 13:31:42 -0600

added preferences template

created a template for the preferences tab to match the aesthetic of
firefox. it currently does not affect the functionality of the plugin at
all.

Diffstat:
Asettings.css | 25+++++++++++++++++++++++++
Asettings.html | 35+++++++++++++++++++++++++++++++++++
Asettings.js | 22++++++++++++++++++++++
3 files changed, 82 insertions(+), 0 deletions(-)

diff --git a/settings.css b/settings.css @@ -0,0 +1,25 @@ +body { + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; + background: #fff; + color: rgb(74, 74, 79); + font-size: 13px; + overflow: hidden; +} + +h3:first-of-type { + margin-block-start: 1rem; +} + +input[type="checkbox"] { + margin-inline: 0 8px; + margin-block: 1px auto; + inline-size: 16px; + block-size: 16px; +} + +@media (prefers-color-scheme: dark) { + body { + background: #23212a; + color: #fff; + } +} diff --git a/settings.html b/settings.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <link rel="stylesheet" href="settings.css"> + </head> + <body> + <form> + <h3>Settings</h3> + <div class="setting"> + <label class="permission"> + <input id="newTab" type="checkbox" checked> + Open uploaded image in a new tab + </label> + </div> + <div class="setting"> + <label class="permission"> + <input id="clipboardPlace" type="checkbox"> + Place uploaded image URL in system clipboard + </label> + </div> + <h3>File host</h3> + <div class="setting"> + <label class="permission"> + <select id="fileHost"> + <option value="filehole">filehole.org</option> + <option value="0x0">0x0.st</option> + </select> + </label> + </div> + </form> + <script src="js/options.js"></script> + <div style="height:100px;"></div> + </body> +</html> diff --git a/settings.js b/settings.js @@ -0,0 +1,22 @@ +function saveOptions(e) { + e.preventDefault(); + browser.storage.sync.set({ + fileHost: document.querySelector("#fileHost").value + }); +} + +function restoreOptions() { + function setCurrentChoice(result) { + document.querySelector("#fileHost").value = result.fileHost || "filehole"; + } + + function onError(error) { + console.log(`Error: ${error}`); + } + + let getting = browser.storage.sync.get("fileHost"); + getting.then(setCurrentChoice, onError); +} + +document.addEventListener("DOMContentLoaded", restoreOptions); +document.querySelector("form").addEventListener("submit", saveOptions);