-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
49 lines (44 loc) · 1.24 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
// Generated by CoffeeScript 1.6.3
(function() {
var load_data, save_data;
load_data = function() {
return chrome.storage.local.get(["fixed_servers"], function(data) {
var fixed_servers, k, v, _results;
if (!data.fixed_servers) {
data.fixed_servers = {};
}
fixed_servers = data.fixed_servers;
if (!fixed_servers.host) {
fixed_servers.host = "127.0.0.1";
}
if (!fixed_servers.port) {
fixed_servers.port = "7070";
}
_results = [];
for (k in fixed_servers) {
v = fixed_servers[k];
_results.push(document.querySelector("#" + k).setAttribute("value", v));
}
return _results;
});
};
save_data = function() {
var fixed_servers, k;
fixed_servers = {
host: "",
port: ""
};
for (k in fixed_servers) {
fixed_servers[k] = document.querySelector('#' + k).value;
}
return chrome.storage.local.set({
fixed_servers: fixed_servers
}, function() {
return chrome.extension.sendMessage({
id: "refresh"
}, function() {});
});
};
document.addEventListener('DOMContentLoaded', load_data);
document.querySelector('#save').addEventListener('click', save_data);
}).call(this);