From b2c7ca31da2e5b8d6f293fae82c5e83f962b28f5 Mon Sep 17 00:00:00 2001 From: Aevann Date: Tue, 7 Mar 2023 02:21:08 +0200 Subject: [PATCH] move disabling buttons to bottom.js --- files/assets/js/bottom.js | 21 +++++++++++++++++++-- files/assets/js/core.js | 6 ------ files/templates/admin/alt_votes.html | 2 +- files/templates/admin/alts.html | 2 +- files/templates/admin/badge_admin.html | 2 +- files/templates/admin/banned_domains.html | 2 +- files/templates/admin/edit_rules.html | 2 +- files/templates/admin/update_assets.html | 2 +- files/templates/chat.html | 2 +- files/templates/contact.html | 2 +- files/templates/errors/nsfw.html | 2 +- files/templates/login/forgot_password.html | 2 +- files/templates/login/lost_2fa.html | 2 +- files/templates/login/reset_password.html | 2 +- files/templates/oauth.html | 2 +- files/templates/post_actions.html | 2 +- files/templates/post_actions_mobile.html | 2 +- files/templates/settings/advanced.html | 2 +- files/templates/settings/apps.html | 6 +++--- files/templates/settings/common.html | 4 ++-- files/templates/settings/css.html | 4 ++-- files/templates/settings/personal.html | 4 ++-- files/templates/settings/security.html | 10 +++++----- files/templates/sub/exilees.html | 2 +- files/templates/sub/mods.html | 4 ++-- files/templates/sub/settings.html | 4 ++-- files/templates/submission.html | 2 +- files/templates/submit_hats.html | 2 +- files/templates/submit_marseys.html | 2 +- files/templates/userpage/admintools.html | 12 ++++++------ files/templates/userpage/banner.html | 4 ++-- 31 files changed, 65 insertions(+), 54 deletions(-) diff --git a/files/assets/js/bottom.js b/files/assets/js/bottom.js index a1a07d351..d3adf48c6 100644 --- a/files/assets/js/bottom.js +++ b/files/assets/js/bottom.js @@ -97,6 +97,15 @@ for (const element of TH) { element.addEventListener('click', () => {sort_table(element)}); } +function disable_btn(t) { + t.disabled = true + t.classList.add('disabled'); + setTimeout(() => { + t.disabled = false; + t.classList.remove("disabled"); + }, 2000); +} + function register_new_elements(e) { const showmores = document.getElementsByClassName('showmore') for (const element of showmores) { @@ -105,7 +114,10 @@ function register_new_elements(e) { const onclick = e.querySelectorAll('[data-onclick]'); for (const element of onclick) { - element.onclick = () => {execute(element, 'onclick')}; + element.onclick = () => { + execute(element, 'onclick') + disable_btn(element) + }; } const oninput = e.querySelectorAll('[data-oninput]'); @@ -162,7 +174,12 @@ function register_new_elements(e) { element.addEventListener('click', () => { document.getElementById('giveaward').dataset.action = element.dataset.url }); - } + } + + const btns_to_disable = document.querySelectorAll('[type="submit"]') + for (const btn of btns_to_disable) { + btn.addEventListener('click') = disable_btn + } } register_new_elements(document); diff --git a/files/assets/js/core.js b/files/assets/js/core.js index 343d1f7ac..6131eb3b7 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -133,12 +133,6 @@ if (!location.pathname.endsWith('/submit')) }); } -function disable(t) { - t.classList.add('disabled'); - setTimeout(() => { - t.classList.remove("disabled"); - }, 2000); -} function autoExpand(field) { xpos=window.scrollX; diff --git a/files/templates/admin/alt_votes.html b/files/templates/admin/alt_votes.html index 46c6f029a..a14888f63 100644 --- a/files/templates/admin/alt_votes.html +++ b/files/templates/admin/alt_votes.html @@ -7,7 +7,7 @@ - + {% if u1 and u2 %} diff --git a/files/templates/admin/alts.html b/files/templates/admin/alts.html index 91f6e4114..0887fc4e2 100644 --- a/files/templates/admin/alts.html +++ b/files/templates/admin/alts.html @@ -10,7 +10,7 @@
- +
{% if u %} diff --git a/files/templates/admin/badge_admin.html b/files/templates/admin/badge_admin.html index 34bac5cc4..234d3eecd 100644 --- a/files/templates/admin/badge_admin.html +++ b/files/templates/admin/badge_admin.html @@ -52,7 +52,7 @@ {% endif %} - + diff --git a/files/templates/admin/banned_domains.html b/files/templates/admin/banned_domains.html index 95578cc50..1e72537a6 100644 --- a/files/templates/admin/banned_domains.html +++ b/files/templates/admin/banned_domains.html @@ -33,7 +33,7 @@ - + diff --git a/files/templates/admin/edit_rules.html b/files/templates/admin/edit_rules.html index 67cf917c2..d7225362d 100644 --- a/files/templates/admin/edit_rules.html +++ b/files/templates/admin/edit_rules.html @@ -18,7 +18,7 @@
- +
diff --git a/files/templates/admin/update_assets.html b/files/templates/admin/update_assets.html index bcba1d6ce..590dba5c0 100644 --- a/files/templates/admin/update_assets.html +++ b/files/templates/admin/update_assets.html @@ -32,7 +32,7 @@ {% endif %} diff --git a/files/templates/chat.html b/files/templates/chat.html index ada99e044..6321aee24 100644 --- a/files/templates/chat.html +++ b/files/templates/chat.html @@ -123,7 +123,7 @@ - + diff --git a/files/templates/contact.html b/files/templates/contact.html index 0ae236301..75907771e 100644 --- a/files/templates/contact.html +++ b/files/templates/contact.html @@ -18,7 +18,7 @@ {{macros.file_input('file-uplod', False)}} - + diff --git a/files/templates/errors/nsfw.html b/files/templates/errors/nsfw.html index 1376f28cf..ed9d92386 100644 --- a/files/templates/errors/nsfw.html +++ b/files/templates/errors/nsfw.html @@ -12,7 +12,7 @@
- +
No
diff --git a/files/templates/login/forgot_password.html b/files/templates/login/forgot_password.html index 361daddf2..00c001a5a 100644 --- a/files/templates/login/forgot_password.html +++ b/files/templates/login/forgot_password.html @@ -9,7 +9,7 @@ - + {% endblock %} diff --git a/files/templates/login/lost_2fa.html b/files/templates/login/lost_2fa.html index a54d8b857..9feff857e 100644 --- a/files/templates/login/lost_2fa.html +++ b/files/templates/login/lost_2fa.html @@ -11,7 +11,7 @@ - + {% endblock %} diff --git a/files/templates/login/reset_password.html b/files/templates/login/reset_password.html index 0ffee1808..bd340fdde 100644 --- a/files/templates/login/reset_password.html +++ b/files/templates/login/reset_password.html @@ -11,7 +11,7 @@ - + {% endblock %} diff --git a/files/templates/oauth.html b/files/templates/oauth.html index 147c7090c..3545d407a 100644 --- a/files/templates/oauth.html +++ b/files/templates/oauth.html @@ -12,7 +12,7 @@ - + No, back to {{SITE_NAME}} diff --git a/files/templates/post_actions.html b/files/templates/post_actions.html index e99ed21ec..6aab82c62 100644 --- a/files/templates/post_actions.html +++ b/files/templates/post_actions.html @@ -1,7 +1,7 @@ {% if v and v.id==p.author_id and p.private %}
- +
{% endif %} diff --git a/files/templates/post_actions_mobile.html b/files/templates/post_actions_mobile.html index 8b43f23de..6e28cb320 100644 --- a/files/templates/post_actions_mobile.html +++ b/files/templates/post_actions_mobile.html @@ -1,7 +1,7 @@ {% if v and v.id==p.author_id and p.private %}
- +
{% endif %} diff --git a/files/templates/settings/advanced.html b/files/templates/settings/advanced.html index 677f0e1c2..22472fb9d 100644 --- a/files/templates/settings/advanced.html +++ b/files/templates/settings/advanced.html @@ -146,7 +146,7 @@ rows="3" name="filters" form="custom-filter" maxlength="1000">{% if v.custom_filter_list %}{{v.custom_filter_list}}{% endif %}
Use a new line for each filter entry. Limit of 1000 characters. - +
diff --git a/files/templates/settings/apps.html b/files/templates/settings/apps.html index 2a19b6f1c..0fdfdf170 100644 --- a/files/templates/settings/apps.html +++ b/files/templates/settings/apps.html @@ -32,7 +32,7 @@ @@ -67,7 +67,7 @@ @@ -118,7 +118,7 @@ diff --git a/files/templates/settings/common.html b/files/templates/settings/common.html index b6e6d28da..b05342432 100644 --- a/files/templates/settings/common.html +++ b/files/templates/settings/common.html @@ -65,7 +65,7 @@
{% endif %} {{below_text}} - + @@ -94,7 +94,7 @@ {% endif %}
{{below_text}} - +
diff --git a/files/templates/settings/css.html b/files/templates/settings/css.html index 7143bfec5..b6b279526 100644 --- a/files/templates/settings/css.html +++ b/files/templates/settings/css.html @@ -14,7 +14,7 @@ Limit of {{CSS_LENGTH_LIMIT}} characters
- +
@@ -32,7 +32,7 @@ Limit of {{CSS_LENGTH_LIMIT}} characters
- +
diff --git a/files/templates/settings/personal.html b/files/templates/settings/personal.html index 6075667d7..8877b9082 100644 --- a/files/templates/settings/personal.html +++ b/files/templates/settings/personal.html @@ -166,7 +166,7 @@ 3-25 characters, including letters, numbers, _ , and -
- +
@@ -203,7 +203,7 @@
- +

In some browsers, users have to click at least once anywhere in the profile page for the anthem to play. diff --git a/files/templates/settings/security.html b/files/templates/settings/security.html index 017a95ec7..5e128bebe 100644 --- a/files/templates/settings/security.html +++ b/files/templates/settings/security.html @@ -38,9 +38,9 @@ {% endif %} {% if v.email %} - + {% else %} - + {% endif %} {% if FEATURES['MARSEYBUX'] %} @@ -81,7 +81,7 @@
- +
@@ -119,7 +119,7 @@ @@ -222,7 +222,7 @@ diff --git a/files/templates/sub/exilees.html b/files/templates/sub/exilees.html index 65a915cd4..23aaf6d5f 100644 --- a/files/templates/sub/exilees.html +++ b/files/templates/sub/exilees.html @@ -26,7 +26,7 @@ {% if v.mods(sub.name) %}
- +
{% endif %} diff --git a/files/templates/sub/mods.html b/files/templates/sub/mods.html index 5c9557239..84bfda14b 100644 --- a/files/templates/sub/mods.html +++ b/files/templates/sub/mods.html @@ -24,7 +24,7 @@
- +
{% endif %} @@ -37,7 +37,7 @@
- +
{% endif %} diff --git a/files/templates/sub/settings.html b/files/templates/sub/settings.html index da0409c92..148200783 100644 --- a/files/templates/sub/settings.html +++ b/files/templates/sub/settings.html @@ -110,7 +110,7 @@
- +
@@ -131,7 +131,7 @@
- +
diff --git a/files/templates/submission.html b/files/templates/submission.html index ccd328a2f..27f9c95da 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -182,7 +182,7 @@ Formatting help - +
diff --git a/files/templates/submit_hats.html b/files/templates/submit_hats.html index 01a43c1b3..c584e1716 100644 --- a/files/templates/submit_hats.html +++ b/files/templates/submit_hats.html @@ -38,7 +38,7 @@ diff --git a/files/templates/submit_marseys.html b/files/templates/submit_marseys.html index f7444e0fe..530c3101b 100644 --- a/files/templates/submit_marseys.html +++ b/files/templates/submit_marseys.html @@ -33,7 +33,7 @@ diff --git a/files/templates/userpage/admintools.html b/files/templates/userpage/admintools.html index 203ddae92..337f74fd8 100644 --- a/files/templates/userpage/admintools.html +++ b/files/templates/userpage/admintools.html @@ -35,7 +35,7 @@ - + @@ -52,7 +52,7 @@ - + {% endif %} {% if v.admin_level >= PERMS['USER_SHADOWBAN'] %} @@ -61,7 +61,7 @@
- +
{% endif %} {% if v.admin_level >= PERMS['USER_AGENDAPOSTER'] %} @@ -70,7 +70,7 @@
- +
{% endif %} @@ -93,12 +93,12 @@
- +
- +
{% endif %} diff --git a/files/templates/userpage/banner.html b/files/templates/userpage/banner.html index d0828c688..9cd524650 100644 --- a/files/templates/userpage/banner.html +++ b/files/templates/userpage/banner.html @@ -161,7 +161,7 @@ {{macros.file_input('file-upload', True)}} - +
@@ -464,7 +464,7 @@ {{macros.file_input('file-upload-mobile', True)}} - +