This commit is contained in:
Ray Lothian 2018-08-15 16:17:16 +04:30
parent ce9223f342
commit 2f7b81c8fe
2 changed files with 12 additions and 7 deletions

View file

@ -4,10 +4,11 @@
<title>My Test Extension Options</title> <title>My Test Extension Options</title>
<style> <style>
body { body {
min-width: 400px; min-width: 600px;
padding: 10px; }
textarea {
width: 100%;
} }
textarea { width: 100%; }
.h { .h {
text-decoration: underline; text-decoration: underline;
text-decoration-style: dashed; text-decoration-style: dashed;

View file

@ -1,11 +1,11 @@
'use strict'; 'use strict';
function notify(msg) { function notify(msg, period = 750) {
// Update status to let user know options were saved. // Update status to let user know options were saved.
const status = document.getElementById('status'); const status = document.getElementById('status');
status.textContent = msg; status.textContent = msg;
clearTimeout(notify.id); clearTimeout(notify.id);
notify.id = setTimeout(() => status.textContent = '', 750); notify.id = setTimeout(() => status.textContent = '', period);
} }
function prepare(str) { function prepare(str) {
@ -17,11 +17,15 @@ function prepare(str) {
function save() { function save() {
let custom = {}; let custom = {};
const c = document.getElementById('custom').value;
try { try {
custom = JSON.parse(document.getElementById('custom').value); custom = JSON.parse(c);
} }
catch (e) { catch (e) {
notify(e.message); window.setTimeout(() => {
notify('Custom JSON error: ' + e.message, 5000);
document.getElementById('custom').value = c;
}, 1000);
} }
chrome.storage.local.set({ chrome.storage.local.set({