forked from nrchandan/mult-table-chrome-ext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
48 lines (41 loc) · 1.25 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
42
43
44
45
46
47
48
let numberDisplay = document.getElementById('number');
let numberSection = document.getElementById('numberColumn');
let resultSection = document.getElementById('resultColumn');
let prevButton = document.getElementById('prev');
let nextButton = document.getElementById('next');
let content = document.getElementById('content');
let number;
let color;
chrome.storage.sync.get('number', function(data) {
number = data.number;
refreshTable();
});
chrome.storage.sync.get('color', function(data) {
color = data.color;
refreshTable();
});
function refreshTable() {
content.style.backgroundImage = 'repeating-linear-gradient(' + color + ' 0px, ' + color + ' 24px, teal 25px)'
numberDisplay.innerHTML = number;
numberSection.innerHTML = "";
resultSection.innerHTML = "";
for (let i = 1; i <= 10; i++) {
numberSection.innerHTML += "<div>" + number + "</div>";
resultSection.innerHTML += "<div>" + number * i + "</div>";
}
}
function storeNumber() {
chrome.storage.sync.set({number: number}, function() {
console.log('New number is ' + number);
})
}
prevButton.addEventListener("click", function() {
number--;
refreshTable();
storeNumber();
});
nextButton.addEventListener("click", function() {
number++;
refreshTable();
storeNumber();
});