2021-01-16 18:40:22 +00:00
|
|
|
function MetaPanel(el) {
|
|
|
|
this.el = el;
|
|
|
|
this.modes = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
MetaPanel.prototype.update = function(data) {
|
|
|
|
};
|
|
|
|
|
|
|
|
MetaPanel.prototype.isSupported = function(data) {
|
|
|
|
return this.modes.includes(data.protocol);
|
|
|
|
};
|
|
|
|
|
|
|
|
MetaPanel.prototype.clear = function() {
|
|
|
|
this.el.find(".openwebrx-meta-slot").removeClass("active").removeClass("sync");
|
|
|
|
};
|
|
|
|
|
|
|
|
function DmrMetaSlot(el) {
|
|
|
|
this.el = $(el);
|
2021-01-16 21:07:55 +00:00
|
|
|
this.clear();
|
2021-01-16 18:40:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DmrMetaSlot.prototype.update = function(data) {
|
|
|
|
this.el[data['sync'] ? "addClass" : "removeClass"]("sync");
|
|
|
|
if (data['sync'] && data['sync'] === "voice") {
|
2021-08-06 18:02:30 +00:00
|
|
|
this.setId(data['additional'] && data['additional']['callsign'] || data['talkeralias'] || data['source']);
|
2021-01-16 21:07:55 +00:00
|
|
|
this.setName(data['additional'] && data['additional']['fname']);
|
2021-01-19 19:54:35 +00:00
|
|
|
this.setMode(['group', 'direct'].includes(data['type']) ? data['type'] : undefined);
|
|
|
|
this.setTarget(data['target']);
|
2021-09-17 16:24:33 +00:00
|
|
|
this.setLocation(data['lat'], data['lon'], this.getCallsign(data));
|
2021-01-16 18:40:22 +00:00
|
|
|
this.el.addClass("active");
|
|
|
|
} else {
|
2021-01-16 21:07:55 +00:00
|
|
|
this.clear();
|
2021-01-16 18:40:22 +00:00
|
|
|
}
|
2021-01-16 21:07:55 +00:00
|
|
|
};
|
|
|
|
|
2021-09-17 16:24:33 +00:00
|
|
|
DmrMetaSlot.prototype.getCallsign = function(data) {
|
|
|
|
if ('additional' in data) {
|
|
|
|
return data['additional']['callsign'];
|
|
|
|
}
|
|
|
|
if ('talkeralias' in data) {
|
|
|
|
var matches = /^([A-Z0-9]+)(\s.*)?$/.exec(data['talkeralias']);
|
|
|
|
if (matches) return matches[1];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-01-16 21:07:55 +00:00
|
|
|
DmrMetaSlot.prototype.setId = function(id) {
|
|
|
|
if (this.id === id) return;
|
|
|
|
this.id = id;
|
2021-09-17 16:24:33 +00:00
|
|
|
this.el.find('.openwebrx-dmr-id .dmr-id').text(id || '');
|
2021-01-16 18:40:22 +00:00
|
|
|
}
|
|
|
|
|
2021-01-16 21:07:55 +00:00
|
|
|
DmrMetaSlot.prototype.setName = function(name) {
|
|
|
|
if (this.name === name) return;
|
|
|
|
this.name = name;
|
|
|
|
this.el.find('.openwebrx-dmr-name').text(name || '');
|
|
|
|
};
|
|
|
|
|
2021-01-19 19:54:35 +00:00
|
|
|
DmrMetaSlot.prototype.setMode = function(mode) {
|
2021-01-19 21:04:33 +00:00
|
|
|
if (this.mode === mode) return;
|
|
|
|
this.mode = mode;
|
2021-01-19 19:54:35 +00:00
|
|
|
var classes = ['group', 'direct'].filter(function(c){
|
|
|
|
return c !== mode;
|
|
|
|
});
|
|
|
|
this.el.removeClass(classes.join(' ')).addClass(mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
DmrMetaSlot.prototype.setTarget = function(target) {
|
|
|
|
if (this.target === target) return;
|
|
|
|
this.target = target;
|
|
|
|
this.el.find('.openwebrx-dmr-target').text(target || '');
|
|
|
|
}
|
|
|
|
|
2021-09-17 16:24:33 +00:00
|
|
|
DmrMetaSlot.prototype.setLocation = function(lat, lon, callsign) {
|
|
|
|
var hasLocation = lat && lon && callsign && callsign != '';
|
|
|
|
if (hasLocation === this.hasLocation && this.callsign === callsign) return;
|
|
|
|
this.hasLocation = hasLocation; this.callsign = callsign;
|
|
|
|
var html = '';
|
|
|
|
if (hasLocation) {
|
|
|
|
html = '<a class="openwebrx-maps-pin" href="map?callsign=' + encodeURIComponent(callsign) + '" target="_blank"><svg viewBox="0 0 20 35"><use xlink:href="static/gfx/svg-defs.svg#maps-pin"></use></svg></a>';
|
|
|
|
}
|
|
|
|
this.el.find('.openwebrx-dmr-id .location').html(html);
|
|
|
|
}
|
|
|
|
|
2021-01-16 21:07:55 +00:00
|
|
|
DmrMetaSlot.prototype.clear = function() {
|
|
|
|
this.setId();
|
|
|
|
this.setName();
|
2021-01-19 19:54:35 +00:00
|
|
|
this.setMode();
|
|
|
|
this.setTarget();
|
2021-09-17 16:24:33 +00:00
|
|
|
this.setLocation();
|
2021-01-16 21:07:55 +00:00
|
|
|
this.el.removeClass("active");
|
|
|
|
};
|
|
|
|
|
2021-01-16 18:40:22 +00:00
|
|
|
function DmrMetaPanel(el) {
|
|
|
|
MetaPanel.call(this, el);
|
|
|
|
this.modes = ['DMR'];
|
|
|
|
this.slots = this.el.find('.openwebrx-meta-slot').toArray().map(function(el){
|
|
|
|
return new DmrMetaSlot(el);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
DmrMetaPanel.prototype = new MetaPanel();
|
|
|
|
|
|
|
|
DmrMetaPanel.prototype.update = function(data) {
|
|
|
|
if (!this.isSupported(data)) return;
|
|
|
|
if (data['slot']) {
|
|
|
|
var slot = this.slots[data['slot']];
|
|
|
|
slot.update(data);
|
|
|
|
} else {
|
|
|
|
this.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DmrMetaPanel.prototype.clear = function() {
|
|
|
|
MetaPanel.prototype.clear.call(this);
|
|
|
|
this.el.find(".openwebrx-dmr-timeslot-panel").removeClass("muted");
|
2021-01-16 21:07:55 +00:00
|
|
|
this.slots.forEach(function(slot) {
|
|
|
|
slot.clear();
|
|
|
|
});
|
2021-01-16 18:40:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
function YsfMetaPanel(el) {
|
|
|
|
MetaPanel.call(this, el);
|
|
|
|
this.modes = ['YSF'];
|
2021-01-16 20:07:58 +00:00
|
|
|
this.clear();
|
2021-01-16 18:40:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
YsfMetaPanel.prototype = new MetaPanel();
|
|
|
|
|
|
|
|
YsfMetaPanel.prototype.update = function(data) {
|
|
|
|
if (!this.isSupported(data)) return;
|
2021-01-16 20:07:58 +00:00
|
|
|
this.setMode(data['mode']);
|
2021-01-16 18:40:22 +00:00
|
|
|
|
|
|
|
if (data['mode'] && data['mode'] !== "") {
|
2021-01-16 20:07:58 +00:00
|
|
|
this.setSource(data['source']);
|
|
|
|
this.setLocation(data['lat'], data['lon'], data['source']);
|
|
|
|
this.setUp(data['up']);
|
|
|
|
this.setDown(data['down']);
|
2021-08-11 12:10:52 +00:00
|
|
|
if (data['mode'].indexOf('data') < 0) {
|
|
|
|
this.el.find(".openwebrx-meta-slot").addClass("active");
|
|
|
|
}
|
2021-01-16 18:40:22 +00:00
|
|
|
} else {
|
2021-01-16 20:16:49 +00:00
|
|
|
this.clear();
|
2021-01-16 18:40:22 +00:00
|
|
|
}
|
2021-01-16 20:07:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
YsfMetaPanel.prototype.clear = function() {
|
2021-01-16 20:20:21 +00:00
|
|
|
MetaPanel.prototype.clear.call(this);
|
2021-01-16 20:16:49 +00:00
|
|
|
this.setMode();
|
|
|
|
this.setSource();
|
|
|
|
this.setLocation();
|
|
|
|
this.setUp();
|
|
|
|
this.setDown();
|
2021-01-16 20:07:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
YsfMetaPanel.prototype.setMode = function(mode) {
|
|
|
|
if (this.mode === mode) return;
|
|
|
|
this.mode = mode;
|
2021-01-18 23:36:55 +00:00
|
|
|
this.el.find('.openwebrx-ysf-mode').text(mode || '');
|
2021-01-16 20:07:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
YsfMetaPanel.prototype.setSource = function(source) {
|
|
|
|
if (this.source === source) return;
|
|
|
|
this.source = source;
|
|
|
|
this.el.find('.openwebrx-ysf-source .callsign').text(source || '');
|
|
|
|
};
|
|
|
|
|
|
|
|
YsfMetaPanel.prototype.setLocation = function(lat, lon, callsign) {
|
2021-01-16 20:16:49 +00:00
|
|
|
var hasLocation = lat && lon && callsign && callsign != '';
|
|
|
|
if (hasLocation === this.hasLocation && this.callsign === callsign) return;
|
|
|
|
this.hasLocation = hasLocation; this.callsign = callsign;
|
2021-01-16 20:07:58 +00:00
|
|
|
var html = '';
|
2021-01-16 20:16:49 +00:00
|
|
|
if (hasLocation) {
|
2021-05-16 15:30:34 +00:00
|
|
|
html = '<a class="openwebrx-maps-pin" href="map?callsign=' + encodeURIComponent(callsign) + '" target="_blank"><svg viewBox="0 0 20 35"><use xlink:href="static/gfx/svg-defs.svg#maps-pin"></use></svg></a>';
|
2021-01-16 20:07:58 +00:00
|
|
|
}
|
|
|
|
this.el.find('.openwebrx-ysf-source .location').html(html);
|
|
|
|
};
|
|
|
|
|
|
|
|
YsfMetaPanel.prototype.setUp = function(up) {
|
|
|
|
if (this.up === up) return;
|
|
|
|
this.up = up;
|
2021-01-18 23:36:55 +00:00
|
|
|
this.el.find('.openwebrx-ysf-up').text(up || '');
|
2021-01-16 20:07:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
YsfMetaPanel.prototype.setDown = function(down) {
|
|
|
|
if (this.down === down) return;
|
|
|
|
this.down = down;
|
2021-01-18 23:36:55 +00:00
|
|
|
this.el.find('.openwebrx-ysf-down').text(down || '');
|
2021-01-16 18:40:22 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 11:37:13 +00:00
|
|
|
function DStarMetaPanel(el) {
|
|
|
|
MetaPanel.call(this, el);
|
2021-06-08 12:04:54 +00:00
|
|
|
this.modes = ['DSTAR'];
|
2021-06-08 11:37:13 +00:00
|
|
|
this.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
DStarMetaPanel.prototype = new MetaPanel();
|
|
|
|
|
|
|
|
DStarMetaPanel.prototype.update = function(data) {
|
|
|
|
if (!this.isSupported(data)) return;
|
|
|
|
|
|
|
|
if (data['sync'] && data['sync'] == 'voice') {
|
|
|
|
this.el.find(".openwebrx-meta-slot").addClass("active");
|
2021-06-08 12:05:17 +00:00
|
|
|
this.setOurCall(data['ourcall']);
|
|
|
|
this.setYourCall(data['yourcall']);
|
|
|
|
this.setDeparture(data['departure']);
|
|
|
|
this.setDestination(data['destination']);
|
|
|
|
this.setMessage(data['message']);
|
2021-06-08 16:38:53 +00:00
|
|
|
this.setLocation(data['lat'], data['lon'], data['ourcall']);
|
2021-06-08 12:05:17 +00:00
|
|
|
} else {
|
|
|
|
this.clear();
|
2021-06-08 11:37:13 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
DStarMetaPanel.prototype.setOurCall = function(ourcall) {
|
|
|
|
if (this.ourcall === ourcall) return;
|
|
|
|
this.ourcall = ourcall;
|
2021-06-08 16:38:53 +00:00
|
|
|
this.el.find('.openwebrx-dstar-ourcall .callsign').text(ourcall || '');
|
2021-06-08 11:37:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
DStarMetaPanel.prototype.setYourCall = function(yourcall) {
|
|
|
|
if (this.yourcall === yourcall) return;
|
|
|
|
this.yourcall = yourcall;
|
|
|
|
this.el.find('.openwebrx-dstar-yourcall').text(yourcall || '');
|
|
|
|
};
|
|
|
|
|
|
|
|
DStarMetaPanel.prototype.setDeparture = function(departure) {
|
|
|
|
if (this.departure === departure) return;
|
|
|
|
this.departure = departure;
|
|
|
|
this.el.find('.openwebrx-dstar-departure').text(departure || '');
|
|
|
|
};
|
|
|
|
|
|
|
|
DStarMetaPanel.prototype.setDestination = function(destination) {
|
|
|
|
if (this.destination === destination) return;
|
|
|
|
this.destination = destination;
|
|
|
|
this.el.find('.openwebrx-dstar-destination').text(destination || '');
|
|
|
|
};
|
|
|
|
|
|
|
|
DStarMetaPanel.prototype.setMessage = function(message) {
|
|
|
|
if (this.message === message) return;
|
|
|
|
this.message = message;
|
|
|
|
this.el.find('.openwebrx-dstar-message').text(message || '');
|
|
|
|
}
|
|
|
|
|
|
|
|
DStarMetaPanel.prototype.clear = function() {
|
|
|
|
MetaPanel.prototype.clear.call(this);
|
|
|
|
this.setOurCall();
|
|
|
|
this.setYourCall();
|
|
|
|
this.setDeparture();
|
|
|
|
this.setDestination();
|
|
|
|
this.setMessage();
|
2021-06-08 16:38:53 +00:00
|
|
|
this.setLocation();
|
|
|
|
};
|
|
|
|
|
|
|
|
DStarMetaPanel.prototype.setLocation = function(lat, lon, callsign) {
|
|
|
|
var hasLocation = lat && lon && callsign && callsign != '';
|
|
|
|
if (hasLocation === this.hasLocation && this.callsign === callsign) return;
|
|
|
|
this.hasLocation = hasLocation; this.callsign = callsign;
|
|
|
|
var html = '';
|
|
|
|
if (hasLocation) {
|
|
|
|
html = '<a class="openwebrx-maps-pin" href="map?callsign=' + encodeURIComponent(callsign) + '" target="_blank"><svg viewBox="0 0 20 35"><use xlink:href="static/gfx/svg-defs.svg#maps-pin"></use></svg></a>';
|
|
|
|
}
|
2021-06-11 12:36:11 +00:00
|
|
|
this.el.find('.openwebrx-dstar-ourcall .location').html(html);
|
2021-06-08 11:37:13 +00:00
|
|
|
};
|
|
|
|
|
2021-06-15 20:50:30 +00:00
|
|
|
function NxdnMetaPanel(el) {
|
|
|
|
MetaPanel.call(this, el);
|
|
|
|
this.modes = ['NXDN'];
|
|
|
|
this.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
NxdnMetaPanel.prototype = new MetaPanel();
|
|
|
|
|
|
|
|
NxdnMetaPanel.prototype.update = function(data) {
|
|
|
|
if (!this.isSupported(data)) return;
|
|
|
|
|
2021-09-17 16:24:33 +00:00
|
|
|
if (data['sync'] && data['sync'] === 'voice') {
|
2021-06-15 20:50:30 +00:00
|
|
|
this.el.find(".openwebrx-meta-slot").addClass("active");
|
|
|
|
this.setSource(data['additional'] && data['additional']['callsign'] || data['source']);
|
|
|
|
this.setName(data['additional'] && data['additional']['fname']);
|
|
|
|
this.setDestination(data['destination']);
|
|
|
|
this.setMode(['conference', 'individual'].includes(data['type']) ? data['type'] : undefined);
|
|
|
|
} else {
|
|
|
|
this.clear();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
NxdnMetaPanel.prototype.setSource = function(source) {
|
|
|
|
if (this.source === source) return;
|
|
|
|
this.source = source;
|
|
|
|
this.el.find('.openwebrx-nxdn-source').text(source || '');
|
|
|
|
};
|
|
|
|
|
|
|
|
NxdnMetaPanel.prototype.setName = function(name) {
|
|
|
|
if (this.name === name) return;
|
|
|
|
this.name = name;
|
|
|
|
this.el.find('.openwebrx-nxdn-name').text(name || '');
|
|
|
|
};
|
|
|
|
|
|
|
|
NxdnMetaPanel.prototype.setDestination = function(destination) {
|
|
|
|
if (this.destination === destination) return;
|
|
|
|
this.destination = destination;
|
|
|
|
this.el.find('.openwebrx-nxdn-destination').text(destination || '');
|
|
|
|
};
|
|
|
|
|
|
|
|
NxdnMetaPanel.prototype.setMode = function(mode) {
|
|
|
|
if (this.mode === mode) return;
|
|
|
|
this.mode = mode;
|
2021-06-17 12:57:24 +00:00
|
|
|
|
|
|
|
var modes = ['individual', 'conference'];
|
2021-06-15 20:50:30 +00:00
|
|
|
var classes = modes.filter(function(c){
|
|
|
|
return c !== mode;
|
|
|
|
});
|
|
|
|
this.el.find('.openwebrx-meta-slot').removeClass(classes.join(' ')).addClass(mode);
|
|
|
|
};
|
|
|
|
|
|
|
|
NxdnMetaPanel.prototype.clear = function() {
|
|
|
|
MetaPanel.prototype.clear.call(this);
|
|
|
|
this.setMode();
|
|
|
|
this.setSource();
|
|
|
|
this.setName();
|
|
|
|
this.setDestination();
|
|
|
|
};
|
|
|
|
|
2021-12-21 20:18:17 +00:00
|
|
|
function M17MetaPanel(el) {
|
|
|
|
MetaPanel.call(this, el);
|
|
|
|
this.modes = ['M17'];
|
|
|
|
this.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
M17MetaPanel.prototype = new MetaPanel();
|
|
|
|
|
|
|
|
M17MetaPanel.prototype.update = function(data) {
|
|
|
|
if (!this.isSupported(data)) return;
|
|
|
|
|
|
|
|
if (data['sync'] && data['sync'] === 'voice') {
|
|
|
|
this.el.find(".openwebrx-meta-slot").addClass("active");
|
|
|
|
this.setSource(data['source']);
|
|
|
|
this.setDestination(data['destination']);
|
|
|
|
} else {
|
|
|
|
this.clear();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
M17MetaPanel.prototype.setSource = function(source) {
|
|
|
|
if (this.source === source) return;
|
|
|
|
this.source = source;
|
|
|
|
this.el.find('.openwebrx-m17-source').text(source || '');
|
|
|
|
};
|
|
|
|
|
|
|
|
M17MetaPanel.prototype.setDestination = function(destination) {
|
|
|
|
if (this.destination === destination) return;
|
|
|
|
this.destination = destination;
|
|
|
|
this.el.find('.openwebrx-m17-destination').text(destination || '');
|
|
|
|
};
|
|
|
|
|
|
|
|
M17MetaPanel.prototype.clear = function() {
|
|
|
|
MetaPanel.prototype.clear.call(this);
|
|
|
|
this.setSource();
|
|
|
|
this.setDestination();
|
|
|
|
};
|
|
|
|
|
2021-01-16 18:40:22 +00:00
|
|
|
MetaPanel.types = {
|
|
|
|
dmr: DmrMetaPanel,
|
2021-06-08 11:37:13 +00:00
|
|
|
ysf: YsfMetaPanel,
|
|
|
|
dstar: DStarMetaPanel,
|
2021-06-15 20:50:30 +00:00
|
|
|
nxdn: NxdnMetaPanel,
|
2021-12-21 20:18:17 +00:00
|
|
|
m17: M17MetaPanel,
|
2021-01-16 18:40:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.metaPanel = function() {
|
|
|
|
return this.map(function() {
|
|
|
|
var $self = $(this);
|
|
|
|
if (!$self.data('metapanel')) {
|
2021-12-21 20:18:17 +00:00
|
|
|
var matches = /^openwebrx-panel-metadata-([a-z0-9]+)$/.exec($self.prop('id'));
|
2021-01-16 18:40:22 +00:00
|
|
|
var constructor = matches && MetaPanel.types[matches[1]] || MetaPanel;
|
|
|
|
$self.data('metapanel', new constructor($self));
|
|
|
|
}
|
|
|
|
return $self.data('metapanel');
|
|
|
|
});
|
|
|
|
};
|