mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-04-29 18:25:58 +00:00
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
// 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) {
|
|
Object.entries(jsonData.hf_conditions).forEach(function([key, condition]) {
|
|
const cell = $('#hf-conditions-' + key);
|
|
cell.text(condition);
|
|
cell.addClass(hfConditionClass[condition]);
|
|
});
|
|
}
|
|
|
|
// VHF
|
|
|
|
if (jsonData.vhf_conditions) {
|
|
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) {
|
|
$('#vhf-conditions-aurora-lat').text(jsonData.aurora_latitude + '°');
|
|
}
|
|
});
|
|
}
|
|
|
|
// Startup
|
|
$(document).ready(function() {
|
|
loadSolarConditions();
|
|
});
|