Skip to content

Commit

Permalink
Deploying to gh-pages from @ e438273 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
kordwarshuis committed Jan 28, 2024
1 parent 1dd03e3 commit 28b8044
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion assets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3769,7 +3769,7 @@ const iziToast = /* @__PURE__ */ getDefaultExportFromCjs(iziToastExports);
iziToast.show({
theme: "light",
icon: "icon-person",
title: "Hey",
title: "Kerific info",
message: `<p><strong>${userInform}</strong>. To see your collections go to the options of the Kerific extension (right-click on the icon).</p>`,
position: "topRight",
// bottomRight, bottomLeft, topRight, topLeft, topCenter, bottomCenter
Expand Down
27 changes: 27 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,33 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
}
});

// Keep the message channel open for asynchronous response
return true;
} else if (request.action === "removeTerm") {
// Retrieve the existing data
chrome.storage.local.get('kerificTerms', function (result) {
let existingData = result.kerificTerms || { "terms": [] };

// Check if the term is in the collection…
if (existingData.terms.some(obj => obj.term === request.entry.term) === true) {
// … if so, remove entry
existingData.terms = existingData.terms.filter(function (obj) {
return obj.term !== request.entry.term;
});

// Store the updated data
chrome.storage.local.set({ 'kerificTerms': existingData }, function () {
console.log('Data is updated.');
});

// Send a response back
sendResponse({ response: "termRemoved" });
} else {
// … if not, send a response back that term is not found
sendResponse({ response: "termNotFound" });
}
});

// Keep the message channel open for asynchronous response
return true;

Expand Down
4 changes: 2 additions & 2 deletions info.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ <h2>
<p>It works on any webpage, but is especially useful for the KERI documentation.</p>
<p>It does NOT work on pdf's.</p>

<p>There are currently no options to configure.</p>

<p>Visit <a target="_blank" rel="noopener" href="https://kerisse.org">Kerisse.org</a> for more
information.</p>
</div>
</div>
</div>
Expand Down
13 changes: 13 additions & 0 deletions js/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function loadCollections() {
domString += `
<div class="card mb-5">
<div class="card-header">
<button type="button" class="btn btn-danger btn-sm float-end remove-button" data-term="${terms[i].term}">Remove</button>
<h2>${terms[i].term}</h2>
</div>
<div class="card-body">
Expand All @@ -31,6 +32,18 @@ function loadCollections() {
}
}
document.getElementById('container-collection').innerHTML = domString;

var removeButtons = document.querySelectorAll('.remove-button');
console.log('removeButtons: ', removeButtons);
for (var i = 0; i < removeButtons.length; i++) {
removeButtons[i].addEventListener('click', function () {
console.log('remove button clicked');
chrome.runtime.sendMessage({ action: "removeTerm", entry: { term: this.dataset.term } }, function (response) {
console.log("Response:", response);
loadCollections();
});
});
}
});

chrome.storage.local.get(['role'], function (result) {
Expand Down

0 comments on commit 28b8044

Please sign in to comment.