2023-12-15 08:03:32 +00:00
var modalloading = false ;
2023-06-19 11:29:46 +02:00
$ ( '#band' ) . change ( function ( ) {
var band = $ ( "#band option:selected" ) . text ( ) ;
if ( band != "SAT" ) {
$ ( "#sats" ) . prop ( 'disabled' , true ) ;
2026-07-17 13:44:06 +01:00
$ ( "#satellite-filter-group" ) . addClass ( 'd-none' ) ;
$ ( "#sats" ) . val ( 'All' ) ;
$ ( "#sat_orbit" ) . val ( 'All' ) ;
2023-06-19 11:29:46 +02:00
} else {
$ ( "#sats" ) . prop ( 'disabled' , false ) ;
2026-07-17 13:44:06 +01:00
$ ( "#satellite-filter-group" ) . removeClass ( 'd-none' ) . addClass ( 'd-flex' ) ;
2023-06-19 11:29:46 +02:00
}
} ) ;
2023-06-18 22:01:59 +02:00
var map ;
2023-11-28 00:20:47 +01:00
if ( typeof ( visitor ) !== 'undefined' && visitor != true ) {
var grid _two = '' ;
var grid _four = '' ;
var grid _six = '' ;
var grid _two _confirmed = '' ;
var grid _four _confirmed = '' ;
var grid _six _confirmed = '' ;
}
2023-12-01 13:06:33 +01:00
function gridPlot ( form , visitor = true ) {
2023-07-15 14:42:42 +01:00
$ ( ".ld-ext-right-plot" ) . addClass ( 'running' ) ;
2023-11-28 00:20:47 +01:00
$ ( ".ld-ext-right-plot" ) . prop ( 'disabled' , true ) ;
2023-06-18 22:01:59 +02:00
$ ( '#plot' ) . prop ( "disabled" , true ) ;
// If map is already initialized
var container = L . DomUtil . get ( 'gridsquare_map' ) ;
if ( container != null ) {
container . _leaflet _id = null ;
container . remove ( ) ;
2023-12-09 10:44:26 +01:00
$ ( "#gridmapcontainer" ) . append ( '<div id="gridsquare_map" class="map-leaflet" style="width: 100%; height: 800px"></div>' ) ;
2023-06-18 22:01:59 +02:00
}
2023-12-01 13:06:33 +01:00
if ( typeof type == 'undefined' ) { type = '' ; }
2023-09-11 16:59:05 +02:00
if ( type == "activated" ) {
ajax _url = site _url + '/activated_gridmap/getGridsjs' ;
} else if ( type == "worked" ) {
ajax _url = site _url + '/gridmap/getGridsjs' ;
} else {
ajax _url = site _url + '/gridmap/getGridsjs' ;
}
2025-08-19 16:14:47 +00:00
// If visitor context, get the slug from the URL and use visitor endpoint
if ( visitor === true ) {
var pathParts = window . location . pathname . split ( '/' ) ;
var slugIndex = pathParts . indexOf ( 'satellites' ) ;
if ( slugIndex !== - 1 && pathParts [ slugIndex + 1 ] ) {
var slug = pathParts [ slugIndex + 1 ] ;
ajax _url = site _url + '/visitor/getGridsjs' ;
}
}
2023-11-28 00:20:47 +01:00
if ( visitor != true ) {
2023-06-18 22:01:59 +02:00
$ . ajax ( {
2023-09-11 16:59:05 +02:00
url : ajax _url ,
2023-06-18 22:01:59 +02:00
type : 'post' ,
data : {
band : $ ( "#band" ) . val ( ) ,
2026-07-17 13:44:06 +01:00
sat _orbit : $ ( "#sat_orbit" ) . val ( ) ,
2023-06-18 22:01:59 +02:00
mode : $ ( "#mode" ) . val ( ) ,
qsl : $ ( "#qsl" ) . is ( ":checked" ) ,
lotw : $ ( "#lotw" ) . is ( ":checked" ) ,
2023-06-19 11:29:46 +02:00
eqsl : $ ( "#eqsl" ) . is ( ":checked" ) ,
2023-12-08 12:23:19 +00:00
qrz : $ ( "#qrz" ) . is ( ":checked" ) ,
2023-06-19 11:29:46 +02:00
sat : $ ( "#sats" ) . val ( ) ,
2023-06-18 22:01:59 +02:00
} ,
success : function ( data ) {
2024-06-19 14:29:01 +01:00
console . log ( data ) ;
2023-07-02 16:50:06 +02:00
$ ( '.cohidden' ) . show ( ) ;
2023-07-15 14:42:42 +01:00
$ ( ".ld-ext-right-plot" ) . removeClass ( 'running' ) ;
$ ( ".ld-ext-right-plot" ) . prop ( 'disabled' , false ) ;
2023-06-18 22:01:59 +02:00
$ ( '#plot' ) . prop ( "disabled" , false ) ;
2023-11-28 00:20:47 +01:00
grid _two = data . grid _2char ;
2023-06-18 22:01:59 +02:00
grid _four = data . grid _4char ;
grid _six = data . grid _6char ;
grid _two _confirmed = data . grid _2char _confirmed ;
grid _four _confirmed = data . grid _4char _confirmed ;
grid _six _confirmed = data . grid _6char _confirmed ;
2026-07-17 13:44:06 +01:00
updateSatelliteFilterVisibility ( ) ;
renderActivatedGridSummary ( {
worked : grid _four . length ,
confirmed : grid _four _confirmed . length ,
satellite : data . satellite _breakdown || { total : 0 , LEO : 0 , MEO : 0 , GEO : 0 } ,
satelliteConfirmed : data . satellite _breakdown _confirmed || { total : 0 , LEO : 0 , MEO : 0 , GEO : 0 }
} ) ;
2023-11-28 08:20:06 +01:00
plot ( visitor , grid _two , grid _four , grid _six , grid _two _confirmed , grid _four _confirmed , grid _six _confirmed ) ;
2023-11-28 00:20:47 +01:00
} ,
error : function ( data ) {
} ,
} ) ;
} else {
2025-08-19 16:14:47 +00:00
// Visitor context - use AJAX to get filtered data
var pathParts = window . location . pathname . split ( '/' ) ;
var slugIndex = pathParts . indexOf ( 'satellites' ) ;
if ( slugIndex !== - 1 && pathParts [ slugIndex + 1 ] ) {
var slug = pathParts [ slugIndex + 1 ] ;
$ . ajax ( {
url : ajax _url ,
type : 'post' ,
data : {
slug : slug ,
band : $ ( "#band" ) . val ( ) ,
2026-07-17 13:44:06 +01:00
sat _orbit : $ ( "#sat_orbit" ) . val ( ) ,
2025-08-19 16:14:47 +00:00
mode : $ ( "#mode" ) . val ( ) ,
sat : $ ( "#sats" ) . val ( ) ,
} ,
success : function ( data ) {
console . log ( data ) ;
$ ( '.cohidden' ) . show ( ) ;
$ ( ".ld-ext-right-plot" ) . removeClass ( 'running' ) ;
$ ( ".ld-ext-right-plot" ) . prop ( 'disabled' , false ) ;
$ ( '#plot' ) . prop ( "disabled" , false ) ;
grid _two = data . grid _2char ;
grid _four = data . grid _4char ;
grid _six = data . grid _6char ;
grid _two _confirmed = data . grid _2char _confirmed ;
grid _four _confirmed = data . grid _4char _confirmed ;
grid _six _confirmed = data . grid _6char _confirmed ;
2026-07-17 13:44:06 +01:00
updateSatelliteFilterVisibility ( ) ;
renderActivatedGridSummary ( {
worked : grid _four . length ,
confirmed : grid _four _confirmed . length ,
satellite : data . satellite _breakdown || { total : 0 , LEO : 0 , MEO : 0 , GEO : 0 } ,
satelliteConfirmed : data . satellite _breakdown _confirmed || { total : 0 , LEO : 0 , MEO : 0 , GEO : 0 }
} ) ;
2025-08-19 16:14:47 +00:00
plot ( visitor , grid _two , grid _four , grid _six , grid _two _confirmed , grid _four _confirmed , grid _six _confirmed ) ;
} ,
error : function ( data ) {
console . error ( 'Error loading visitor grid data:' , data ) ;
} ,
} ) ;
} else {
// Fallback: use predefined grid data if available
plot ( visitor , grid _two , grid _four , grid _six , grid _two _confirmed , grid _four _confirmed , grid _six _confirmed ) ;
}
2023-11-28 00:20:47 +01:00
} ;
}
2023-11-28 08:20:06 +01:00
function plot ( visitor , grid _two , grid _four , grid _six , grid _two _confirmed , grid _four _confirmed , grid _six _confirmed ) {
2023-06-20 18:39:37 +02:00
var layer = L . tileLayer ( jslayer , {
2023-08-18 08:40:09 +00:00
maxZoom : 12 ,
2023-06-20 18:39:37 +02:00
attribution : jsattribution ,
2023-06-18 22:01:59 +02:00
id : 'mapbox.streets'
} ) ;
map = L . map ( 'gridsquare_map' , {
layers : [ layer ] ,
center : [ 19 , 0 ] ,
zoom : 3 ,
minZoom : 2 ,
fullscreenControl : true ,
fullscreenControlOptions : {
position : 'topleft'
} ,
} ) ;
2023-11-28 08:23:26 +01:00
if ( visitor != true ) {
var printer = L . easyPrint ( {
tileLayer : layer ,
sizeModes : [ 'Current' ] ,
filename : 'myMap' ,
exportOnly : true ,
hideControlContainer : true
} ) . addTo ( map ) ;
}
2023-06-19 11:03:29 +02:00
/*Legend specific*/
var legend = L . control ( { position : "topright" } ) ;
legend . onAdd = function ( map ) {
var div = L . DomUtil . create ( "div" , "legend" ) ;
2023-06-20 21:09:13 +02:00
div . innerHTML += "<h4>" + gridsquares _gridsquares + "</h4>" ;
div . innerHTML += '<i style="background: green"></i><span>' + gridsquares _gridsquares _confirmed + ' (' + grid _four _confirmed . length + ')</span><br>' ;
div . innerHTML += '<i style="background: red"></i><span>' + gridsquares _gridsquares _not _confirmed + ' (' + ( grid _four . length - grid _four _confirmed . length ) + ')</span><br>' ;
div . innerHTML += '<i></i><span>' + gridsquares _gridsquares _total _worked + ' (' + grid _four . length + ')</span><br>' ;
2023-06-19 11:03:29 +02:00
return div ;
} ;
legend . addTo ( map ) ;
2023-06-18 22:01:59 +02:00
var maidenhead = L . maidenhead ( ) . addTo ( map ) ;
2023-11-28 08:20:06 +01:00
if ( visitor != true ) {
map . on ( 'mousemove' , onMapMove ) ;
map . on ( 'click' , onMapClick ) ;
}
2023-06-18 22:01:59 +02:00
}
2026-07-17 13:44:06 +01:00
function renderActivatedGridSummary ( summary ) {
var worked = Number ( summary . worked || 0 ) ;
var confirmed = Number ( summary . confirmed || 0 ) ;
var unconfirmed = Math . max ( worked - confirmed , 0 ) ;
var confirmedPercent = worked > 0 ? Math . round ( ( confirmed / worked ) * 100 ) : 0 ;
var satellite = summary . satellite || { total : 0 , LEO : 0 , MEO : 0 , GEO : 0 } ;
var satelliteConfirmed = summary . satelliteConfirmed || { total : 0 , LEO : 0 , MEO : 0 , GEO : 0 } ;
var html = '' ;
html += '<div class="col-lg-4 col-md-6">' ;
html += ' <div class="card shadow-sm border-0 h-100">' ;
html += ' <div class="card-body">' ;
html += ' <div class="text-uppercase text-muted small fw-semibold">Worked grids</div>' ;
html += ' <div class="display-6 fw-bold">' + worked + '</div>' ;
html += ' <div class="text-muted">Unique 4-character squares on the map</div>' ;
html += ' </div>' ;
html += ' </div>' ;
html += '</div>' ;
html += '<div class="col-lg-4 col-md-6">' ;
html += ' <div class="card shadow-sm border-0 h-100">' ;
html += ' <div class="card-body">' ;
html += ' <div class="text-uppercase text-muted small fw-semibold">Confirmed grids</div>' ;
html += ' <div class="display-6 fw-bold text-success">' + confirmed + '</div>' ;
html += ' <div class="progress mb-2" style="height: 8px;">' ;
html += ' <div class="progress-bar bg-success" role="progressbar" style="width: ' + confirmedPercent + '%" aria-valuenow="' + confirmedPercent + '" aria-valuemin="0" aria-valuemax="100"></div>' ;
html += ' </div>' ;
html += ' <div class="text-muted">' + confirmedPercent + '% of worked squares are confirmed</div>' ;
html += ' <div class="mt-2 small text-muted">Unconfirmed: <span class="fw-semibold text-danger">' + unconfirmed + '</span></div>' ;
html += ' </div>' ;
html += ' </div>' ;
html += '</div>' ;
html += '<div class="col-lg-4 col-md-12">' ;
html += ' <div class="card shadow-sm border-0 h-100">' ;
html += ' <div class="card-body">' ;
html += ' <div class="d-flex justify-content-between align-items-start gap-2">' ;
html += ' <div>' ;
html += ' <div class="text-uppercase text-muted small fw-semibold">Satellite split</div>' ;
html += ' <div class="display-6 fw-bold">' + satellite . total + '</div>' ;
html += ' </div>' ;
html += ' <span class="badge rounded-pill text-bg-dark align-self-start">LEO / MEO / GEO</span>' ;
html += ' </div>' ;
html += ' <div class="d-flex flex-wrap gap-2">' ;
html += ' <span class="badge rounded-pill text-bg-primary">LEO ' + satellite . LEO + '</span>' ;
html += ' <span class="badge rounded-pill text-bg-warning">MEO ' + satellite . MEO + ' (IO-117)</span>' ;
html += ' <span class="badge rounded-pill text-bg-info">GEO ' + satellite . GEO + ' (QO-100)</span>' ;
html += ' </div>' ;
html += ' <div class="mt-2 small text-muted">Counts are per satellite class and can overlap if a grid has been worked on more than one satellite.</div>' ;
html += ' </div>' ;
html += ' </div>' ;
html += '</div>' ;
$ ( '#activated-grid-summary' ) . html ( html ) ;
}
function updateSatelliteFilterVisibility ( ) {
var band = $ ( "#band" ) . val ( ) ;
if ( band === 'SAT' ) {
$ ( "#satellite-filter-group" ) . removeClass ( 'd-none' ) . addClass ( 'd-flex' ) ;
$ ( "#sats" ) . prop ( 'disabled' , false ) ;
} else {
$ ( "#satellite-filter-group" ) . addClass ( 'd-none' ) . removeClass ( 'd-flex' ) ;
$ ( "#sats" ) . prop ( 'disabled' , true ) . val ( 'All' ) ;
$ ( "#sat_orbit" ) . val ( 'All' ) ;
}
}
2023-06-18 22:01:59 +02:00
function spawnGridsquareModal ( loc _4char ) {
2023-12-15 08:03:32 +00:00
if ( ! ( modalloading ) ) {
var ajax _data = ( {
'Searchphrase' : loc _4char ,
'Band' : $ ( "#band" ) . val ( ) ,
'Mode' : $ ( "#mode" ) . val ( ) ,
'Type' : 'VUCC'
} )
if ( type == 'activated' ) {
ajax _data . searchmode = 'activated' ;
}
modalloading = true ;
$ . ajax ( {
url : base _url + 'index.php/awards/qso_details_ajax' ,
type : 'post' ,
data : ajax _data ,
success : function ( html ) {
BootstrapDialog . show ( {
title : lang _general _word _qso _data ,
cssClass : 'qso-dialog' ,
size : BootstrapDialog . SIZE _WIDE ,
nl2br : false ,
message : html ,
onshown : function ( dialog ) {
modalloading = false ;
$ ( '[data-bs-toggle="tooltip"]' ) . tooltip ( ) ;
$ ( '.contacttable' ) . DataTable ( {
"pageLength" : 25 ,
responsive : false ,
ordering : false ,
"scrollY" : "550px" ,
"scrollCollapse" : true ,
"paging" : false ,
"scrollX" : true ,
2024-01-03 22:03:11 -05:00
"language" : {
2024-01-03 22:18:20 -05:00
url : getDataTablesLanguageUrl ( ) ,
2024-01-03 22:03:11 -05:00
} ,
2023-12-15 08:03:32 +00:00
dom : 'Bfrtip' ,
buttons : [
'csv'
]
} ) ;
// change color of csv-button if dark mode is chosen
if ( isDarkModeTheme ( ) ) {
$ ( ".buttons-csv" ) . css ( "color" , "white" ) ;
}
2023-12-22 11:15:00 +01:00
$ ( '.table-responsive .dropdown-toggle' ) . off ( 'mouseenter' ) . on ( 'mouseenter' , function ( ) {
showQsoActionsMenu ( $ ( this ) . closest ( '.dropdown' ) ) ;
} ) ;
2023-12-15 08:03:32 +00:00
} ,
buttons : [ {
label : lang _admin _close ,
action : function ( dialogItself ) {
dialogItself . close ( ) ;
}
} ]
} ) ;
} ,
error : function ( e ) {
modalloading = false ;
}
} ) ;
2023-12-15 06:45:05 +00:00
}
2023-07-04 11:10:16 +02:00
}
2023-07-15 14:42:42 +01:00
function clearMarkers ( ) {
$ ( ".ld-ext-right-clear" ) . addClass ( 'running' ) ;
$ ( ".ld-ext-right-clear" ) . prop ( 'disabled' , true ) ;
clicklines . forEach ( function ( item ) {
map . removeLayer ( item )
} ) ;
clickmarkers . forEach ( function ( item ) {
map . removeLayer ( item )
} ) ;
$ ( ".ld-ext-right-clear" ) . removeClass ( 'running' ) ;
$ ( ".ld-ext-right-clear" ) . prop ( 'disabled' , false ) ;
}
2023-07-04 11:10:16 +02:00
$ ( document ) . ready ( function ( ) {
2026-07-17 13:44:06 +01:00
updateSatelliteFilterVisibility ( ) ;
gridPlot ( this . form , visitor ) ;
2023-07-12 14:28:08 +02:00
} )