-
Notifications
You must be signed in to change notification settings - Fork 2
/
options.js
32 lines (31 loc) · 1.05 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
'use strict';
(() => {
const sourceSelectElement = document.getElementById("source-lang-select");
const targetSelectElement = document.getElementById("target-lang-select");
chrome.storage.sync.get(['sourceLang'], (result) => {
if (typeof result.sourceLang !== "undefined") {
sourceSelectElement.value = result.sourceLang;
} else {
sourceSelectElement.value = 'en';
}
});
chrome.storage.sync.get(['targetLang'], (result) => {
if (typeof result.targetLang !== "undefined"){
targetSelectElement.value = result.targetLang;
} else {
targetSelectElement.value = 'de';
}
});
sourceSelectElement.addEventListener('change', () => {
const sourceLang = sourceSelectElement.value;
chrome.storage.sync.set({ sourceLang }, () => {
console.log('Source is ' + sourceLang);
});
});
targetSelectElement.addEventListener('change', () => {
const targetLang = targetSelectElement.value;
chrome.storage.sync.set({ targetLang }, () => {
console.log('Target is ' + targetLang);
});
});
})();