mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-04-29 18:25:58 +00:00
Simplify API for band conditions #92
This commit is contained in:
@@ -1,32 +1,26 @@
|
||||
// Load solar conditions
|
||||
function loadSolarConditions() {
|
||||
$.getJSON('/api/v1/solar', function(jsonData) {
|
||||
|
||||
// HF
|
||||
|
||||
const hfConditionClass = { 'Good': 'table-success', 'Fair': 'table-warning', 'Poor': 'table-danger' };
|
||||
|
||||
if (jsonData.hf_conditions) {
|
||||
jsonData.hf_conditions.forEach(function(entry) {
|
||||
const cell = $('#hf-conditions-' + entry.band + '-' + entry.time);
|
||||
cell.text(entry.condition);
|
||||
const cls = hfConditionClass[entry.condition];
|
||||
if (cls) { cell.addClass(cls); }
|
||||
Object.entries(jsonData.hf_conditions).forEach(function([key, condition]) {
|
||||
const cell = $('#hf-conditions-' + key);
|
||||
cell.text(condition);
|
||||
cell.addClass(hfConditionClass[condition]);
|
||||
});
|
||||
}
|
||||
|
||||
const vhfIdMap = {
|
||||
'vhf-aurora|northern_hemi': 'vhf-conditions-aurora',
|
||||
'E-Skip|europe_6m': 'vhf-conditions-es-6m-eu',
|
||||
'E-Skip|europe_4m': 'vhf-conditions-es-4m-eu',
|
||||
'E-Skip|europe': 'vhf-conditions-es-2m-eu',
|
||||
'E-Skip|north_america':'vhf-conditions-es-2m-na',
|
||||
};
|
||||
// VHF
|
||||
|
||||
if (jsonData.vhf_conditions) {
|
||||
jsonData.vhf_conditions.forEach(function(entry) {
|
||||
const id = vhfIdMap[entry.phenomenon + '|' + entry.location];
|
||||
if (id) {
|
||||
const cell = $('#' + id);
|
||||
cell.text(entry.condition);
|
||||
cell.addClass(entry.condition === 'Band Closed' ? 'table-danger' : 'table-success');
|
||||
}
|
||||
Object.entries(jsonData.vhf_conditions).forEach(function([key, condition]) {
|
||||
const cell = $('#vhf-conditions-' + key);
|
||||
cell.text(condition);
|
||||
cell.addClass(condition === 'Band Closed' ? 'table-danger' : 'table-success');
|
||||
});
|
||||
}
|
||||
if (jsonData.aurora_latitude !== null && jsonData.aurora_latitude !== undefined) {
|
||||
|
||||
Reference in New Issue
Block a user