Skip to main content

max / makenotwork

1.1 KB · 23 lines History Blame Raw
1 // Delegated event handlers extracted from inline on* attributes in the
2 // dashboard, dashboard editor, embed, and wizard templates, moved here for CSP
3 // compliance (so script-src can drop 'unsafe-inline'). The dispatcher in
4 // the core module invokes each of these by name with `this` bound to the dispatching
5 // element and any data-arg/data-arg2 attributes passed as arguments. Bodies
6 // are preserved verbatim from the original inline handlers.
7
8 // Reactivate-account form: schedule a page reload after the HTMX request.
9 window.reactivateReload = function () {
10 setTimeout(function(){ window.location.reload(); }, 500);
11 };
12
13 // Copy the item id to the clipboard and flash feedback on the button.
14 window.onCopyItemId = function (id) {
15 navigator.clipboard.writeText(id); this.textContent='Copied!'; setTimeout(()=>this.textContent='Copy Item ID', 1500);
16 };
17
18 // Custom page reset form: confirm before submitting. data-submit auto-prevents
19 // the native submit, so re-submit programmatically when confirmed.
20 window.confirmResetPage = function () {
21 if (confirm('Reset this page to the platform default? This clears your custom HTML and CSS.')) this.submit();
22 };
23