-
Notifications
You must be signed in to change notification settings - Fork 1
/
options.js
72 lines (60 loc) · 1.87 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
var attributes = {
delay: 500,
leadName: 'John Doe',
leadPhone: '(11) 11111-1111',
leadEmail: 'fakemail@gmail.com',
insuredPersonName: 'John Doe',
insuredPersonCpf: '427.848.588-39',
insuredPersonJobRole: 'Webdesigner',
insuredPersonSalaryRange: 'Band4',
insuredPersonAddressNumber: '500',
insuredPersonGender: 'M',
insuredPersonDateOfBirth: '01/01/1980',
insuredPersonCep: '08461-660',
// AUTO
vehicleMake: 'CHEVROLET',
vehicleModel: 'CELTA',
vehicleVersion: 'CELTA SPIRIT / LT 1.0 MPFI 8V FLEXP. 5P (Gasolina / Flex)',
vehicleYear: '2015',
vehicleBrandNew: 'zero_km_with_license_plate',
vehicleUsage: 'auto|private',
vehiclePurchased: "true",
vehicleCollected: "true",
vehicleCep: '08461-660',
vehicleLicensePlate: 'EMP5324',
vehicleBulletProof: 'false',
driverGender: 'M',
driverDateOfBirth: '01/01/1980',
driverLastClaim: 5,
// HOME
propertyTypeUsage: 'house|habitual',
propertyValue: 'R$ 500.000',
propertyCep: '08461-660',
// LIFE
beneficiaryName: 'Jane Roe',
beneficiaryRelationship: 'father',
beneficiaryCompensation: '100,00%'
}
var keyPrefix = "YOUSE__";
// Saves options to chrome.storage
function save_options() {
chrome.storage.sync.clear();
var savedOptions = {};
for (var key in attributes) {
savedOptions[keyPrefix + key] = document.getElementById(key).value;
}
chrome.storage.sync.set(savedOptions, function() {
alert('Dados salvos com sucesso');
});
}
// Restores select box and checkbox state using the preferences
// stored in chrome.storage.
function restore_options() {
chrome.storage.sync.get(null, function(items) {
for (var key in attributes) {
document.getElementById(key).value = items[keyPrefix + key] || attributes[key];
}
});
}
document.addEventListener('DOMContentLoaded', restore_options);
document.getElementById('save').addEventListener('click', save_options);