mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-29 07:59:01 +01:00
Chat message limit can now be changed (#16121)
* a * Update code/modules/goonchat/browserassets/js/browserOutput.js Co-authored-by: SleepyGemmy <99297919+SleepyGemmy@users.noreply.github.com> * Update html/changelogs/DreamySkrell-chatmessagelimit11112.yml Co-authored-by: SleepyGemmy <99297919+SleepyGemmy@users.noreply.github.com> * Update code/modules/goonchat/browserassets/js/browserOutput.js Co-authored-by: SleepyGemmy <99297919+SleepyGemmy@users.noreply.github.com> * b * whitespace... * Update code/modules/goonchat/browserassets/js/browserOutput.js Co-authored-by: SleepyGemmy <99297919+SleepyGemmy@users.noreply.github.com> --------- Co-authored-by: DreamySkrell <> Co-authored-by: SleepyGemmy <99297919+SleepyGemmy@users.noreply.github.com>
This commit is contained in:
co-authored by
SleepyGemmy
DreamySkrell <>
parent
167f53a1ab
commit
50d38e8b1c
@@ -56,6 +56,7 @@
|
||||
<a href="#" class="subCell increaseLineHeight" id="increaseLineHeight"><span>Increase line height</span> <i class="fas fa-text-height"></i></a>
|
||||
<a href="#" class="subCell togglePing" id="togglePing"><span>Toggle ping display</span> <i class="fas fa-circle"></i></a>
|
||||
<a href="#" class="subCell highlightTerm" id="highlightTerm"><span>Highlight string</span> <i class="fas fa-tag"></i></a>
|
||||
<a href="#" class="subCell messageLimit" id="messageLimit"><span>Change message limit</span> <i class="fas fa-bars"></i></a>
|
||||
<a href="#" class="subCell saveLog" id="saveLog"><span>Save chat log</span> <i class="fas fa-save"></i></a>
|
||||
<a href="#" class="subCell toggleCombine" id="toggleCombine"><span>Toggle line combining</span> <i class="fas fa-filter"></i></a>
|
||||
<a href="#" class="subCell clearMessages" id="clearMessages"><span>Clear all messages</span> <i class="fas fa-eraser"></i></a>
|
||||
|
||||
@@ -24,8 +24,10 @@ window.status = 'Output';
|
||||
var $messages, $subTheme, $subOptions, $subFont, $selectedSub, $contextMenu, $filterMessages, $last_message;
|
||||
var opts = {
|
||||
//General
|
||||
'messageCount': 0, //A count...of messages...
|
||||
'messageLimit': 2053, //A limit...for the messages...
|
||||
'messageCount': 0, //A count of messages
|
||||
'messageLimit': 2048, //A limit for the messages
|
||||
'messageLimitMin': 2048,
|
||||
'messageLimitMax': 16384,
|
||||
'scrollSnapTolerance': 10, //If within x pixels of bottom
|
||||
'clickTolerance': 10, //Keep focus if outside x pixels of mousedown position on mouseup
|
||||
'imageRetryDelay': 50, //how long between attempts to reload images (in ms)
|
||||
@@ -348,9 +350,9 @@ function output(message, flag) {
|
||||
opts.messageCount++;
|
||||
|
||||
//Pop the top message off if history limit reached
|
||||
if (opts.messageCount >= opts.messageLimit) {
|
||||
while (opts.messageCount >= opts.messageLimit) {
|
||||
$messages.children('div.entry:first-child').remove();
|
||||
opts.messageCount--; //I guess the count should only ever equal the limit
|
||||
opts.messageCount--;
|
||||
}
|
||||
|
||||
// Create the element - if combining is off, we use it, and if it's on, we
|
||||
@@ -670,6 +672,7 @@ $(function() {
|
||||
fontsize: getCookie('fontsize'),
|
||||
iconsize: getCookie('iconsize'),
|
||||
lineheight: getCookie('lineheight'),
|
||||
'smessageLimit': getCookie('messageLimit'),
|
||||
'spingDisabled': getCookie('pingdisabled'),
|
||||
'shighlightTerms': getCookie('highlightterms'),
|
||||
'shighlightColor': getCookie('highlightcolor'),
|
||||
@@ -694,6 +697,17 @@ $(function() {
|
||||
if(savedConfig.stheme){
|
||||
setTheme(savedConfig.stheme);
|
||||
}
|
||||
if (savedConfig.smessageLimit) {
|
||||
var limit = parseInt(savedConfig.smessageLimit);
|
||||
if(isNaN(limit) || limit < opts.messageLimitMin) {
|
||||
limit = opts.messageLimitMin
|
||||
}
|
||||
if(limit > opts.messageLimitMax) {
|
||||
limit = opts.messageLimitMax
|
||||
}
|
||||
opts.messageLimit = limit;
|
||||
internalOutput('<span class="internal boldnshit">Loaded message limit of '+opts.messageLimit+'</span>', 'internal');
|
||||
}
|
||||
if (savedConfig.spingDisabled) {
|
||||
if (savedConfig.spingDisabled == 'true') {
|
||||
opts.pingDisabled = true;
|
||||
@@ -994,6 +1008,44 @@ $(function() {
|
||||
setCookie('highlightcolor', opts.highlightColor, 365);
|
||||
});
|
||||
|
||||
$('#messageLimit').click(function(e) {
|
||||
if ($('.popup .messageLimit').is(':visible')) {return;}
|
||||
var popupContent = '<div class="head">Chat Message Limit</div>' +
|
||||
'<div class="messageLimitPopup" id="messageLimitPopup">' +
|
||||
'<div>Choose the limit of messages in the chat. Default value is '+opts.messageLimitMin+', min is '+opts.messageLimitMin+', max is '+opts.messageLimitMax+'. ' +
|
||||
'If limit is reached, oldest messages at the top will be deleted. Higher limits may cause lower performance during long rounds.</div>' +
|
||||
'<form id="messageLimitForm">' +
|
||||
'<div><input type="text" name="messageLimitInput" id="messageLimitInput" class="messageLimitInput" maxlength="255" value="'+(opts.messageLimit ? opts.messageLimit : '')+'" /></div>' +
|
||||
'<div><input type="submit" name="messageLimitSubmit" id="messageLimitSubmit" class="messageLimitSubmit" value="Save" /></div>' +
|
||||
'</form>' +
|
||||
'</div>';
|
||||
createPopup(popupContent, 250);
|
||||
});
|
||||
|
||||
$('body').on('submit', '#messageLimitForm', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var limit = $('#messageLimitInput').val();
|
||||
limit = parseInt(limit);
|
||||
|
||||
if(isNaN(limit) || limit < opts.messageLimitMin) {
|
||||
limit = opts.messageLimitMin
|
||||
internalOutput('<span class="internal boldnshit">Message limit invalid or below min value.</span>', 'internal');
|
||||
}
|
||||
if(limit > opts.messageLimitMax) {
|
||||
limit = opts.messageLimitMax
|
||||
internalOutput('<span class="internal boldnshit">Message limit above max value.</span>', 'internal');
|
||||
}
|
||||
|
||||
opts.messageLimit = limit
|
||||
internalOutput('<span class="internal boldnshit">Message limit set to '+opts.messageLimit+'</span>', 'internal');
|
||||
|
||||
var $popup = $('#messageLimitPopup').closest('.popup');
|
||||
$popup.remove();
|
||||
|
||||
setCookie('messageLimit', opts.messageLimit, 365);
|
||||
});
|
||||
|
||||
$('#clearMessages').click(function() {
|
||||
$messages.empty();
|
||||
opts.messageCount = 0;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
################################
|
||||
# Example Changelog File
|
||||
#
|
||||
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
|
||||
#
|
||||
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
|
||||
# When it is, any changes listed below will disappear.
|
||||
#
|
||||
# Valid Prefixes:
|
||||
# bugfix
|
||||
# wip (For works in progress)
|
||||
# tweak
|
||||
# soundadd
|
||||
# sounddel
|
||||
# rscadd (general adding of nice things)
|
||||
# rscdel (general deleting of nice things)
|
||||
# imageadd
|
||||
# imagedel
|
||||
# maptweak
|
||||
# spellcheck (typo fixes)
|
||||
# experiment
|
||||
# balance
|
||||
# admin
|
||||
# backend
|
||||
# security
|
||||
# refactor
|
||||
#################################
|
||||
|
||||
# Your name.
|
||||
author: DreamySkrell
|
||||
|
||||
# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
|
||||
delete-after: True
|
||||
|
||||
# Any changes you've made. See valid prefix list above.
|
||||
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
|
||||
# SCREW THIS UP AND IT WON'T WORK.
|
||||
# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries.
|
||||
# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog.
|
||||
changes:
|
||||
- tweak: "Chat message limit can now be changed."
|
||||
Reference in New Issue
Block a user