-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.js
More file actions
21 lines (21 loc) · 837 Bytes
/
options.js
File metadata and controls
21 lines (21 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// grabs div from options.html
let page = document.getElementById('buttonDiv');
// provides several color options to color background
const kButtonColors = ['#3aa757', '#e8453c', '#f9bb2d', '#4688f1'];
// for each item in the above const var, create a button that on click will
// change the color stored in the storage api that is used to color
// the background of the chrome dev site
// and report the change to the web console
function constructOptions(kButtonColors) {
for (let item of kButtonColors) {
let button = document.createElement('button');
button.style.backgroundColor = item;
button.addEventListener('click', function() {
chrome.storage.sync.set({color: item}, function() {
console.log('color is ' + item);
})
});
page.appendChild(button);
}
}
constructOptions(kButtonColors);