forked from davidfyffe/PrefillChromeExtension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
36 lines (27 loc) · 1.24 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
'use strict';
function createForm() {
let dailyHours = document.getElementById("dailyHours");
let weeklyHours = document.getElementById("weeklyHours");
let office = document.querySelector('.officeCheckBox:checked');
//set text to stored value
chrome.storage.sync.get({dailyHours: {dailyHours: dailyHours.value, office: office.value}}, function(data) {
dailyHours.value = data.dailyHours.dailyHours;
office.value = data.dailyHours.office;
});
chrome.storage.sync.get({weeklyHours: weeklyHours.value}, function(data) {
weeklyHours.value = data.weeklyHours;
});
//save new values
let button = document.getElementById('saveButton');
button.addEventListener('click', function() {
let officeUpdatedValue = document.querySelector('.officeCheckBox:checked').value;
chrome.storage.sync.set({dailyHours: {dailyHours: dailyHours.value, office: officeUpdatedValue}}, function() {
console.log("DailyHours =" + dailyHours.value);
console.log("Office =" + officeUpdatedValue);
});
chrome.storage.sync.set({weeklyHours: weeklyHours.value}, function() {
console.log("WeeklyHours = " + weeklyHours.value);
});
});
}
createForm();