Skip to content

Commit

Permalink
fix eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
modos189 committed Jan 20, 2024
1 parent d14c4ba commit 4d4ca3d
Showing 1 changed file with 32 additions and 38 deletions.
70 changes: 32 additions & 38 deletions core/code/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,19 +515,19 @@ window.chat.renderMarkup = function (markup) {

markup.forEach(function (ent, ind) {
switch (ent[0]) {
case 'SENDER':
case 'SECURE':
// skip as already handled
break;
case 'SENDER':
case 'SECURE':
// skip as already handled
break;

case 'PLAYER': // automatically generated messages
if (ind > 0) msg += chat.renderMarkupEntity(ent); // don’t repeat nick directly
break;
case 'PLAYER': // automatically generated messages
if (ind > 0) msg += chat.renderMarkupEntity(ent); // don’t repeat nick directly
break;

default:
// add other enitities whatever the type
msg += chat.renderMarkupEntity(ent);
break;
default:
// add other enitities whatever the type
msg += chat.renderMarkupEntity(ent);
break;
}
});
return msg;
Expand Down Expand Up @@ -563,27 +563,24 @@ function transformMessage(markup) {
}

window.chat.renderTimeCell = function (time, classNames) {
var ta = unixTimeToHHmm(time);
var tb = unixTimeToDateTimeString(time, true);
const ta = window.unixTimeToHHmm(time);
let tb = window.unixTimeToDateTimeString(time, true);
// add <small> tags around the milliseconds
tb = (tb.slice(0,19)+'<small class="milliseconds">'+tb.slice(19)+'</small>')
.replace(/</g,'&lt;')
.replace(/>/g,'&gt;')
.replace(/"/g,'&quot;');
return '<td><time class="' + classNames + '" title="'+tb+'" data-timestamp="'+time+'">'+ta+'</time></td>';
tb = (tb.slice(0, 19) + '<small class="milliseconds">' + tb.slice(19) + '</small>').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
return '<td><time class="' + classNames + '" title="' + tb + '" data-timestamp="' + time + '">' + ta + '</time></td>';
};

window.chat.renderNickCell = function(nick, classNames) {
var i = ['<span class="invisep">&lt;</span>', '<span class="invisep">&gt;</span>'];
return '<td>'+i[0]+'<mark class="' + classNames + '">'+ nick+'</mark>'+i[1]+'</td>';
window.chat.renderNickCell = function (nick, classNames) {
const i = ['<span class="invisep">&lt;</span>', '<span class="invisep">&gt;</span>'];
return '<td>' + i[0] + '<mark class="' + classNames + '">' + nick + '</mark>' + i[1] + '</td>';
};

window.chat.renderMsgCell = function(msg, classNames) {
return '<td class="' + classNames + '">'+msg+'</td>';
window.chat.renderMsgCell = function (msg, classNames) {
return '<td class="' + classNames + '">' + msg + '</td>';
};

window.chat.renderMsgRow = function(data) {
var timeClass = (data.msgToPlayer) ? 'pl_nudge_date' : '';
window.chat.renderMsgRow = function (data) {
var timeClass = data.msgToPlayer ? 'pl_nudge_date' : '';
var timeCell = chat.renderTimeCell(data.time, timeClass);

var nickClasses = ['nickname'];
Expand Down Expand Up @@ -612,32 +609,29 @@ window.chat.renderMsgRow = function(data) {
};

// legacy rendering, not used internaly, but left there for backward compatibilty in case a plugin uses it directly
window.chat.renderMsg = function(msg, nick, time, team, msgToPlayer, systemNarrowcast) {
var ta = unixTimeToHHmm(time);
var tb = unixTimeToDateTimeString(time, true);
window.chat.renderMsg = function (msg, nick, time, team, msgToPlayer, systemNarrowcast) {
const ta = window.unixTimeToHHmm(time);
let tb = window.unixTimeToDateTimeString(time, true);
// add <small> tags around the milliseconds
tb = (tb.slice(0,19)+'<small class="milliseconds">'+tb.slice(19)+'</small>')
.replace(/</g,'&lt;')
.replace(/>/g,'&gt;')
.replace(/"/g,'&quot;');
tb = (tb.slice(0, 19) + '<small class="milliseconds">' + tb.slice(19) + '</small>').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');

// help cursor via “#chat time”
var t = '<time title="'+tb+'" data-timestamp="'+time+'">'+ta+'</time>';
var t = '<time title="' + tb + '" data-timestamp="' + time + '">' + ta + '</time>';
if (msgToPlayer) {
t = '<div class="pl_nudge_date">' + t + '</div><div class="pl_nudge_pointy_spacer"></div>';
}
if (systemNarrowcast) {
msg = '<div class="system_narrowcast">' + msg + '</div>';
}
var color = COLORS[team];
var color = window.COLORS[team];
// highlight things said/done by the player in a unique colour (similar to @player mentions from others in the chat text itself)
if (nick === window.PLAYER.nickname) {
color = '#fd6';
}
var s = 'style="cursor:pointer; color:'+color+'"';
var i = ['<span class="invisep">&lt;</span>', '<span class="invisep">&gt;</span>'];
return '<tr><td>'+t+'</td><td>'+i[0]+'<mark class="nickname" ' + s + '>'+ nick+'</mark>'+i[1]+'</td><td>'+msg+'</td></tr>';
}
const s = 'style="cursor:pointer; color:' + color + '"';
const i = ['<span class="invisep">&lt;</span>', '<span class="invisep">&gt;</span>'];
return '<tr><td>' + t + '</td><td>' + i[0] + '<mark class="nickname" ' + s + '>' + nick + '</mark>' + i[1] + '</td><td>' + msg + '</td></tr>';
};

window.chat.renderDivider = function(text) {
return '<tr class="divider"><td><hr></td><td>' + text + '</td><td><hr></td></tr>';
Expand Down

0 comments on commit 4d4ca3d

Please sign in to comment.