From 946866319cb570bd6d5bfef43ad52756846f0122 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sat, 16 Jan 2021 21:16:49 +0100 Subject: [PATCH] improve location handling & clearing --- htdocs/lib/MetaPanel.js | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/htdocs/lib/MetaPanel.js b/htdocs/lib/MetaPanel.js index ae2c502..7b54a0a 100644 --- a/htdocs/lib/MetaPanel.js +++ b/htdocs/lib/MetaPanel.js @@ -88,23 +88,18 @@ YsfMetaPanel.prototype.update = function(data) { this.setDown(data['down']); this.el.find(".openwebrx-meta-slot").addClass("active"); } else { - this.setSource(); - this.setLocation(); - this.setUp(); - this.setDown(); - this.el.find(".openwebrx-meta-slot").removeClass("active"); + this.clear(); } }; YsfMetaPanel.prototype.clear = function() { MetaPanel.prototype.clear.call(this); - this.mode = ''; - this.source = ''; - this.lat = 0; - this.lon = 0; - this.callsign = ''; - this.up = ''; - this.down = ''; + this.setMode(); + this.setSource(); + this.setLocation(); + this.setUp(); + this.setDown(); + this.el.find(".openwebrx-meta-slot").removeClass("active"); }; YsfMetaPanel.prototype.setMode = function(mode) { @@ -124,9 +119,11 @@ YsfMetaPanel.prototype.setSource = function(source) { }; YsfMetaPanel.prototype.setLocation = function(lat, lon, callsign) { - if (this.lat === lat && this.lon === lon && this.callsign === callsign) return; + var hasLocation = lat && lon && callsign && callsign != ''; + if (hasLocation === this.hasLocation && this.callsign === callsign) return; + this.hasLocation = hasLocation; this.callsign = callsign; var html = ''; - if (lat && lon && callsign) { + if (hasLocation) { html = ''; } this.el.find('.openwebrx-ysf-source .location').html(html);