forked from alecmev/trimless-gmail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
88 lines (73 loc) · 2.47 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
var tmpItems = null;
function save() {
chrome.storage.sync.set(tmpItems, () => {
$('#status').text('Saved!');
setTimeout(() => $('#status').text(''), 2000);
});
}
function updateColorValue() {
$('#color-value').text(tmpItems['trimless-color-value']);
$('#color-value').css('color', tmpItems['trimless-color-value']);
}
function handleColorChange(color) {
tmpItems['trimless-color-value'] =
color.toHexString().toUpperCase();
tmpItems['trimless-color-border'] =
color.lighten(27).toHexString().toUpperCase();
updateColorValue();
}
function handleIntentationChange(e) {
tmpItems['trimless-indentation-value'] = e.target.value;
$('#indentation-value').text(tmpItems['trimless-indentation-value']);
}
function initialize() {
$('#color-enabled').change(function() {
tmpItems['trimless-color-enabled'] = this.checked;
});
$('#color-enabled').prop('checked', tmpItems['trimless-color-enabled']);
updateColorValue();
$('#color-input').spectrum({
color: tmpItems['trimless-color-value'],
flat: true,
showButtons: false,
showInput: true,
preferredFormat: 'hex',
change: handleColorChange,
move: handleColorChange
});
$('#indentation-enabled').change(function() {
tmpItems['trimless-indentation-enabled'] = this.checked;
});
$('#indentation-enabled').prop(
'checked', tmpItems['trimless-indentation-enabled']
);
$('#indentation-input').change(handleIntentationChange);
$('#indentation-input').on('input change', handleIntentationChange);
$('#indentation-input').val(tmpItems['trimless-indentation-value']);
$('#indentation-input').change();
$('#reply-enabled').change(function() {
tmpItems['trimless-reply-enabled'] = this.checked;
});
$('#reply-enabled').prop('checked', tmpItems['trimless-reply-enabled']);
$('#save').click(save);
$('#reset').click(function() {
$('#color-enabled').prop('checked', true);
$('#color-enabled').change();
$('#color-input').spectrum('set', '#888888');
$('#indentation-enabled').prop('checked', true);
$('#indentation-enabled').change();
$('#indentation-input').val(32);
$('#indentation-input').change();
$('#reply-enabled').prop('checked', false);
$('#reply-enabled').change();
});
}
document.addEventListener(
'DOMContentLoaded',
() => {
chrome.storage.sync.get(null, function(items) {
tmpItems = items;
initialize();
});
}
);