-
Notifications
You must be signed in to change notification settings - Fork 5
/
userOptions.js
executable file
·217 lines (180 loc) · 7.73 KB
/
userOptions.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
// Saves options to chrome.storage
function save_options() {
// var mouseMoveColor = document.getElementById('mouseMoveColor').value;
var mouseMoveColor = $('#mouseMoveColor').spectrum("get").toRgbString();
var mouseMoveSize = document.getElementById('mouseMoveSize').value;
// var mouseMoveSize = $("#mouseMoveSize").simpleSlider("get");
var mouseMoveBorderColor = $('#mouseMoveBorderColor').spectrum("get").toRgbString();
var mouseMoveBorderSize = document.getElementById('mouseMoveBorderSize').value;
var mouseDownColor = $('#mouseDownColor').spectrum("get").toRgbString();
var mouseDownSize = document.getElementById('mouseDownSize').value;
var mouseDownBorderColor = $('#mouseDownBorderColor').spectrum("get").toRgbString();
var mouseDownBorderSize = document.getElementById('mouseDownBorderSize').value;
var mouseUpColor = $('#mouseUpColor').spectrum("get").toRgbString();
var mouseUpSize = document.getElementById('mouseUpSize').value;
var mouseUpBorderColor = $('#mouseUpBorderColor').spectrum("get").toRgbString();
var mouseUpBorderSize = document.getElementById('mouseUpBorderSize').value;
chrome.storage.sync.set({
mouseMoveColor: mouseMoveColor,
mouseMoveSize: mouseMoveSize,
mouseMoveBorderColor: mouseMoveBorderColor,
mouseMoveBorderSize: mouseMoveBorderSize,
mouseDownColor: mouseDownColor,
mouseDownSize: mouseDownSize,
mouseDownBorderColor: mouseDownBorderColor,
mouseDownBorderSize: mouseDownBorderSize,
mouseUpColor: mouseUpColor,
mouseUpSize: mouseUpSize,
mouseUpBorderColor: mouseUpBorderColor,
mouseUpBorderSize: mouseUpBorderSize,
}, function() {
// Update status to let user know options were saved.
var status = document.getElementById('status');
status.textContent = 'Options saved.';
setTimeout(function() {
status.textContent = '';
}, 750); window.close("userOptions.html");
});
}
// Resets default settings to chrome.storage
function reset_options() {
var resetMouseMoveColor = 'rgba(255,255,10,0.5)';
var resetMouseMoveSize = '50';
var resetMouseMoveBorderColor = 'rgba(255,255,255,0)';
var resetMouseMoveBorderSize = '0';
var resetMouseDownColor = 'rgba(255,255,255,0)';
var resetMouseDownSize = '25';
var resetMouseDownBorderColor = 'rgba(65,65,190,0.7)';
var resetMouseDownBorderSize = '5';
var resetMouseUpColor = 'rgba(255,255,255,0)';
var resetMouseUpSize = '20';
var resetMouseUpBorderColor = 'rgba(65,65,190,0.6)';
var resetMouseUpBorderSize = '4';
chrome.storage.sync.set({
mouseMoveColor: 'rgba(255,255,10,0.5)',
mouseMoveSize: '50',
mouseMoveBorderColor: 'rgba(65,65,190,0.7)',
mouseMoveBorderSize: '0',
mouseDownColor: 'rgba(255,255,255,0)',
mouseDownSize: '25',
mouseDownBorderColor: 'rgba(64,64,191,0.5)',
mouseDownBorderSize: '5',
mouseUpColor: 'rgba(255,255,255,0)',
mouseUpSize: '20',
mouseUpBorderColor: 'rgba(65,65,190,0.6)',
mouseUpBorderSize: '4',
}, function() {
// Update status to let user know options were saved to default.
var status = document.getElementById('status');
status.textContent = 'Options reset.';
setTimeout(function() {
status.textContent = '';
}, 750); window.close("userOptions.html");
});
}
// Restores select box and checkbox state using the preferences
// stored in chrome.storage.
function init() {
chrome.storage.sync.get({
mouseMoveColor: 'rgba(255,230,0,0.5)',
mouseMoveSize: '45',
mouseMoveBorderColor: 'rgba(255,255,255,0)',
mouseMoveBorderSize: '0',
mouseDownColor: 'rgba(255,255,255,0)',
mouseDownSize: '15',
mouseDownBorderColor: 'rgba(64,64,191,0.5)',
mouseDownBorderSize: '4',
mouseUpColor: 'rgba(255,255,255,0)',
mouseUpSize: '10',
mouseUpBorderColor: 'rgba(64,64,191,0.5)',
mouseUpBorderSize: '3',
}, function(items) {
console.log(items, items.mouseMoveColor);
$('#mouseMoveColor').spectrum({
color: items.mouseMoveColor,
showAlpha: true,
showInput: true,
showPalette: true,
palette: [
["rgba(255, 128, 0, .9)", "rgba(255, 128, 0, .5)"],
["red", "green", "blue"],
["hsla(25, 50, 75, .5)", "rgba(100, .5, .5, .8)"]
]
});
console.log(items, items.mouseMoveBorderColor);
$('#mouseMoveBorderColor').spectrum({
color: items.mouseMoveBorderColor,
showAlpha: true,
showInput: true,
showPalette: true,
palette: [
["rgba(255, 128, 0, .9)", "rgba(255, 128, 0, .5)"],
["red", "green", "blue"],
["hsla(25, 50, 75, .5)", "rgba(100, .5, .5, .8)"]
]
});
console.log(items, items.mouseDownColor);
$('#mouseDownColor').spectrum({
color: items.mouseDownColor,
showAlpha: true,
showInput: true,
showPalette: true,
palette: [
["rgba(255, 128, 0, .9)", "rgba(255, 128, 0, .5)"],
["red", "green", "blue"],
["hsla(25, 50, 75, .5)", "rgba(100, .5, .5, .8)"]
]
});
console.log(items, items.mouseDownBorderColor);
$('#mouseDownBorderColor').spectrum({
color: items.mouseDownBorderColor,
showAlpha: true,
showInput: true,
showPalette: true,
palette: [
["rgba(255, 128, 0, .9)", "rgba(255, 128, 0, .5)"],
["red", "green", "blue"],
["hsla(25, 50, 75, .5)", "rgba(100, .5, .5, .8)"]
]
});
console.log(items, items.mouseUpColor);
$('#mouseUpColor').spectrum({
color: items.mouseUpColor,
showAlpha: true,
showInput: true,
showPalette: true,
palette: [
["rgba(255, 128, 0, .9)", "rgba(255, 128, 0, .5)"],
["red", "green", "blue"],
["hsla(25, 50, 75, .5)", "rgba(100, .5, .5, .8)"]
]
});
console.log(items, items.mouseUpBorderColor);
$('#mouseUpBorderColor').spectrum({
color: items.mouseUpBorderColor,
showAlpha: true,
showInput: true,
showPalette: true,
palette: [
["rgba(255, 128, 0, .9)", "rgba(255, 128, 0, .5)"],
["red", "green", "blue"],
["hsla(25, 50, 75, .5)", "rgba(100, .5, .5, .8)"]
]
});
// document.getElementById('mouseMoveColor').value = items.mouseMoveColor;
document.getElementById('mouseMoveSize').value = items.mouseMoveSize;
// document.getElementById('mouseMoveBorderColor').value = items.mouseMoveBorderColor;
document.getElementById('mouseMoveBorderSize').value = items.mouseMoveBorderSize;
// document.getElementById('mouseDownColor').value = items.mouseDownColor;
document.getElementById('mouseDownSize').value = items.mouseDownSize;
// document.getElementById('mouseDownBorderColor').value = items.mouseDownBorderColor;
document.getElementById('mouseDownBorderSize').value = items.mouseDownBorderSize;
// document.getElementById('mouseUpColor').value = items.mouseUpColor;
document.getElementById('mouseUpSize').value = items.mouseUpSize;
// document.getElementById('mouseUpBorderColor').value = items.mouseUpBorderColor;
document.getElementById('mouseUpBorderSize').value = items.mouseUpBorderSize;
});
}
document.addEventListener('DOMContentLoaded', init);
document.getElementById('save').addEventListener('click', save_options);
document.getElementById('reset').addEventListener('click', reset_options);