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:
Guangcong Luo
2018-11-17 13:59:06 -06:00
parent 8669bae196
commit 6464a97641
2 changed files with 10 additions and 4 deletions

View File

@@ -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) {

View File

@@ -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: {}};