-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
60 lines (56 loc) · 1.49 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
function open() {
chrome.tabs.create({
"url": "/clock.html"
});
};
function message(msg, color) {
var status = $("#status");
status.css("color", color);
status.text(msg);
setTimeout(function() {
status.text("");
status.css("color", "inherit");
}, 750);
};
function save() {
var items = {
"analog": $("#analog").prop("checked"),
"military": $("#military").prop("checked"),
"size": $("#size").prop("value"),
"accent": $("#accent").prop("value"),
"foreground": $("#foreground").prop("value"),
"background": $("#background").prop("value"),
"font": $("#font").prop("value")
};
chrome.storage.sync.set(items, function() {
message("Options Saved!", "green");
});
};
function load() {
chrome.storage.sync.get({
"analog": true,
"military": false,
"size": 144,
"accent": "#ff0000",
"foreground": "#d6d6d6",
"background": "#282828",
"font": "sans-serif"
}, function(items) {
$("#analog")[0].checked = items["analog"];
$("#military")[0].checked = items["military"];
$("#size").val(items["size"]);
$("#accent").val(items["accent"]).trigger('change');
$("#foreground").val(items["foreground"]).trigger('change');
$("#background").val(items["background"]).trigger('change');
$("#font").val(items["font"]);
});
};
$(document).ready(function() {
load();
$("#save").on("click", save);
$("#open").on("click", open);
$("#accent, #foreground, #background").on('change', function(event){
$input = $(event.target);
$input.css('background', $input.prop('value'));
});
});