diff --git a/providers/dxcluster.py b/providers/dxcluster.py index 37c56a9..d5dbd29 100644 --- a/providers/dxcluster.py +++ b/providers/dxcluster.py @@ -67,7 +67,7 @@ class DXCluster(Provider): if match: spot_time = datetime.strptime(match.group(5), "%H%MZ") spot_datetime = datetime.combine(datetime.today(), spot_time.time()).replace(tzinfo=pytz.UTC) - spot = Spot(source=self.name(), + spot = Spot(source="DX Cluster", dx_call=match.group(3), de_call=match.group(1), freq=float(match.group(2)), diff --git a/webassets/css/style.css b/webassets/css/style.css new file mode 100644 index 0000000..0e6b2ce --- /dev/null +++ b/webassets/css/style.css @@ -0,0 +1,18 @@ +div#table-container { + width: 80%; + margin: 0 auto; + overflow: scroll; +} + +div#table-container table, div#table-container th, div#table-container td { + border: 1px solid; + border-collapse: collapse +} + +div#table-container th, div#table-container td { + padding: 10px; +} + +div#table-container th { + background-color: dodgerblue; +} \ No newline at end of file diff --git a/webassets/index.html b/webassets/index.html index 1b39c0f..2024fe1 100644 --- a/webassets/index.html +++ b/webassets/index.html @@ -1,16 +1,18 @@ - Spot tool + Unnamed spot tool - +

Unnamed spot tool

+
Some filters here
+ diff --git a/webassets/js/code.js b/webassets/js/code.js index 3682b52..dbbfe8c 100644 --- a/webassets/js/code.js +++ b/webassets/js/code.js @@ -1,13 +1,45 @@ +// TODO get all data into JS +// TODO populate table more nicely +// TODO track last received time and use API since call, merge and sort local data, refresh display +// TODO filtering (applied locally) +// TODO look and feel + $.getJSON('/api/spots', function(jsonData) { let headers = Object.keys(jsonData[0]); let table = $('').append(''); - headers.forEach(header => table.find('thead tr').append(``)); + ["Time", "DX", "Frequency", "Mode", "Comment", "Source", "DE"].forEach(header => table.find('thead tr').append(``)); jsonData.forEach(row => { let $tr = $(''); - headers.forEach(header => $tr.append(``)); + $tr.append(``); + $tr.append(``); + $tr.append(``); + $tr.append(``); + $tr.append(''); + $tr.append(``); + $tr.append(``); table.find('tbody').append($tr); }); $('#table-container').html(table); -}); \ No newline at end of file +}); + +function escapeHtml(str) { + if (typeof str !== 'string') { + return ''; + } + + const escapeCharacter = (match) => { + switch (match) { + case '&': return '&'; + case '<': return '<'; + case '>': return '>'; + case '"': return '"'; + case '\'': return '''; + case '`': return '`'; + default: return match; + } + }; + + return str.replace(/[&<>"'`]/g, escapeCharacter); +} \ No newline at end of file
${header}${header}
${row[header]}${row["time"]}${row["dx_call"]}${row["freq"]}${row["mode"]}').append(escapeHtml(`${row["comment"]}`)).append('${row["source"]}${row["de_call"]}