-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
42 lines (34 loc) · 1.06 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
const inputEl = document.getElementById("amount");
const buttonEl = document.getElementById("button-el");
const display = document.getElementById("display-total");
const displayLimit = document.getElementById("display-limit");
let total = 0;
let dataFromLocalStorage = parseInt(
JSON.parse(localStorage.getItem("expense"))
);
let limitFromLocalStorage = parseInt(JSON.parse(localStorage.getItem("limit")));
if (limitFromLocalStorage) {
displayLimit.innerHTML = limitFromLocalStorage;
}
if (dataFromLocalStorage) {
total = dataFromLocalStorage;
display.innerHTML = total;
}
buttonEl.addEventListener("click", () => {
total += parseInt(inputEl.value);
display.innerHTML = total;
inputEl.innerHTML = "";
localStorage.setItem("expense", JSON.stringify(total));
// if (limitFromLocalStorage <= total) {
// noti();
// }
});
// const noti = () => {
// chrome.notifications.create("",{
// title: "Limit Reached",
// type: "basic",
// iconUrl: "Cash-icon-16.png",
// message: "Uh No ! You have reached your Limit.",
// })
// };
// noti();