mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-10-03 00:01:29 -05:00
Support uhtml in battles
Supporting it actually turns out to be very simple, so we might as well. In practice, we probably want to never use this feature for broadcast messages - I don't think I want it in replays. It could still be nice for stuff like /roomsettings, though.
This commit is contained in:
@@ -104,6 +104,10 @@ class BattleLog {
|
||||
divHTML = BattleLog.sanitizeHTML(args[1]);
|
||||
break;
|
||||
|
||||
case 'uhtml': case 'uhtmlchange':
|
||||
this.changeUhtml(args[1], args[2], args[0] === 'uhtml');
|
||||
return ['', ''];
|
||||
|
||||
case 'error': case 'inactive': case 'inactiveoff':
|
||||
divClass = 'chat message-error';
|
||||
divHTML = BattleLog.escapeHTML(args[1]);
|
||||
@@ -237,9 +241,11 @@ class BattleLog {
|
||||
elements.push(node);
|
||||
}
|
||||
}
|
||||
for (const node of this.preemptElem.childNodes as any) {
|
||||
if (node.className && (' ' + node.className + ' ').includes(classContains)) {
|
||||
elements.push(node);
|
||||
if (this.preemptElem) {
|
||||
for (const node of this.preemptElem.childNodes as any) {
|
||||
if (node.className && (' ' + node.className + ' ').includes(classContains)) {
|
||||
elements.push(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (html && elements.length && !forceAdd) {
|
||||
|
||||
@@ -3162,7 +3162,7 @@ class Battle {
|
||||
case 'fieldhtml': case 'controlshtml': case 'bigerror':
|
||||
case 'debug': case 'tier':
|
||||
return {args: [cmd, str.slice(index + 1)], kwArgs: {}};
|
||||
case 'c': case 'chat':
|
||||
case 'c': case 'chat': case 'uhtml': case 'uhtmlchange':
|
||||
// three parts
|
||||
const index2a = str.indexOf('|', index + 1);
|
||||
return {args: [cmd, str.slice(index + 1, index2a), str.slice(index2a + 1)], kwArgs: {}};
|
||||
|
||||
Reference in New Issue
Block a user