From 7d5128655d6211b5668853d064e13afd1448048f Mon Sep 17 00:00:00 2001
From: Craig
Date: Thu, 25 Dec 2025 16:22:40 -0500
Subject: [PATCH 1/3] store form reference and find format button dynamically
---
.../js/client-mainmenu.js | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/play.pokemonshowdown.com/js/client-mainmenu.js b/play.pokemonshowdown.com/js/client-mainmenu.js
index 6850c57b0b2..c51f2814370 100644
--- a/play.pokemonshowdown.com/js/client-mainmenu.js
+++ b/play.pokemonshowdown.com/js/client-mainmenu.js
@@ -1280,7 +1280,8 @@
if (!this.search) this.search = "";
this.onselect = data.onselect;
this.selectType = data.selectType;
- if (!this.selectType) this.selectType = (this.sourceEl.closest('form').data('search') ? 'search' : 'challenge');
+ this.$form = this.sourceEl.closest('form');
+ if (!this.selectType) this.selectType = (this.$form.data('search') ? 'search' : 'challenge');
var html = '
';
@@ -1402,17 +1403,19 @@
return true;
},
selectFormat: function (format) {
+ var $form = this.$form.length ? this.$form : this.sourceEl.closest('form');
+
if (this.onselect) {
this.onselect(format);
} else if (app.rooms[''].curFormat !== format) {
app.rooms[''].curFormat = format;
app.rooms[''].curTeamIndex = -1;
- var $teamButton = this.sourceEl.closest('form').find('button[name=team]');
+ var $teamButton = $form.find('button[name=team]');
if ($teamButton.length) $teamButton.replaceWith(app.rooms[''].renderTeams(format));
- var $bestOfCheckbox = this.sourceEl.closest('form').find('input[name=bestof]');
- var $bestOfValueInput = this.sourceEl.closest('form').find('input[name=bestofvalue]');
- if ($bestOfCheckbox && $bestOfValueInput) {
+ var $bestOfCheckbox = $form.find('input[name=bestof]');
+ var $bestOfValueInput = $form.find('input[name=bestofvalue]');
+ if ($bestOfCheckbox.length && $bestOfValueInput.length) {
var $parentTag = $bestOfCheckbox.parent().parent();
var bestOfDefault = BattleFormats[format] && BattleFormats[format].bestOfDefault;
if (bestOfDefault) {
@@ -1424,8 +1427,8 @@
}
}
- var $teraPreviewCheckbox = this.sourceEl.closest('form').find('input[name=terapreview]');
- if ($teraPreviewCheckbox) {
+ var $teraPreviewCheckbox = $form.find('input[name=terapreview]');
+ if ($teraPreviewCheckbox.length) {
var $parentTag = $teraPreviewCheckbox.parent().parent();
var teraPreviewDefault = BattleFormats[format] && BattleFormats[format].teraPreviewDefault;
if (teraPreviewDefault) {
@@ -1441,7 +1444,7 @@
label.style.display = BattleFormats[format].partner ? '' : 'none';
});
}
- this.sourceEl.val(format).html(BattleLog.escapeFormat(format) || '(Select a format)');
+ $form.find('button[name=format]').val(format).html(BattleLog.escapeFormat(format) || '(Select a format)');;
this.close();
}
From 316f652d441df5a8e16fd88d932884180bb5b3c2 Mon Sep 17 00:00:00 2001
From: Craig
Date: Thu, 25 Dec 2025 16:53:31 -0500
Subject: [PATCH 2/3] formatting
---
play.pokemonshowdown.com/js/client-mainmenu.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/play.pokemonshowdown.com/js/client-mainmenu.js b/play.pokemonshowdown.com/js/client-mainmenu.js
index c51f2814370..82d53619e66 100644
--- a/play.pokemonshowdown.com/js/client-mainmenu.js
+++ b/play.pokemonshowdown.com/js/client-mainmenu.js
@@ -1444,7 +1444,7 @@
label.style.display = BattleFormats[format].partner ? '' : 'none';
});
}
- $form.find('button[name=format]').val(format).html(BattleLog.escapeFormat(format) || '(Select a format)');;
+ $form.find('button[name=format]').val(format).html(BattleLog.escapeFormat(format) || '(Select a format)');
this.close();
}
From 56e8ae258213887e56b9486b89dee7923645613b Mon Sep 17 00:00:00 2001
From: Craig
Date: Thu, 25 Dec 2025 16:57:05 -0500
Subject: [PATCH 3/3] appease our linter overlords
---
play.pokemonshowdown.com/js/client-mainmenu.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/play.pokemonshowdown.com/js/client-mainmenu.js b/play.pokemonshowdown.com/js/client-mainmenu.js
index 82d53619e66..e3475107813 100644
--- a/play.pokemonshowdown.com/js/client-mainmenu.js
+++ b/play.pokemonshowdown.com/js/client-mainmenu.js
@@ -1404,7 +1404,7 @@
},
selectFormat: function (format) {
var $form = this.$form.length ? this.$form : this.sourceEl.closest('form');
-
+
if (this.onselect) {
this.onselect(format);
} else if (app.rooms[''].curFormat !== format) {