From 95acf40eb6c93436ddc22d13553e417dc4bda5df Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Fri, 11 Nov 2016 21:42:45 +0000 Subject: [PATCH] more effort displaying meta information --- htdocs/openwebrx.js | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index deb3082..7bb39cc 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -1227,9 +1227,37 @@ function on_ws_recv(evt) var metaPanels = Array.prototype.filter.call(document.getElementsByClassName('openwebrx-panel'), function(el) { return el.dataset.panelName == 'metadata'; }); - metaPanels.forEach(function(el) { - el.innerHTML = stringData; + + var meta = {}; + stringData.substr(4).split(";").forEach(function(s) { + var item = s.split(":"); + meta[item[0]] = item[1]; }); + + var update = function(el) { + el.innerHTML = ""; + } + if (meta.protocol) switch (meta.protocol) { + case 'DMR': + if (meta.slot) { + var html = 'Timeslot: ' + meta.slot; + if (meta.type) html += ' Typ: ' + meta.type; + if (meta.source && meta.target) html += ' Source: ' + meta.source + ' Target: ' + meta.target; + update = function(el) { + var slotEl = el.getElementsByClassName('slot-' + meta.slot); + if (!slotEl.length) { + slotEl = document.createElement('div'); + slotEl.class = 'slot-' + meta.slot; + el.appendChild(slotEl); + } else { + slotEl = SlotEl[0]; + } + slotEl.innerHTML = html; + }; + } + } + + metaPanels.forEach(update); } }