mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-04-29 18:25:58 +00:00
71 lines
2.6 KiB
JavaScript
71 lines
2.6 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);
|
|
let vhfClass;
|
|
if (condition === 'Band Closed') {
|
|
vhfClass = 'table-danger';
|
|
} else if (condition.includes('High')) {
|
|
vhfClass = 'table-warning';
|
|
} else {
|
|
vhfClass = 'table-success';
|
|
}
|
|
cell.addClass(vhfClass);
|
|
});
|
|
}
|
|
if (jsonData.aurora_latitude !== null && jsonData.aurora_latitude !== undefined) {
|
|
$('#vhf-conditions-aurora-lat').text(jsonData.aurora_latitude + '°');
|
|
}
|
|
|
|
// Solar Weather
|
|
|
|
const swFields = {
|
|
'sfi': 'sw-sfi',
|
|
'sunspots': 'sw-sunspots',
|
|
'band_conditions_desc': 'sw-band-conditions-desc',
|
|
'k_index': 'sw-k-index',
|
|
'a_index': 'sw-a-index',
|
|
'geomag_field': 'sw-geomag-field',
|
|
'geomag_storm_scale': 'sw-geomag-storm-scale',
|
|
'geomag_storm_desc': 'sw-geomag-storm-desc',
|
|
'geomag_noise': 'sw-geomag-noise',
|
|
'x_ray': 'sw-x-ray',
|
|
'blackout_desc': 'sw-blackout-desc',
|
|
'proton_flux': 'sw-proton-flux',
|
|
'solar_storm_scale': 'sw-solar-storm-scale',
|
|
'proton_flux_desc': 'sw-proton-flux-desc',
|
|
'electron_flux': 'sw-electron-flux',
|
|
'electron_flux_desc': 'sw-electron-flux-desc',
|
|
};
|
|
Object.entries(swFields).forEach(function([field, id]) {
|
|
const val = jsonData[field];
|
|
if (val !== null && val !== undefined) {
|
|
$('#' + id).text(val);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
// Startup
|
|
$(document).ready(function() {
|
|
loadSolarConditions();
|
|
});
|