diff --git a/language/en/webpushnotifications_module_acp.php b/language/en/webpushnotifications_module_acp.php index bf4edbe..9d83cd0 100644 --- a/language/en/webpushnotifications_module_acp.php +++ b/language/en/webpushnotifications_module_acp.php @@ -51,6 +51,6 @@ 'WEBPUSH_DROPDOWN_SUBSCRIBE' => 'Show web push settings in the notification dropdown', 'WEBPUSH_DROPDOWN_SUBSCRIBE_EXPLAIN'=> 'Show or hide the “Enable Web Push” toggle switch in the notification dropdown. This allows users to easily enable or disable push notifications from any page of the forum.', 'WEBPUSH_POPUP_PROMPT' => 'Show popup prompt for unsubscribed members', - 'WEBPUSH_POPUP_PROMPT_EXPLAIN' => 'Display a popup message asking registered members if they want to receive push notifications. The popup will only appear to members who are not currently subscribed and have not previously declined.', + 'WEBPUSH_POPUP_PROMPT_EXPLAIN' => 'Display a popup message asking registered members if they want to receive push notifications. The popup will only appear to members who are not currently subscribed and have not previously denied.', 'WEBPUSH_INSECURE_SERVER_ERROR' => 'This board is not using a secure SSL/HTTPS protocol, which is required for enabling web push notifications. Alternatively, the server environment might be misconfigured. Ensure that the HTTPS and HEADER_CLIENT_PROTO server environment variables are correctly configured.', ]); diff --git a/language/en/webpushnotifications_module_ucp.php b/language/en/webpushnotifications_module_ucp.php index 31ed884..be503ca 100644 --- a/language/en/webpushnotifications_module_ucp.php +++ b/language/en/webpushnotifications_module_ucp.php @@ -52,5 +52,5 @@ 'NOTIFY_WEBPUSH_POPUP_TITLE' => 'Allow browser notifications?', 'NOTIFY_WEBPUSH_POPUP_MESSAGE' => 'We would like to send you browser notifications for replies, private messages, and relevant forum activity. Optional — you can manage these settings at any time.', 'NOTIFY_WEBPUSH_POPUP_ALLOW' => 'Allow', - 'NOTIFY_WEBPUSH_POPUP_DECLINE' => 'Decline', + 'NOTIFY_WEBPUSH_POPUP_DENY' => 'Deny', ]); diff --git a/language/ru/webpushnotifications_module_ucp.php b/language/ru/webpushnotifications_module_ucp.php index 6b08e2b..10b5e7a 100644 --- a/language/ru/webpushnotifications_module_ucp.php +++ b/language/ru/webpushnotifications_module_ucp.php @@ -52,5 +52,5 @@ 'NOTIFY_WEBPUSH_POPUP_TITLE' => 'Включить браузерные уведомления?', 'NOTIFY_WEBPUSH_POPUP_MESSAGE' => 'Браузерные уведомления позволяют быстро получать информацию о новых ответах, личных сообщениях и других активностях на данной конференции. Функцию можно отключить или включить в любое время в настройках уведомлений в Личном разделе.', 'NOTIFY_WEBPUSH_POPUP_ALLOW' => 'Включить', - 'NOTIFY_WEBPUSH_POPUP_DECLINE' => 'Отклонить', + 'NOTIFY_WEBPUSH_POPUP_DENY' => 'Отклонить', ]); diff --git a/styles/all/template/webpush.js b/styles/all/template/webpush.js index 0968dff..e57b5d3 100644 --- a/styles/all/template/webpush.js +++ b/styles/all/template/webpush.js @@ -1,8 +1,8 @@ /* global phpbb */ -'use strict'; - function PhpbbWebpush() { + 'use strict'; + /** @type {string} URL to service worker */ let serviceWorkerUrl = ''; @@ -126,8 +126,8 @@ function PhpbbWebpush() { return; } - // Check if user declined on this browser - if (getDeclined() === 'true') { + // Check if user denied prompt on this browser + if (promptDenied.get() === 'true') { return; } @@ -157,22 +157,24 @@ function PhpbbWebpush() { }, 1000); const allowBtn = document.getElementById('wpn_popup_allow'); - const declineBtn = document.getElementById('wpn_popup_decline'); + const denyBtn = document.getElementById('wpn_popup_deny'); const overlay = document.getElementById('wpn_popup_prompt'); if (allowBtn) { allowBtn.addEventListener('click', (event) => { event.stopPropagation(); popup.style.display = 'none'; - subscribeButtonHandler({ preventDefault: () => {} }); + subscribeButtonHandler({ + preventDefault: () => {} + }); }); } - if (declineBtn) { - declineBtn.addEventListener('click', (event) => { + if (denyBtn) { + denyBtn.addEventListener('click', (event) => { event.stopPropagation(); popup.style.display = 'none'; - setDeclined(); + promptDenied.set(); }); } @@ -180,7 +182,7 @@ function PhpbbWebpush() { overlay.addEventListener('click', (event) => { if (event.target === overlay) { popup.style.display = 'none'; - setDeclined(); + promptDenied.set(); } }); } @@ -328,7 +330,7 @@ function PhpbbWebpush() { if ('form_tokens' in response) { updateFormTokens(response.form_tokens); } - resetDeclined(); + promptDenied.remove(); const popup = document.getElementById('wpn_popup_prompt'); if (popup) { popup.style.display = 'none'; @@ -379,18 +381,26 @@ function PhpbbWebpush() { return outputArray; } - function setDeclined() { - localStorage.setItem('wpn_popup_declined', 'true'); - } - function getDeclined() { - return localStorage.getItem('wpn_popup_declined'); - } - function resetDeclined() { - localStorage.removeItem('wpn_popup_declined'); - } + const promptDenied = { + key: 'wpn_popup_denied', + + set() { + localStorage.setItem(this.key, 'true'); + }, + + get() { + return localStorage.getItem(this.key); + }, + + remove() { + localStorage.removeItem(this.key); + } + }; } function domReady(callBack) { + 'use strict'; + if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', callBack); } else { @@ -401,6 +411,8 @@ function domReady(callBack) { phpbb.webpush = new PhpbbWebpush(); domReady(() => { + 'use strict'; + /* global phpbbWebpushOptions */ phpbb.webpush.init(phpbbWebpushOptions); }); diff --git a/styles/all/template/webpush_popup.html b/styles/all/template/webpush_popup.html index ef893c6..deb9133 100644 --- a/styles/all/template/webpush_popup.html +++ b/styles/all/template/webpush_popup.html @@ -2,11 +2,17 @@