more chat changes
- remove public @mentions from the faction chat channel - add default case to chat text handling. if a new message fragment type is added, at least something will be shown in chat instead of being blank (as happened when AT_PLAYER was first introduced) - highlight your own player name in the chat column in yellow for things you said/actions performed - similar to @mentions from other players
This commit is contained in:
parent
8b2472701a
commit
f48aca8864
44
code/chat.js
44
code/chat.js
@ -241,12 +241,12 @@ window.chat.renderFull = function(oldMsgsWereAdded) {
|
||||
// common
|
||||
//
|
||||
|
||||
window.chat.writeDataToHash = function(newData, storageHash, skipSecureMsgs) {
|
||||
window.chat.writeDataToHash = function(newData, storageHash, isPublicChannel) {
|
||||
$.each(newData.result, function(ind, json) {
|
||||
// avoid duplicates
|
||||
if(json[0] in storageHash.data) return true;
|
||||
|
||||
var skipThisEntry = false;
|
||||
var isSecureMessage = false;
|
||||
var msgToPlayer = false;
|
||||
|
||||
var time = json[1];
|
||||
@ -259,10 +259,7 @@ window.chat.writeDataToHash = function(newData, storageHash, skipSecureMsgs) {
|
||||
if (storageHash.newestTimestamp === -1 || storageHash.newestTimestamp < time) storageHash.newestTimestamp = time;
|
||||
|
||||
//remove "Your X on Y was destroyed by Z" from the faction channel
|
||||
if (systemNarrowcast && !skipSecureMsgs) {
|
||||
//NOTE: skipSecureMsgs is being used as a "is public channel" flag here
|
||||
return true;
|
||||
}
|
||||
if (systemNarrowcast && !isPublicChannel) return true;
|
||||
|
||||
var msg = '', nick = '', pguid;
|
||||
$.each(json[2].plext.markup, function(ind, markup) {
|
||||
@ -306,13 +303,34 @@ window.chat.writeDataToHash = function(newData, storageHash, skipSecureMsgs) {
|
||||
break;
|
||||
|
||||
case 'SECURE':
|
||||
if(skipSecureMsgs) {
|
||||
skipThisEntry = true;
|
||||
return false; // breaks $.each
|
||||
}
|
||||
//NOTE: we won't add the '[secure]' string here - it'll be handled below instead
|
||||
isSecureMessage = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
//handle unknown types by outputting the plain text version, marked with it's type
|
||||
msg += $('<div/>').text(markup[0]+':<'+markup[1].plain+'>').html();
|
||||
break;
|
||||
}
|
||||
});
|
||||
if(skipThisEntry) return true;
|
||||
|
||||
|
||||
//skip secure messages on the public channel
|
||||
if (isPublicChannel && isSecureMessage) return true;
|
||||
|
||||
//skip public messages (e.g. @player mentions) on the secure channel
|
||||
if ((!isPublicChannel) && (!isSecureMessage)) return true;
|
||||
|
||||
|
||||
//NOTE: these two are currently redundant with the above two tests - but code can change...
|
||||
//from the server, private channel messages are flagged with a SECURE string '[secure] ', and appear in
|
||||
//both the public and private channels
|
||||
//we don't include this '[secure]' text above, as it's redundant in the faction-only channel
|
||||
//let's add it here though if we have a secure message in the public channel, or the reverse if a non-secure in the faction one
|
||||
if (isPublicChannel && isSecureMessage) msg = '<span style="color: #f66">[secure]</span> ' + msg;
|
||||
//and, add the reverse - a 'public' marker to messages in the private channel
|
||||
if ((!isPublicChannel) && (!isSecureMessage)) msg = '<span style="color: #ff6">[public]</span> ' + msg;
|
||||
|
||||
|
||||
// format: timestamp, autogenerated, HTML message, player guid
|
||||
storageHash.data[json[0]] = [json[1], auto, chat.renderMsg(msg, nick, time, team, msgToPlayer, systemNarrowcast), pguid];
|
||||
@ -378,7 +396,9 @@ window.chat.renderMsg = function(msg, nick, time, team, msgToPlayer, systemNarro
|
||||
{
|
||||
msg = '<div class="system_narrowcast">' + msg + '</div>';
|
||||
}
|
||||
var s = 'style="cursor:pointer; color:'+COLORS[team]+'"';
|
||||
var color = COLORS[team];
|
||||
if (nick === window.PLAYER.nickname) color = '#fd6'; //highlight things said/done by the player in a unique colour (similar to @player mentions from others in the chat text itself)
|
||||
var s = 'style="cursor:pointer; color:'+color+'"';
|
||||
var title = nick.length >= 8 ? 'title="'+nick+'" class="help"' : '';
|
||||
var i = ['<span class="invisep"><</span>', '<span class="invisep">></span>'];
|
||||
return '<tr><td>'+t+'</td><td>'+i[0]+'<mark class="nickname" onclick="window.chat.addNickname(\'@' + nick + '\')" ' + s + '>'+ nick+'</mark>'+i[1]+'</td><td>'+msg+'</td></tr>';
|
||||
|
Loading…
x
Reference in New Issue
Block a user