-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathoptions.js
45 lines (37 loc) · 1.35 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
document.forms[0].onsubmit = function(e) {
e.preventDefault();
var form = $('#form_options').serializeArray();
chrome.runtime.getBackgroundPage(function(bgWindow) {
bgWindow.saveConfigs(form);
window.close();
});
};
$(document).ready(function(){
function inputByName(elm_name){
return $("input[name='"+ elm_name +"']");
}
function bindColorInput(colorInputName, textInputName, defaultColor){
let colorInput = inputByName(colorInputName);
let textInput = inputByName(textInputName);
colorInput.change(function(){
textInput.val(this.value);
});
textInput.on('keyup', function(){
colorInput.val(this.value);
});
colorInput.val(defaultColor);
textInput.val(defaultColor);
}
bindColorInput('text_color_picker', 'show_age_text_color', '#000000');
bindColorInput('bg_color_picker', 'show_age_bg_color', '#FFFFFF');
bindColorInput('text_color_picker_real_age', 'show_real_age_text_color', '#000000');
bindColorInput('bg_color_picker_real_age', 'show_real_age_bg_color', '#FFFFFF');
chrome.storage.local.get({
formOptions: []
}, function(storage) {
values = storage.formOptions;
for (var i = 0; i < values.length; i++) {
$("input[name='" + values[i].name + "'], select[name='" + values[i].name + "']").val(values[i].value).attr('checked', 'true');
}
});
});