Skip to content

Commit

Permalink
Deploying to gh-pages from @ 65f8a5a 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
kordwarshuis committed Jan 28, 2024
1 parent b0b61b3 commit 7ca29a6
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 41 deletions.
65 changes: 36 additions & 29 deletions assets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3751,6 +3751,7 @@ const iziToast = /* @__PURE__ */ getDefaultExportFromCjs(iziToastExports);
return match ? match[1] : null;
}
function saveTextOfThisPopup(el) {
let userInform = "";
chrome.runtime.sendMessage({
action: "addTerm",
entry: {
Expand All @@ -3760,35 +3761,41 @@ const iziToast = /* @__PURE__ */ getDefaultExportFromCjs(iziToastExports);
}
}, function(response) {
console.log("Response:", response);
});
iziToast.show({
theme: "light",
icon: "icon-person",
title: "Hey",
message: `<p>Definition saved! 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
progressBarColor: "rgb(0, 255, 184)",
timeout: 5e3,
// buttons: [
// ['<button>Ok</button>', function (instance, toast) {
// alert("Hello world!");
// }, true], // true to focus
// ['<button>Close</button>', function (instance, toast) {
// instance.hide({
// transitionOut: 'fadeOutUp',
// onClosing: function (instance, toast, closedBy) {
// console.info('closedBy: ' + closedBy); // The return will be: 'closedBy: buttonName'
// }
// }, toast, 'buttonName');
// }]
// ],
onOpening: function(instance, toast) {
console.info("callback abriu!");
},
onClosing: function(instance, toast, closedBy) {
console.info("closedBy: " + closedBy);
}
if (response.response === "termAdded") {
userInform = "Term and definition added";
} else if (response.response === "termNotAdded") {
userInform = "Term and definition not added. It is already in your collection.";
}
iziToast.show({
theme: "light",
icon: "icon-person",
title: "Hey",
message: `<p>${userInform}. 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
progressBarColor: "rgb(0, 255, 184)",
maxWidth: "25%",
timeout: 5e3,
// buttons: [
// ['<button>Ok</button>', function (instance, toast) {
// alert("Hello world!");
// }, true], // true to focus
// ['<button>Close</button>', function (instance, toast) {
// instance.hide({
// transitionOut: 'fadeOutUp',
// onClosing: function (instance, toast, closedBy) {
// console.info('closedBy: ' + closedBy); // The return will be: 'closedBy: buttonName'
// }
// }, toast, 'buttonName');
// }]
// ],
onOpening: function(instance, toast) {
console.info("callback abriu!");
},
onClosing: function(instance, toast, closedBy) {
console.info("closedBy: " + closedBy);
}
});
});
}
})();
31 changes: 19 additions & 12 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,27 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
chrome.storage.local.get('kerificTerms', function (result) {
let existingData = result.kerificTerms || { "terms": [] };

// Add the new term and definition
existingData.terms.push({
"term": request.entry.term,
"definition": request.entry.definition,
"organisation": request.entry.organisation
});
// Check if the term is already in the collection…
if (existingData.terms.some(obj => obj.term === request.entry.term) === false) {
// … if not, add the new term and definition
existingData.terms.push({
"term": request.entry.term,
"definition": request.entry.definition,
"organisation": request.entry.organisation
});

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

// Send a response back
sendResponse({ response: "Term and definition added" });
// Send a response back
// sendResponse({ response: "Term and definition added" });
sendResponse({ response: "termAdded" });
} else {
// … if so, send a response back without adding the term
sendResponse({ response: "termNotAdded" });
}
});

// Keep the message channel open for asynchronous response
Expand Down

0 comments on commit 7ca29a6

Please sign in to comment.