-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathoptions.js
36 lines (30 loc) · 960 Bytes
/
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
angular.module("optionsApp", [])
.controller("ClientListController", function() {
var clientList = this;
clientList.clients = localStorage["clients"] ? JSON.parse(localStorage["clients"]) : {};
clientList.removeClient = function(client) {
delete clientList.clients[client.endpoint];
persistAndRefresh();
};
clientList.editClient = function(client) {
clientList.endpoint = client.endpoint;
clientList.login = client.login;
clientList.password = client.password;
};
clientList.addClient = function() {
var client = {
endpoint: clientList.endpoint,
login: clientList.login,
password: clientList.password
};
clientList.clients[client.endpoint] = client;
persistAndRefresh();
clientList.endpoint = "";
clientList.login = "";
clientList.password = "";
};
var persistAndRefresh = function () {
localStorage["clients"] = JSON.stringify(clientList.clients);
chrome.runtime.sendMessage({ state: "refresh" });
};
});