Skip to content

Commit

Permalink
delete option + button active state added
Browse files Browse the repository at this point in the history
  • Loading branch information
SunWorldDev committed Nov 30, 2023
1 parent a3383bd commit fa415ec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,23 @@ async function loadData() {
frame.addEventListener("click", (e) => {
navigator.clipboard.writeText(e.currentTarget.getAttribute("data-code"));
});
frame.addEventListener("contextmenu", async function(e) {
e.preventDefault();

let cTarget = e.currentTarget;

const userConfirmation = window.confirm("Do you want to delete " + cTarget.children[0].innerHTML + "?");

if (userConfirmation) {
let data = await fetchData();
delete data[cTarget.children[0].innerHTML];
console.log(cTarget.children[0].innerHTML);
await chrome.storage.sync.set({ data: data }, function() {
console.log('deleted');
});
loadData();
}
});
parent.appendChild(frame);
}
} catch (error) {
Expand Down
4 changes: 4 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ body {
}

.frame:hover {
background-color: rgba(30, 30, 30, 0.031);
}

.frame:active {
background-color: rgba(255, 255, 255, 0.031);
}

Expand Down

0 comments on commit fa415ec

Please sign in to comment.