-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
36 lines (32 loc) · 1.18 KB
/
Copy pathpopup.js
File metadata and controls
36 lines (32 loc) · 1.18 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
32
33
34
35
36
document.getElementById("save").addEventListener("click", function () {
const code = document.getElementById("code").value;
const note = document.getElementById("note").value;
if (code && note) {
chrome.storage.sync.get(["notes"], function (result) {
let notes = result.notes || [];
notes.push({ code, note });
chrome.storage.sync.set({ notes }, function () {
alert("Note saved!");
document.getElementById("code").value = "";
document.getElementById("note").value = "";
});
});
} else {
alert("Please enter both code and note.");
}
});
document.getElementById("view").addEventListener("click", function () {
chrome.storage.sync.get(["notes"], function (result) {
const notes = result.notes || [];
const notesList = document.getElementById("notes-list");
notesList.innerHTML = "";
notes.forEach((note, index) => {
const listItem = document.createElement("li");
listItem.innerHTML = `<strong>Note ${index + 1}:</strong><br>${
note.code
}<br><br>${note.note}`;
notesList.appendChild(listItem);
});
document.getElementById("notes-container").style.display = "block";
});
});