-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathoptions.js
More file actions
31 lines (26 loc) · 1.01 KB
/
options.js
File metadata and controls
31 lines (26 loc) · 1.01 KB
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
loadOptions();
document.getElementById('save_options').addEventListener('click', saveOptions);
function loadOptions() {
chrome.storage.local.get('lang_list', function(properties) {
console.log('lang_list: ' + properties['lang_list'])
var langList = properties['lang_list']
if (langList == undefined) {
// When language list is empty, there is no filtering; when non-empty, this list gives the available languages.
langList = [];
}
langList.forEach(function(value, index, array) {
document.getElementById(value).checked = true;
});
})
$('body').attr("hidden", false);
}
function saveOptions() {
var langList = $("input[name='lang']:checked").toArray().map(function getId(e) { return e.id} );
langList.forEach(function(value, index, array) {
document.getElementById(value).checked = true;
});
chrome.storage.local.set({'lang_list': langList}, function() {
console.log('lang_list set to: ' + langList);
})
setTimeout(function() { alert("Options saved!"); }, 100);
}