-
Notifications
You must be signed in to change notification settings - Fork 4
/
options.js
47 lines (42 loc) · 1.15 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
function message(msg){
alert(msg);
}
var $token = document.getElementById('options-token');
var $username = document.getElementById('options-username');
var $repo = document.getElementById('options-repo');
var $saveButton = document.getElementById('save');
chrome.storage.local.get('options', function(items){
var options = items.options;
if(options.token)
$token.value = options.token;
if(options.username)
$username.value = options.username;
if(options.repo)
$repo.value = options.repo;
});
$saveButton.addEventListener('click', function saveOptions () {
var token = $token.value;
var username = $username.value;
var repo = $repo.value;
if(!token) {
message('Error: No github token specified');
return;
}
if(!username) {
message('Error: No github username specified');
return;
}
if(!repo) {
message('Error: No github repo specified');
return;
}
chrome.storage.local.set({
options: {
token: token,
username: username,
repo: repo
}
}, function() {
message('saved');
});
});