-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
54 lines (47 loc) · 1.19 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
function addUser(email, publicKey) {
var save = {};
save[email] = publicKey;
chrome.storage.sync.set(save, function() {
showUsers();
$("#email").val("");
$("#publickey").val("");
});
}
function showUsers() {
$("#users option").remove();
chrome.storage.sync.get(null, function (values) {
$.each(values, function(key, value) {
if (key !== 'myPrivateKey') {
option = $('#users')
.append($("<option></option>")
.text(key));
}
});
});
}
function removeUser(email) {
chrome.storage.sync.remove(email, function() {
showUsers();
});
}
function updatePrivateKey(privateKey) {
var save = {};
save['myPrivateKey'] = privateKey;
chrome.storage.sync.set(save, function() {
$("#privatekey").val("");
alert('Your Private Key has been sucessfully been updated')
});
}
$("#adduser").click(function() {
event.preventDefault();
addUser($("#email").val(), $("#publickey").val());
});
$("#removeuser").click(function() {
event.preventDefault();
removeUser($("#users").val());
});
$("#updatePrivateKey").click(function() {
event.preventDefault();
updatePrivateKey($('#privatekey').val())
});
showUsers();