-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
37 lines (28 loc) · 1.03 KB
/
options.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2018 Authentiq BV. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
window.browser = (function() {
return window.msBrowser || window.browser || window.chrome;
})();
const background = browser.extension.getBackgroundPage();
function constructOptions() {
const field = document.getElementById('handle');
const button = document.getElementById('save');
browser.storage.sync.get('handle', function(data) {
field.value = data.handle || '';
});
button.addEventListener('click', function(evt) {
let newHandle = field.value;
browser.storage.sync.set({ handle: newHandle }, function() {
console.info('AQ: New handle is:', newHandle);
background.pushHandle = newHandle;
const successMessage = document.getElementById('success-message');
successMessage.classList.remove('hidden');
setTimeout(() => {
successMessage.classList.add('hidden');
}, 7000);
});
});
}
constructOptions();