diff --git a/js/client.js b/js/client.js index 5596dbf9676..c9c0cc9a01d 100644 --- a/js/client.js +++ b/js/client.js @@ -877,10 +877,11 @@ function toId() { serializeForm: function (form, checkboxOnOff) { // querySelector dates back to IE8 so we can use it // fortunate, because form serialization is a HUGE MESS in older browsers - var elements = form.querySelectorAll('input[name], select[name], textarea[name], keygen[name]'); + var elements = form.querySelectorAll('input[name], select[name], textarea[name], keygen[name], button[value]'); var out = []; for (var i = 0; i < elements.length; i++) { var element = elements[i]; + if ($(element).attr('type') === 'submit') continue; if (element.type === 'checkbox' && !element.value && checkboxOnOff) { out.push([element.name, element.checked ? 'on' : 'off']); } else if (!['checkbox', 'radio'].includes(element.type) || element.checked) { @@ -2113,12 +2114,15 @@ function toId() { }, dispatchClickButton: function (e) { var target = e.currentTarget; - if (target.name) { + var type = $(target).attr('type'); + if (type === 'submit') type = null; + if (target.name || type) { app.dismissingSource = app.dismissPopups(); app.dispatchingButton = target; e.preventDefault(); e.stopImmediatePropagation(); - this[target.name](target.value, target); + if (target.name && this[target.name]) this[target.name](target.value, target); + if (type && this[type]) this[type](target.value, target); delete app.dismissingSource; delete app.dispatchingButton; } @@ -2146,6 +2150,15 @@ function toId() { // }, + /** + * Used for , does format popup and caches value in button value + */ + selectformat: function (value, target) { + app.addPopup(FormatPopup, {format: 'gen9randombattle', sourceEl: target, selectType: 'watch', onselect: function (newFormat) { + target.value = newFormat; + }}); + }, + // layout bestWidth: 659, diff --git a/src/battle-log.ts b/src/battle-log.ts index cbacd789cb0..2d54337f5f7 100644 --- a/src/battle-log.ts +++ b/src/battle-log.ts @@ -759,6 +759,7 @@ export class BattleLog { username: 0, spotify: 0, youtube: 0, + formatselect: 0, twitch: 0, }); @@ -780,6 +781,7 @@ export class BattleLog { 'psicon::pokemon': 0, 'psicon::item': 0, 'psicon::type': 0, + 'selectformat::type': 0, 'psicon::category': 0, 'username::name': 0, 'form::data-submitsend': 0, @@ -913,6 +915,16 @@ export class BattleLog { 'frameborder', '0', 'allow', 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture', 'allowfullscreen', 'allowfullscreen', ], }; + } else if (tagName === 'formatselect') { + return { + tagName: 'button', + attribs: [ + 'type', 'selectformat', + 'class', "select formatselect", + 'value', getAttrib('value') || "gen9randombattle", + 'name', getAttrib('name') || '', + ], + }; } else if (tagName === 'psicon') { // is a custom element which supports a set of mutually incompatible attributes: // and