2026-04-26 22:10:29 +01:00
|
|
|
function setTimeplotLoading(isLoading) {
|
|
|
|
|
var $button = $('#timeplotShowButton');
|
|
|
|
|
if ($button.length) {
|
|
|
|
|
$button.toggleClass('running', isLoading);
|
|
|
|
|
$button.prop('disabled', isLoading);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function timeplotRender(band, dxcc, cqzone) {
|
|
|
|
|
setTimeplotLoading(true);
|
|
|
|
|
$('.alert').remove();
|
|
|
|
|
|
2021-03-17 12:56:04 +01:00
|
|
|
$.ajax({
|
2026-04-26 22:10:29 +01:00
|
|
|
url: base_url + 'index.php/timeplotter/getTimes',
|
2021-03-17 12:56:04 +01:00
|
|
|
type: 'post',
|
2026-04-26 22:10:29 +01:00
|
|
|
data: { 'band': band, 'dxcc': dxcc, 'cqzone': cqzone },
|
|
|
|
|
success: function (tmp) {
|
|
|
|
|
setTimeplotLoading(false);
|
2021-03-17 12:56:04 +01:00
|
|
|
if (tmp.ok == 'OK') {
|
|
|
|
|
plotTimeplotterChart(tmp);
|
2026-04-26 22:10:29 +01:00
|
|
|
} else {
|
|
|
|
|
$('#container').remove();
|
|
|
|
|
$('#info').remove();
|
|
|
|
|
$('#timeplotter_div').append('<div class="alert alert-danger" role="alert">' + tmp.error + '</div>');
|
2021-03-17 12:56:04 +01:00
|
|
|
}
|
2026-04-26 22:10:29 +01:00
|
|
|
},
|
|
|
|
|
error: function () {
|
|
|
|
|
setTimeplotLoading(false);
|
|
|
|
|
$('#container').remove();
|
|
|
|
|
$('#info').remove();
|
|
|
|
|
$('#timeplotter_div').append('<div class="alert alert-danger" role="alert">Unable to load Timeplotter data.</div>');
|
2021-03-17 12:56:04 +01:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-26 22:10:29 +01:00
|
|
|
function timeplot(form) {
|
|
|
|
|
timeplotRender(form.band.value, form.dxcc.value, form.cqzone.value);
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-17 12:56:04 +01:00
|
|
|
function plotTimeplotterChart(tmp) {
|
|
|
|
|
$("#container").remove();
|
|
|
|
|
$("#info").remove();
|
|
|
|
|
$("#timeplotter_div").append('<p id="info">' + tmp.qsocount + ' contacts were plotted.</p><div id="container" style="height: 600px;"></div>');
|
2021-09-10 18:53:24 +02:00
|
|
|
var color = ifDarkModeThemeReturn('white', 'grey');
|
2021-03-17 12:56:04 +01:00
|
|
|
var options = {
|
|
|
|
|
chart: {
|
|
|
|
|
type: 'column',
|
|
|
|
|
zoomType: 'xy',
|
2021-09-10 18:53:24 +02:00
|
|
|
renderTo: 'container',
|
|
|
|
|
backgroundColor: getBodyBackground()
|
2021-03-17 12:56:04 +01:00
|
|
|
},
|
|
|
|
|
title: {
|
2021-09-10 18:53:24 +02:00
|
|
|
text: 'Time Distribution',
|
|
|
|
|
style: {
|
|
|
|
|
color: color
|
|
|
|
|
}
|
2021-03-17 12:56:04 +01:00
|
|
|
},
|
|
|
|
|
xAxis: {
|
|
|
|
|
categories: [],
|
|
|
|
|
crosshair: true,
|
|
|
|
|
type: "category",
|
|
|
|
|
min:0,
|
|
|
|
|
max:47,
|
2021-09-10 18:53:24 +02:00
|
|
|
labels: {
|
|
|
|
|
style: {
|
|
|
|
|
color: color
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-17 12:56:04 +01:00
|
|
|
},
|
|
|
|
|
yAxis: {
|
|
|
|
|
title: {
|
2021-09-10 18:53:24 +02:00
|
|
|
text: '# QSOs',
|
|
|
|
|
style: {
|
|
|
|
|
color: color
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
labels: {
|
|
|
|
|
style: {
|
|
|
|
|
color: color
|
|
|
|
|
}
|
2021-03-17 12:56:04 +01:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
rangeSelector: {
|
|
|
|
|
selected: 1
|
|
|
|
|
},
|
|
|
|
|
tooltip: {
|
|
|
|
|
formatter: function () {
|
|
|
|
|
if(this.point) {
|
|
|
|
|
return "Time: " + options.xAxis.categories[this.point.x] +
|
|
|
|
|
"<br />Callsign(s) worked (max 5): " + myComments[this.point.x] +
|
|
|
|
|
"<br />Number of QSOs: <strong>" + series.data[this.point.x] + "</strong>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-10 18:53:24 +02:00
|
|
|
legend: {
|
|
|
|
|
itemStyle: {
|
|
|
|
|
color: color
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-03-17 12:56:04 +01:00
|
|
|
series: []
|
|
|
|
|
};
|
|
|
|
|
var myComments=[];
|
|
|
|
|
|
|
|
|
|
var series = {
|
|
|
|
|
data: []
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$.each(tmp.qsodata, function(){
|
|
|
|
|
myComments.push(this.calls);
|
|
|
|
|
options.xAxis.categories.push(this.time);
|
|
|
|
|
series.name = 'Number of QSOs';
|
|
|
|
|
series.data.push(this.count);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
options.series.push(series);
|
|
|
|
|
|
|
|
|
|
var chart = new Highcharts.Chart(options);
|
|
|
|
|
}
|
2026-04-26 22:10:29 +01:00
|
|
|
|
|
|
|
|
function renderTimeplotFromComponent() {
|
|
|
|
|
var paramsElement = document.getElementById('timeplotParams');
|
|
|
|
|
if (!paramsElement) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var band = paramsElement.dataset.band || 'All';
|
|
|
|
|
var dxcc = paramsElement.dataset.dxcc || 'All';
|
|
|
|
|
var cqzone = paramsElement.dataset.cqzone || 'All';
|
|
|
|
|
|
|
|
|
|
timeplotRender(band, dxcc, cqzone);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
document.body.addEventListener('htmx:afterSwap', function (event) {
|
|
|
|
|
if (event.target && event.target.id === 'timeplotterResults') {
|
|
|
|
|
renderTimeplotFromComponent();
|
|
|
|
|
}
|
|
|
|
|
});
|