Skip to content

Commit ed6bb7f

Browse files
committed
Move JavaScript code from the global scope to a separate new scope.
1 parent ee2349e commit ed6bb7f

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

com.woltlab.wcf/templates/paidSubscriptionList.tpl

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
{capture assign='headContent'}
22
{if PAID_SUBSCRIPTION_ENABLE_TOS_CONFIRMATION}
33
<script data-relocate="true">
4-
const tosCheckbox = document.getElementById('tosConfirmed');
5-
const buttons = document.querySelectorAll('.paidSubscriptionList button');
6-
if (tosCheckbox) {
7-
function toggleButtons() {
8-
buttons.forEach(function(button) {
9-
button.disabled = !tosCheckbox.checked;
10-
});
4+
{
5+
const tosCheckbox = document.getElementById('tosConfirmed');
6+
const buttons = document.querySelectorAll('.paidSubscriptionList button');
7+
if (tosCheckbox) {
8+
function toggleButtons () {
9+
buttons.forEach(function(button) {
10+
button.disabled = !tosCheckbox.checked;
11+
});
12+
}
13+
14+
tosCheckbox.addEventListener('change', toggleButtons);
15+
toggleButtons();
1116
}
12-
tosCheckbox.addEventListener('change', toggleButtons);
13-
toggleButtons();
1417
}
1518
</script>
1619

0 commit comments

Comments
 (0)