-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
31 lines (28 loc) · 1.01 KB
/
popup.js
File metadata and controls
31 lines (28 loc) · 1.01 KB
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
document.addEventListener("DOMContentLoaded", function () {
const goalInput = document.getElementById("goalInput");
const addGoalButton = document.getElementById("addGoal");
const goalList = document.getElementById("goalList");
chrome.storage.sync.get(["goals"], function (data) {
if (data.goals) {
data.goals.forEach(goal => addGoalToUI(goal));
}
});
addGoalButton.addEventListener("click", function () {
const goal = goalInput.value.trim();
if (goal) {
chrome.storage.sync.get(["goals"], function (data) {
const goals = data.goals || [];
goals.push(goal);
chrome.storage.sync.set({ "goals": goals }, function () {
addGoalToUI(goal);
goalInput.value = "";
});
});
}
});
function addGoalToUI(goal) {
const li = document.createElement("li");
li.textContent = goal;
goalList.appendChild(li);
}
});