mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2025-12-11 02:12:14 +00:00
Adds repeated message squashing to chat. (#33605)
* Adds repeated message squashing to chat. * Forgot to actually use the pref * Drops some unnecessary css * No trimming same thing three times * Increases size of repeats up to 24px, fixes scrolling
This commit is contained in:
committed by
CitadelStationBot
parent
77b792d69a
commit
ea47d74997
@@ -38,6 +38,19 @@ img.icon {
|
|||||||
vertical-align: bottom;
|
vertical-align: bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.r:before { /* "repeated" badge class for combined messages */
|
||||||
|
content: 'x';
|
||||||
|
}
|
||||||
|
.r {
|
||||||
|
display: inline;
|
||||||
|
padding: .2em .6em .3em;
|
||||||
|
font-size: 75%;
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 1;
|
||||||
|
color: #f00;
|
||||||
|
}
|
||||||
|
|
||||||
a {color: #0000ff;}
|
a {color: #0000ff;}
|
||||||
a.visited {color: #ff00ff;}
|
a.visited {color: #ff00ff;}
|
||||||
a:visited {color: #ff00ff;}
|
a:visited {color: #ff00ff;}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
<a href="#" class="subCell togglePing" id="togglePing"><span>Toggle ping display</span> <i class="icon-circle"></i></a>
|
<a href="#" class="subCell togglePing" id="togglePing"><span>Toggle ping display</span> <i class="icon-circle"></i></a>
|
||||||
<a href="#" class="subCell highlightTerm" id="highlightTerm"><span>Highlight string</span> <i class="icon-tag"></i></a>
|
<a href="#" class="subCell highlightTerm" id="highlightTerm"><span>Highlight string</span> <i class="icon-tag"></i></a>
|
||||||
<a href="#" class="subCell saveLog" id="saveLog"><span>Save chat log</span> <i class="icon-save"></i></a>
|
<a href="#" class="subCell saveLog" id="saveLog"><span>Save chat log</span> <i class="icon-save"></i></a>
|
||||||
|
<a href="#" class="subCell toggleCombine" id="toggleCombine"><span>Toggle line combining</span> <i class="icon-filter"></i></a>
|
||||||
<a href="#" class="subCell clearMessages" id="clearMessages"><span>Clear all messages</span> <i class="icon-eraser"></i></a>
|
<a href="#" class="subCell clearMessages" id="clearMessages"><span>Clear all messages</span> <i class="icon-eraser"></i></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="sub" id="subAudio">
|
<div class="sub" id="subAudio">
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ window.onerror = function(msg, url, line, col, error) {
|
|||||||
|
|
||||||
//Globals
|
//Globals
|
||||||
window.status = 'Output';
|
window.status = 'Output';
|
||||||
var $messages, $subOptions, $subAudio, $selectedSub, $contextMenu, $filterMessages;
|
var $messages, $subOptions, $subAudio, $selectedSub, $contextMenu, $filterMessages, $last_message;
|
||||||
var opts = {
|
var opts = {
|
||||||
//General
|
//General
|
||||||
'messageCount': 0, //A count...of messages...
|
'messageCount': 0, //A count...of messages...
|
||||||
@@ -68,6 +68,8 @@ var opts = {
|
|||||||
|
|
||||||
'defaultMusicVolume': 25,
|
'defaultMusicVolume': 25,
|
||||||
|
|
||||||
|
'messageCombining': true,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function clamp(val, min, max) {
|
function clamp(val, min, max) {
|
||||||
@@ -294,6 +296,31 @@ function output(message, flag) {
|
|||||||
opts.messageCount--; //I guess the count should only ever equal the limit
|
opts.messageCount--; //I guess the count should only ever equal the limit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var handled = false;
|
||||||
|
var trimmed_message = message.trim()
|
||||||
|
var lastmessages = $messages.children('div.entry:last-child');
|
||||||
|
if (opts.messageCombining && lastmessages.length && $last_message)
|
||||||
|
{
|
||||||
|
if($last_message == trimmed_message)
|
||||||
|
{
|
||||||
|
if(lastmessages.children('span.r').length)
|
||||||
|
{
|
||||||
|
var current_value = parseInt(lastmessages.children('span.r').text())
|
||||||
|
lastmessages.children('span.r').text(current_value+1)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lastmessages.append($('<span/>', { 'class': 'r', 'text': 2}));
|
||||||
|
}
|
||||||
|
if(parseInt(lastmessages.css("font-size")) < 24) //Completely arbitrary max size
|
||||||
|
lastmessages.css("font-size","+=2")
|
||||||
|
opts.messageCount--;
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!handled)
|
||||||
|
{
|
||||||
//Actually append the message
|
//Actually append the message
|
||||||
var entry = document.createElement('div');
|
var entry = document.createElement('div');
|
||||||
entry.className = 'entry';
|
entry.className = 'entry';
|
||||||
@@ -303,20 +330,22 @@ function output(message, flag) {
|
|||||||
entry.setAttribute('data-filter', filteredOut);
|
entry.setAttribute('data-filter', filteredOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.innerHTML = message.trim();
|
$last_message = trimmed_message;
|
||||||
|
entry.innerHTML = trimmed_message;
|
||||||
$messages[0].appendChild(entry);
|
$messages[0].appendChild(entry);
|
||||||
$(entry).find("img.icon").error(iconError);
|
$(entry).find("img.icon").error(iconError);
|
||||||
//Actually do the snap
|
//Actually do the snap
|
||||||
if (!filteredOut && atBottom) {
|
|
||||||
$('body,html').scrollTop($messages.outerHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
//Stuff we can do after the message shows can go here, in the interests of responsiveness
|
//Stuff we can do after the message shows can go here, in the interests of responsiveness
|
||||||
if (opts.highlightTerms && opts.highlightTerms.length > 0) {
|
if (opts.highlightTerms && opts.highlightTerms.length > 0) {
|
||||||
highlightTerms(entry);
|
highlightTerms(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!filteredOut && atBottom) {
|
||||||
|
$('body,html').scrollTop($messages.outerHeight());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function internalOutput(message, flag)
|
function internalOutput(message, flag)
|
||||||
{
|
{
|
||||||
output(escaper(message), flag)
|
output(escaper(message), flag)
|
||||||
@@ -568,6 +597,7 @@ $(function() {
|
|||||||
'shighlightTerms': getCookie('highlightterms'),
|
'shighlightTerms': getCookie('highlightterms'),
|
||||||
'shighlightColor': getCookie('highlightcolor'),
|
'shighlightColor': getCookie('highlightcolor'),
|
||||||
'smusicVolume': getCookie('musicVolume'),
|
'smusicVolume': getCookie('musicVolume'),
|
||||||
|
'smessagecombining': getCookie('messagecombining'),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (savedConfig.sfontSize) {
|
if (savedConfig.sfontSize) {
|
||||||
@@ -606,7 +636,15 @@ $(function() {
|
|||||||
opts.updatedVolume = newVolume;
|
opts.updatedVolume = newVolume;
|
||||||
sendVolumeUpdate();
|
sendVolumeUpdate();
|
||||||
internalOutput('<span class="internal boldnshit">Loaded music volume of: '+savedConfig.smusicVolume+'</span>', 'internal');
|
internalOutput('<span class="internal boldnshit">Loaded music volume of: '+savedConfig.smusicVolume+'</span>', 'internal');
|
||||||
|
}
|
||||||
|
if (savedConfig.smessagecombining) {
|
||||||
|
if (savedConfig.smessagecombining == 'false') {
|
||||||
|
opts.messageCombining = false;
|
||||||
} else {
|
} else {
|
||||||
|
opts.messageCombining = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
$('#adminMusic').prop('volume', opts.defaultMusicVolume / 100);
|
$('#adminMusic').prop('volume', opts.defaultMusicVolume / 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -922,6 +960,11 @@ $(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#toggleCombine').click(function(e) {
|
||||||
|
opts.messageCombining = !opts.messageCombining;
|
||||||
|
setCookie('messagecombining', (opts.messageCombining ? 'true' : 'false'), 365);
|
||||||
|
});
|
||||||
|
|
||||||
$('img.icon').error(iconError);
|
$('img.icon').error(iconError);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user