-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
41 lines (34 loc) · 1.31 KB
/
popup.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
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
let onButton = document.getElementById('on');
let offButton = document.getElementById('off');
let blogCheckBox = document.getElementById('blog');
let cafeCheckBox = document.getElementById('cafe');
let mapCheckBox = document.getElementById('map');
onButton.onclick = function(element) {
chrome.storage.sync.set({ isEnabled: true }, function() {
chrome.action.setBadgeText({ text: 'ON' });
});
};
offButton.onclick = function(element) {
chrome.storage.sync.set({ isEnabled: false }, function() {
chrome.action.setBadgeText({ text: 'OFF' });
});
};
blogCheckBox.onchange = function blogChange() {
chrome.storage.sync.set({ blog: blogCheckBox.checked }, function() {});
};
cafeCheckBox.onchange = function cafeChange() {
chrome.storage.sync.set({ cafe: cafeCheckBox.checked }, function() {});
};
mapCheckBox.onchange = function mapChange() {
chrome.storage.sync.set({ map: mapCheckBox.checked }, function() {});
};
// ComboBox initialize
chrome.storage.sync.get(['blog', 'cafe', 'map'], function(data) {
blogCheckBox.checked = data.blog;
cafeCheckBox.checked = data.cafe;
mapCheckBox.checked = data.map;
});