Support /cleartext (#1572)

This commit is contained in:
Annika
2020-07-26 15:33:37 -07:00
committed by GitHub
parent fcf50aab11
commit 96e45efc59
2 changed files with 28 additions and 1 deletions

View File

@@ -1425,6 +1425,7 @@
break;
case 'unlink':
// |unlink| is deprecated in favor of |hidelines|
// note: this message has global effects, but it's handled here
// so that it can be included in the scrollback buffer.
if (Dex.prefs('nounlink')) return;
@@ -1444,7 +1445,21 @@
this.$chat.children().last().append(' <button name="toggleMessages" value="' + user + '" class="subtle"><small>(' + $messages.length + ' line' + ($messages.length > 1 ? 's' : '') + ' from ' + user + ' hidden)</small></button>');
}
break;
case 'hidelines':
if (Dex.prefs('nounlink')) return;
var user = toID(row[2]);
var $messages = $('.chatmessage-' + user);
if (!$messages.length) break;
$messages.find('a').contents().unwrap();
if (row[1] !== 'unlink') {
$messages = this.$chat.find('.chatmessage-' + user);
if (!$messages.length) break;
var lineCount = parseInt(row[3], 10) || 0;
if (lineCount) $messages = $messages.slice(-lineCount);
$messages.hide().addClass('revealed').find('button').parent().remove();
if (row[1] === 'hide') this.$chat.children().last().append(' <button name="toggleMessages" value="' + user + '" class="subtle"><small>(' + $messages.length + ' line' + ($messages.length > 1 ? 's' : '') + ' from ' + user + ' hidden)</small></button>');
}
break;
case 'tournament':
case 'tournaments':
if (Dex.prefs('tournaments') === 'hide') {

View File

@@ -184,6 +184,7 @@ class BattleLog {
return;
case 'unlink': {
// |unlink| is deprecated in favor of |hidelines|
const user = toID(args[2]) || toID(args[1]);
this.unlinkChatFrom(user);
if (args[2]) {
@@ -192,6 +193,17 @@ class BattleLog {
}
return;
}
case 'hidelines': {
const user = toID(args[2]);
this.unlinkChatFrom(user);
if (args[1] !== 'unlink') {
const lineCount = parseInt(args[3], 10);
this.hideChatFrom(user, args[1] === 'hide', lineCount);
}
return;
}
case 'debug':
divClass = 'debug';
divHTML = '<div class="chat"><small style="color:#999">[DEBUG] ' + BattleLog.escapeHTML(args[1]) + '.</small></div>';