mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-08-22 19:11:12 -05:00
Support text formatting in |error| (#1652)
This commit is contained in:
@@ -1448,7 +1448,7 @@
|
||||
break;
|
||||
|
||||
case 'error':
|
||||
this.$chat.append('<div class="notice message-error">' + BattleLog.escapeHTML(row.slice(1).join('|')) + '</div>');
|
||||
this.$chat.append('<div class="notice message-error">' + BattleLog.parseMessage(row.slice(1).join('|'), true) + '</div>');
|
||||
break;
|
||||
|
||||
case 'uhtml':
|
||||
|
||||
@@ -614,7 +614,7 @@ class BattleLog {
|
||||
case 'text':
|
||||
return ['chat', BattleLog.parseMessage(target)];
|
||||
case 'error':
|
||||
return ['chat message-error', BattleLog.escapeHTML(target)];
|
||||
return ['chat message-error', formatText(target, true)];
|
||||
case 'html':
|
||||
return [
|
||||
'chat chatmessage-' + toID(name) + hlClass + mineClass,
|
||||
@@ -645,12 +645,12 @@ class BattleLog {
|
||||
}
|
||||
}
|
||||
|
||||
static parseMessage(str: string) {
|
||||
static parseMessage(str: string, isTrusted = false) {
|
||||
// Don't format console commands (>>).
|
||||
if (str.substr(0, 3) === '>> ' || str.substr(0, 4) === '>>> ') return this.escapeHTML(str);
|
||||
// Don't format console results (<<).
|
||||
if (str.substr(0, 3) === '<< ') return this.escapeHTML(str);
|
||||
str = formatText(str);
|
||||
str = formatText(str, isTrusted);
|
||||
|
||||
let options = BattleLog.prefs('chatformatting') || {};
|
||||
|
||||
|
||||
2
src/globals.d.ts
vendored
2
src/globals.d.ts
vendored
@@ -29,7 +29,7 @@ declare var BattlePokemonSpritesBW: any;
|
||||
|
||||
// defined in battle-log-misc
|
||||
declare function MD5(input: string): string;
|
||||
declare function formatText(input: string): string;
|
||||
declare function formatText(input: string, isTrusted?: boolean): string;
|
||||
|
||||
// PS globals
|
||||
/////////////
|
||||
|
||||
Reference in New Issue
Block a user