mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2026-01-08 16:13:58 +00:00
Slightly optimizes goonchat by removing checks for a completely unused feature
This commit is contained in:
@@ -245,96 +245,41 @@ function output(message, flag) {
|
||||
|
||||
message = byondDecode(message).trim();
|
||||
|
||||
//The behemoth of filter-code (for Admin message filters)
|
||||
//Note: This is proooobably hella inefficient
|
||||
var filteredOut = false;
|
||||
if (opts.hasOwnProperty('showMessagesFilters') && !opts.showMessagesFilters['All'].show) {
|
||||
//Get this filter type (defined by class on message)
|
||||
var messageHtml = $.parseHTML(message),
|
||||
messageClasses;
|
||||
if (opts.hasOwnProperty('filterHideAll') && opts.filterHideAll) {
|
||||
var internal = false;
|
||||
messageClasses = (!!$(messageHtml).attr('class') ? $(messageHtml).attr('class').split(/\s+/) : false);
|
||||
if (messageClasses) {
|
||||
for (var i = 0; i < messageClasses.length; i++) { //Every class
|
||||
if (messageClasses[i] == 'internal') {
|
||||
internal = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!internal) {
|
||||
filteredOut = 'All';
|
||||
}
|
||||
} else {
|
||||
//If the element or it's child have any classes
|
||||
if (!!$(messageHtml).attr('class') || !!$(messageHtml).children().attr('class')) {
|
||||
messageClasses = $(messageHtml).attr('class').split(/\s+/);
|
||||
if (!!$(messageHtml).children().attr('class')) {
|
||||
messageClasses = messageClasses.concat($(messageHtml).children().attr('class').split(/\s+/));
|
||||
}
|
||||
var tempCount = 0;
|
||||
for (var i = 0; i < messageClasses.length; i++) { //Every class
|
||||
var thisClass = messageClasses[i];
|
||||
$.each(opts.showMessagesFilters, function(key, val) { //Every filter
|
||||
if (key !== 'All' && val.show === false && typeof val.match != 'undefined') {
|
||||
for (var i = 0; i < val.match.length; i++) {
|
||||
var matchClass = val.match[i];
|
||||
if (matchClass == thisClass) {
|
||||
filteredOut = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (filteredOut) return false;
|
||||
});
|
||||
if (filteredOut) break;
|
||||
tempCount++;
|
||||
}
|
||||
} else {
|
||||
if (!opts.showMessagesFilters['Misc'].show) {
|
||||
filteredOut = 'Misc';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Stuff we do along with appending a message
|
||||
var atBottom = false;
|
||||
if (!filteredOut) {
|
||||
var bodyHeight = $('body').height();
|
||||
var messagesHeight = $messages.outerHeight();
|
||||
var scrollPos = $('body,html').scrollTop();
|
||||
var bodyHeight = $('body').height();
|
||||
var messagesHeight = $messages.outerHeight();
|
||||
var scrollPos = $('body,html').scrollTop();
|
||||
|
||||
//Should we snap the output to the bottom?
|
||||
if (bodyHeight + scrollPos >= messagesHeight - opts.scrollSnapTolerance) {
|
||||
atBottom = true;
|
||||
if ($('#newMessages').length) {
|
||||
$('#newMessages').remove();
|
||||
//Should we snap the output to the bottom?
|
||||
if (bodyHeight + scrollPos >= messagesHeight - opts.scrollSnapTolerance) {
|
||||
atBottom = true;
|
||||
if ($('#newMessages').length) {
|
||||
$('#newMessages').remove();
|
||||
}
|
||||
//If not, put the new messages box in
|
||||
} else {
|
||||
if ($('#newMessages').length) {
|
||||
var messages = $('#newMessages .number').text();
|
||||
messages = parseInt(messages);
|
||||
messages++;
|
||||
$('#newMessages .number').text(messages);
|
||||
if (messages == 2) {
|
||||
$('#newMessages .messageWord').append('s');
|
||||
}
|
||||
//If not, put the new messages box in
|
||||
} else {
|
||||
if ($('#newMessages').length) {
|
||||
var messages = $('#newMessages .number').text();
|
||||
messages = parseInt(messages);
|
||||
messages++;
|
||||
$('#newMessages .number').text(messages);
|
||||
if (messages == 2) {
|
||||
$('#newMessages .messageWord').append('s');
|
||||
}
|
||||
} else {
|
||||
$messages.after('<a href="#" id="newMessages"><span class="number">1</span> new <span class="messageWord">message</span> <i class="icon-double-angle-down"></i></a>');
|
||||
}
|
||||
$messages.after('<a href="#" id="newMessages"><span class="number">1</span> new <span class="messageWord">message</span> <i class="icon-double-angle-down"></i></a>');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
opts.messageCount++;
|
||||
|
||||
//Pop the top message off if history limit reached
|
||||
if (opts.messageCount >= opts.messageLimit) {
|
||||
$messages.children('div.entry:first-child').remove();
|
||||
opts.messageCount--; //I guess the count should only ever equal the limit
|
||||
}
|
||||
//if (opts.messageCount >= opts.messageLimit) {
|
||||
//$messages.children('div.entry:first-child').remove();
|
||||
//opts.messageCount--; //I guess the count should only ever equal the limit
|
||||
//}
|
||||
|
||||
// Create the element - if combining is off, we use it, and if it's on, we
|
||||
// might discard it bug need to check its text content. Some messages vary
|
||||
@@ -372,11 +317,6 @@ function output(message, flag) {
|
||||
//Actually append the message
|
||||
entry.className = 'entry';
|
||||
|
||||
if (filteredOut) {
|
||||
entry.className += ' hidden';
|
||||
entry.setAttribute('data-filter', filteredOut);
|
||||
}
|
||||
|
||||
$last_message = trimmed_message;
|
||||
$messages[0].appendChild(entry);
|
||||
$(entry).find("img.icon").error(iconError);
|
||||
@@ -401,7 +341,7 @@ function output(message, flag) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!filteredOut && atBottom) {
|
||||
if (atBottom) {
|
||||
$('body,html').scrollTop($messages.outerHeight());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user