-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoptions.js
62 lines (50 loc) · 2.11 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function optionsLoad() {
// get element objects
var isePanField = document.getElementById('isePanField');
var iseMntField = document.getElementById('iseMntField');
var userField = document.getElementById('userField');
var passField = document.getElementById('passField');
var portField = document.getElementById('portField');
// retrieve values from chrome local storage, place in input field if defined
chrome.storage.local.get(['isePanNode'], function(result) {
if(result.isePanNode) { isePanField.value = result.isePanNode }
else { isePanField.value = ''; }
});
chrome.storage.local.get(['iseMntNode'], function(result) {
if(result.iseMntNode) { iseMntField.value = result.iseMntNode }
else { iseMntField.value = ''; }
});
chrome.storage.local.get(['isePort'], function(result) {
if(result.isePort) { portField.value = result.isePort }
else { portField.value = '9060'; }
});
chrome.storage.local.get(['iseUser'], function(result) {
if(result.iseUser) { userField.value = result.iseUser }
else { userField.value = ''; }
});
chrome.storage.local.get(['isePass'], function(result) {
if(result.isePass) { passField.value = result.isePass }
else { passField.value = ''; }
});
}
optionsLoad();
document.getElementById('optionsSubmit').onclick = function() {
// get element fields
var isePanField = document.getElementById('isePanField');
var iseMntField = document.getElementById('iseMntField');
var portField = document.getElementById('portField');
var userField = document.getElementById('userField');
var passField = document.getElementById('passField');
// set chrome local storage values to field values
chrome.storage.local.set({isePanNode: isePanField.value});
chrome.storage.local.set({iseMntNode: iseMntField.value});
chrome.storage.local.set({isePort: portField.value});
chrome.storage.local.set({iseUser: userField.value});
chrome.storage.local.set({isePass: passField.value});
window.close();
chrome.runtime.reload();
}
document.getElementById('refreshGroups').onclick = function() {
window.close();
chrome.runtime.reload();
}