fix scroll-to-bottom functionality

This commit is contained in:
Jakob Ketterl 2023-09-02 00:23:25 +02:00
parent 96ff66d891
commit aa8922f9a7
1 changed files with 11 additions and 7 deletions

View File

@ -49,7 +49,12 @@ MessagePanel.prototype.initClearButton = function() {
MessagePanel.prototype.htmlEscape = function(input) { MessagePanel.prototype.htmlEscape = function(input) {
return $('<div/>').text(input).html() return $('<div/>').text(input).html()
} };
MessagePanel.prototype.scrollToBottom = function() {
var $t = $(this.el).find('table');
$t.scrollTop($t[0].scrollHeight);
};
function WsjtMessagePanel(el) { function WsjtMessagePanel(el) {
MessagePanel.call(this, el); MessagePanel.call(this, el);
@ -113,7 +118,7 @@ WsjtMessagePanel.prototype.pushMessage = function(msg) {
'<td class="message">' + linkedmsg + '</td>' + '<td class="message">' + linkedmsg + '</td>' +
'</tr>' '</tr>'
)); ));
$b.scrollTop($b[0].scrollHeight); this.scrollToBottom();
} }
$.fn.wsjtMessagePanel = function(){ $.fn.wsjtMessagePanel = function(){
@ -219,7 +224,7 @@ PacketMessagePanel.prototype.pushMessage = function(msg) {
'<td class="message">' + this.htmlEscape(msg.comment || msg.message || '') + '</td>' + '<td class="message">' + this.htmlEscape(msg.comment || msg.message || '') + '</td>' +
'</tr>' '</tr>'
)); ));
$b.scrollTop($b[0].scrollHeight); this.scrollToBottom();
}; };
$.fn.packetMessagePanel = function() { $.fn.packetMessagePanel = function() {
@ -260,7 +265,7 @@ PocsagMessagePanel.prototype.pushMessage = function(msg) {
'<td class="message">' + this.htmlEscape(msg.message) + '</td>' + '<td class="message">' + this.htmlEscape(msg.message) + '</td>' +
'</tr>' '</tr>'
)); ));
$b.scrollTop($b[0].scrollHeight); this.scrollToBottom();
}; };
$.fn.pocsagMessagePanel = function() { $.fn.pocsagMessagePanel = function() {
@ -422,8 +427,7 @@ IsmMessagePanel.prototype.render = function() {
}; };
IsmMessagePanel.prototype.pushMessage = function(message) { IsmMessagePanel.prototype.pushMessage = function(message) {
var $t = $(this.el).find('table'); var $b = $(this.el).find('tbody');
var $b = $t.find('tbody');
var ifDefined = function(input, formatter) { var ifDefined = function(input, formatter) {
if (typeof(input) !== 'undefined') { if (typeof(input) !== 'undefined') {
@ -448,7 +452,7 @@ IsmMessagePanel.prototype.pushMessage = function(message) {
'<td class="data">' + this.htmlEscape(mergeRemainingMessage(message, ['model', 'id', 'channel', 'mode', 'time'])) + '</td>' + '<td class="data">' + this.htmlEscape(mergeRemainingMessage(message, ['model', 'id', 'channel', 'mode', 'time'])) + '</td>' +
'</tr>' '</tr>'
)); ));
$t.scrollTop($t[0].scrollHeight); this.scrollToBottom();
}; };
$.fn.ismMessagePanel = function() { $.fn.ismMessagePanel = function() {