2020-12-09 18:26:34 +00:00
|
|
|
function MessagePanel(el) {
|
|
|
|
this.el = el;
|
|
|
|
this.render();
|
2020-12-09 19:08:50 +00:00
|
|
|
this.initClearButton();
|
2020-12-09 18:26:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MessagePanel.prototype.render = function() {
|
|
|
|
};
|
|
|
|
|
|
|
|
MessagePanel.prototype.pushMessage = function(message) {
|
|
|
|
};
|
|
|
|
|
|
|
|
// automatic clearing is not enabled by default. call this method from the constructor to enable
|
|
|
|
MessagePanel.prototype.initClearTimer = function() {
|
|
|
|
var me = this;
|
|
|
|
if (me.removalInterval) clearInterval(me.removalInterval);
|
|
|
|
me.removalInterval = setInterval(function () {
|
2020-12-09 19:08:50 +00:00
|
|
|
me.clearMessages(1000);
|
2020-12-09 18:26:34 +00:00
|
|
|
}, 15000);
|
2020-12-09 19:08:50 +00:00
|
|
|
};
|
2020-12-09 18:26:34 +00:00
|
|
|
|
2020-12-09 19:08:50 +00:00
|
|
|
MessagePanel.prototype.clearMessages = function(toRemain) {
|
2020-12-09 18:42:46 +00:00
|
|
|
var $elements = $(this.el).find('tbody tr');
|
|
|
|
// limit to 1000 entries in the list since browsers get laggy at some point
|
2020-12-09 19:08:50 +00:00
|
|
|
var toRemove = $elements.length - toRemain;
|
2020-12-09 18:42:46 +00:00
|
|
|
if (toRemove <= 0) return;
|
|
|
|
$elements.slice(0, toRemove).remove();
|
2020-12-09 19:08:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
MessagePanel.prototype.initClearButton = function() {
|
|
|
|
var me = this;
|
|
|
|
me.clearButton = $(
|
|
|
|
'<div class="openwebrx-button">Clear</div>'
|
|
|
|
);
|
|
|
|
me.clearButton.css({
|
|
|
|
position: 'absolute',
|
|
|
|
top: '10px',
|
|
|
|
right: '10px'
|
|
|
|
});
|
|
|
|
me.clearButton.on('click', function() {
|
|
|
|
me.clearMessages(0);
|
|
|
|
});
|
|
|
|
$(me.el).append(me.clearButton);
|
|
|
|
};
|
2020-12-09 18:42:46 +00:00
|
|
|
|
2020-12-09 18:26:34 +00:00
|
|
|
function WsjtMessagePanel(el) {
|
|
|
|
MessagePanel.call(this, el);
|
|
|
|
this.initClearTimer();
|
|
|
|
}
|
|
|
|
|
|
|
|
WsjtMessagePanel.prototype = new MessagePanel();
|
|
|
|
|
|
|
|
WsjtMessagePanel.prototype.render = function() {
|
|
|
|
$(this.el).append($(
|
|
|
|
'<table>' +
|
|
|
|
'<thead><tr>' +
|
|
|
|
'<th>UTC</th>' +
|
|
|
|
'<th class="decimal">dB</th>' +
|
|
|
|
'<th class="decimal">DT</th>' +
|
|
|
|
'<th class="decimal freq">Freq</th>' +
|
|
|
|
'<th class="message">Message</th>' +
|
|
|
|
'</tr></thead>' +
|
|
|
|
'<tbody></tbody>' +
|
|
|
|
'</table>'
|
|
|
|
));
|
|
|
|
};
|
|
|
|
|
|
|
|
WsjtMessagePanel.prototype.pushMessage = function(msg) {
|
|
|
|
var $b = $(this.el).find('tbody');
|
|
|
|
var t = new Date(msg['timestamp']);
|
|
|
|
var pad = function (i) {
|
|
|
|
return ('' + i).padStart(2, "0");
|
|
|
|
};
|
|
|
|
var linkedmsg = msg['msg'];
|
|
|
|
var matches;
|
|
|
|
|
|
|
|
var html_escape = function(input) {
|
|
|
|
return $('<div/>').text(input).html()
|
|
|
|
};
|
|
|
|
|
|
|
|
if (['FT8', 'JT65', 'JT9', 'FT4', 'FST4', 'FST4W'].indexOf(msg['mode']) >= 0) {
|
|
|
|
matches = linkedmsg.match(/(.*\s[A-Z0-9]+\s)([A-R]{2}[0-9]{2})$/);
|
|
|
|
if (matches && matches[2] !== 'RR73') {
|
|
|
|
linkedmsg = html_escape(matches[1]) + '<a href="map?locator=' + matches[2] + '" target="openwebrx-map">' + matches[2] + '</a>';
|
|
|
|
} else {
|
|
|
|
linkedmsg = html_escape(linkedmsg);
|
|
|
|
}
|
|
|
|
} else if (msg['mode'] === 'WSPR') {
|
|
|
|
matches = linkedmsg.match(/([A-Z0-9]*\s)([A-R]{2}[0-9]{2})(\s[0-9]+)/);
|
|
|
|
if (matches) {
|
|
|
|
linkedmsg = html_escape(matches[1]) + '<a href="map?locator=' + matches[2] + '" target="openwebrx-map">' + matches[2] + '</a>' + html_escape(matches[3]);
|
|
|
|
} else {
|
|
|
|
linkedmsg = html_escape(linkedmsg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$b.append($(
|
|
|
|
'<tr data-timestamp="' + msg['timestamp'] + '">' +
|
|
|
|
'<td>' + pad(t.getUTCHours()) + pad(t.getUTCMinutes()) + pad(t.getUTCSeconds()) + '</td>' +
|
|
|
|
'<td class="decimal">' + msg['db'] + '</td>' +
|
|
|
|
'<td class="decimal">' + msg['dt'] + '</td>' +
|
|
|
|
'<td class="decimal freq">' + msg['freq'] + '</td>' +
|
|
|
|
'<td class="message">' + linkedmsg + '</td>' +
|
|
|
|
'</tr>'
|
|
|
|
));
|
|
|
|
$b.scrollTop($b[0].scrollHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
$.fn.wsjtMessagePanel = function(){
|
|
|
|
if (!this.data('panel')) {
|
|
|
|
this.data('panel', new WsjtMessagePanel(this));
|
|
|
|
};
|
|
|
|
return this.data('panel');
|
2020-12-09 18:42:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
function PacketMessagePanel(el) {
|
|
|
|
MessagePanel.call(this, el);
|
|
|
|
this.initClearTimer();
|
|
|
|
}
|
|
|
|
|
|
|
|
PacketMessagePanel.prototype = new MessagePanel();
|
|
|
|
|
|
|
|
PacketMessagePanel.prototype.render = function() {
|
|
|
|
$(this.el).append($(
|
|
|
|
'<table>' +
|
|
|
|
'<thead><tr>' +
|
|
|
|
'<th>UTC</th>' +
|
|
|
|
'<th class="callsign">Callsign</th>' +
|
|
|
|
'<th class="coord">Coord</th>' +
|
|
|
|
'<th class="message">Comment</th>' +
|
|
|
|
'</tr></thead>' +
|
|
|
|
'<tbody></tbody>' +
|
|
|
|
'</table>'
|
|
|
|
));
|
|
|
|
};
|
|
|
|
|
|
|
|
PacketMessagePanel.prototype.pushMessage = function(msg) {
|
|
|
|
var $b = $(this.el).find('tbody');
|
|
|
|
var pad = function (i) {
|
|
|
|
return ('' + i).padStart(2, "0");
|
|
|
|
};
|
|
|
|
|
|
|
|
if (msg.type && msg.type === 'thirdparty' && msg.data) {
|
|
|
|
msg = msg.data;
|
|
|
|
}
|
|
|
|
var source = msg.source;
|
|
|
|
if (msg.type) {
|
|
|
|
if (msg.type === 'item') {
|
|
|
|
source = msg.item;
|
|
|
|
}
|
|
|
|
if (msg.type === 'object') {
|
|
|
|
source = msg.object;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var timestamp = '';
|
|
|
|
if (msg.timestamp) {
|
|
|
|
var t = new Date(msg.timestamp);
|
|
|
|
timestamp = pad(t.getUTCHours()) + pad(t.getUTCMinutes()) + pad(t.getUTCSeconds())
|
|
|
|
}
|
|
|
|
|
|
|
|
var link = '';
|
|
|
|
var classes = [];
|
|
|
|
var styles = {};
|
|
|
|
var overlay = '';
|
|
|
|
var stylesToString = function (s) {
|
|
|
|
return $.map(s, function (value, key) {
|
|
|
|
return key + ':' + value + ';'
|
|
|
|
}).join('')
|
|
|
|
};
|
|
|
|
if (msg.symbol) {
|
|
|
|
classes.push('aprs-symbol');
|
|
|
|
classes.push('aprs-symboltable-' + (msg.symbol.table === '/' ? 'normal' : 'alternate'));
|
|
|
|
styles['background-position-x'] = -(msg.symbol.index % 16) * 15 + 'px';
|
|
|
|
styles['background-position-y'] = -Math.floor(msg.symbol.index / 16) * 15 + 'px';
|
|
|
|
if (msg.symbol.table !== '/' && msg.symbol.table !== '\\') {
|
|
|
|
var s = {};
|
|
|
|
s['background-position-x'] = -(msg.symbol.tableindex % 16) * 15 + 'px';
|
|
|
|
s['background-position-y'] = -Math.floor(msg.symbol.tableindex / 16) * 15 + 'px';
|
|
|
|
overlay = '<div class="aprs-symbol aprs-symboltable-overlay" style="' + stylesToString(s) + '"></div>';
|
|
|
|
}
|
|
|
|
} else if (msg.lat && msg.lon) {
|
|
|
|
classes.push('openwebrx-maps-pin');
|
|
|
|
}
|
|
|
|
var attrs = [
|
|
|
|
'class="' + classes.join(' ') + '"',
|
|
|
|
'style="' + stylesToString(styles) + '"'
|
|
|
|
].join(' ');
|
|
|
|
if (msg.lat && msg.lon) {
|
|
|
|
link = '<a ' + attrs + ' href="map?callsign=' + source + '" target="openwebrx-map">' + overlay + '</a>';
|
|
|
|
} else {
|
|
|
|
link = '<div ' + attrs + '>' + overlay + '</div>'
|
|
|
|
}
|
|
|
|
|
|
|
|
$b.append($(
|
|
|
|
'<tr>' +
|
|
|
|
'<td>' + timestamp + '</td>' +
|
|
|
|
'<td class="callsign">' + source + '</td>' +
|
|
|
|
'<td class="coord">' + link + '</td>' +
|
|
|
|
'<td class="message">' + (msg.comment || msg.message || '') + '</td>' +
|
|
|
|
'</tr>'
|
|
|
|
));
|
|
|
|
$b.scrollTop($b[0].scrollHeight);
|
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.packetMessagePanel = function() {
|
|
|
|
if (!this.data('panel')) {
|
|
|
|
this.data('panel', new PacketMessagePanel(this));
|
|
|
|
};
|
|
|
|
return this.data('panel');
|
2020-12-09 18:53:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
PocsagMessagePanel = function(el) {
|
|
|
|
MessagePanel.call(this, el);
|
|
|
|
this.initClearTimer();
|
|
|
|
}
|
|
|
|
|
|
|
|
PocsagMessagePanel.prototype = new MessagePanel();
|
|
|
|
|
|
|
|
PocsagMessagePanel.prototype.render = function() {
|
|
|
|
$(this.el).append($(
|
|
|
|
'<table>' +
|
|
|
|
'<thead><tr>' +
|
|
|
|
'<th class="address">Address</th>' +
|
|
|
|
'<th class="message">Message</th>' +
|
|
|
|
'</tr></thead>' +
|
|
|
|
'<tbody></tbody>' +
|
|
|
|
'</table>'
|
|
|
|
));
|
|
|
|
};
|
|
|
|
|
|
|
|
PocsagMessagePanel.prototype.pushMessage = function(msg) {
|
|
|
|
var $b = $(this.el).find('tbody');
|
|
|
|
$b.append($(
|
|
|
|
'<tr>' +
|
2020-12-09 19:08:50 +00:00
|
|
|
'<td class="address">' + msg.address + '</td>' +
|
|
|
|
'<td class="message">' + msg.message + '</td>' +
|
2020-12-09 18:53:37 +00:00
|
|
|
'</tr>'
|
|
|
|
));
|
|
|
|
$b.scrollTop($b[0].scrollHeight);
|
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.pocsagMessagePanel = function() {
|
|
|
|
if (!this.data('panel')) {
|
|
|
|
this.data('panel', new PocsagMessagePanel(this));
|
|
|
|
};
|
|
|
|
return this.data('panel');
|
2020-12-09 18:26:34 +00:00
|
|
|
};
|