From 6a1ea8eb7ddd3092163ac03375b71992603beabe Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sun, 31 Mar 2024 15:41:55 +0800 Subject: [PATCH] updated alerting methods Use both toasts and console. --- gui/scripts/alerts.js | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/gui/scripts/alerts.js b/gui/scripts/alerts.js index ba0473d..27307f4 100644 --- a/gui/scripts/alerts.js +++ b/gui/scripts/alerts.js @@ -2,16 +2,36 @@ Alert management system. */ -export function confirm_action() { - let user_response = false; +export default class alerts { + static confirm_action() { + let user_response = false; - (async () => { - // Import the module. - let reader = await import(chrome.runtime.getURL("gui/scripts/read.js")); + (async () => { + // Import the module. + let reader = (await import(chrome.runtime.getURL("gui/scripts/read.js")))[ + `texts` + ]; - // Get the user response. - user_response = confirm(reader.read(`GUI_alert_confirm_action_text`)); - })(); - // Return the user response. - return user_response; + // Get the user response. + user_response = confirm( + reader.localized(`GUI_alert_confirm_action_text`), + ); + })(); + // Return the user response. + return user_response; + } + + static log(message) { + console.log(message); + try { + M.toast({ text: message }); + } catch (err) {} + } + + static warn(message) { + console.warn(message); + try { + M.toast({ text: message }); + } catch (err) {} + } }