From 09453199b8edeaf3af9f0fd53c66eb3273ee7b7b Mon Sep 17 00:00:00 2001 From: GGThed Date: Fri, 7 Aug 2026 20:51:07 -0400 Subject: [PATCH] refactor(csp): migrer dix gabarits vers les comportements declaratifs OPS-010, suite. 76 gestionnaires en ligne -> 52, dans 5 gabarits au lieu de 15. Le cliquet de tests/test_csp.py est abaisse en consequence. Six motifs recurrents, generalises dans main.js plutot que traites un a un data-action clic, resolu par un ecouteur delegue data-change changement -- attribut distinct du clic, sans quoi un would +// otherwise fire its handler on the click that opens it. +document.addEventListener('change', function (event) { + dispatchAction('data-change', event); +}); + +/** + * Confirmation before a destructive submit. + * + *
+ * + * Replaces onsubmit="return confirm(...)", and keeps the wording in the + * markup where it can be translated. + */ +document.addEventListener('submit', function (event) { + const form = event.target.closest('[data-confirm]'); + if (form && !window.confirm(form.getAttribute('data-confirm'))) { + event.preventDefault(); + } +}); + +/** + * Navigate on selection. + * + * @@ -186,7 +186,7 @@
@@ -272,5 +272,15 @@ function hideRejectModal() { document.getElementById('rejectModal').style.display = 'none'; document.getElementById('rejection_reason').value = ''; } + +// Behaviours are declared in the markup with data-action / data-change and +// dispatched by the delegated listener in main.js. This replaces inline +// onclick attributes, which no CSP nonce is able to authorise. +registerActions({ + 'show-reject-modal': function (element) { + showRejectModal(element.getAttribute('data-request-id')); + }, + 'hide-reject-modal': hideRejectModal, +}); {% endblock %} \ No newline at end of file diff --git a/app/templates/pages/one_on_one.html b/app/templates/pages/one_on_one.html index 6f2f097..5b58f3d 100644 --- a/app/templates/pages/one_on_one.html +++ b/app/templates/pages/one_on_one.html @@ -130,7 +130,7 @@
- {% for d in dates %} {% endfor %} @@ -138,7 +138,7 @@
-
@@ -305,5 +305,13 @@ function updateEndTimeOptions() { } }); } + +// Behaviours are declared in the markup with data-action / data-change and +// dispatched by the delegated listener in main.js. This replaces inline +// onclick attributes, which no CSP nonce is able to authorise. +registerActions({ + 'update-time-slots': updateTimeSlots, + 'update-end-times': updateEndTimeOptions, +}); {% endblock %} \ No newline at end of file diff --git a/app/templates/pages/profile.html b/app/templates/pages/profile.html index 2c9fef1..17c3a8e 100644 --- a/app/templates/pages/profile.html +++ b/app/templates/pages/profile.html @@ -193,10 +193,10 @@

Loading...

- -
@@ -216,7 +216,7 @@

Loading availability grid...

-
@@ -599,6 +599,15 @@ function clearDisponibilities() { document.addEventListener('DOMContentLoaded', function() { renderDisponibilityGrid(); }); + +// Behaviours are declared in the markup with data-action / data-change and +// dispatched by the delegated listener in main.js. This replaces inline +// onclick attributes, which no CSP nonce is able to authorise. +registerActions({ + 'save-disponibilities': saveDisponibilities, + 'clear-disponibilities': clearDisponibilities, + 'clear-availability': clearAllAvailability, +}); {% endif %} {% endblock %} \ No newline at end of file diff --git a/app/templates/pages/register.html b/app/templates/pages/register.html index 8c5478a..e6cdabd 100644 --- a/app/templates/pages/register.html +++ b/app/templates/pages/register.html @@ -93,7 +93,7 @@ {% endfor %} @@ -172,6 +172,13 @@ document.addEventListener('DOMContentLoaded', function() { toggleGamertagInput(checkbox); }); }); + +// Behaviours are declared in the markup with data-action / data-change and +// dispatched by the delegated listener in main.js. This replaces inline +// onclick attributes, which no CSP nonce is able to authorise. +registerActions({ + 'toggle-gamertag': toggleGamertagInput, +});