Light Modus hinzugefügt

This commit is contained in:
clerie
2018-06-29 12:16:09 +02:00
parent d0a14f0ee5
commit ac139f6bca
4 changed files with 82 additions and 16 deletions

23
settings/index.html Normal file
View File

@@ -0,0 +1,23 @@
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<form>
<h2>Ressourcen</h2>
<label>
<input type="checkbox" id="light">
<b>Light Modus</b><br>
Verringert die Prozessorlast durch abschalten der interaktiven Elemente
</label>
<br>
<br>
<button type="submit">Speichen</button>
</form>
<script src="settings.js"></script>
</body>
</html>

23
settings/settings.js Normal file
View File

@@ -0,0 +1,23 @@
function saveOptions(e) {
e.preventDefault();
browser.storage.local.set({
light: document.querySelector("#light").checked
});
}
function restoreOptions() {
function setCurrentChoice(result) {
document.querySelector("#light").checked = result.light || false;
}
function onError(error) {
console.log(`Error: ${error}`);
}
var getting = browser.storage.local.get("light");
getting.then(setCurrentChoice, onError);
}
document.addEventListener("DOMContentLoaded", restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);