2023-12-15 08:03:32 +00:00
var modalloading = false ;
2023-06-19 09:29:46 +00:00
$ ( '#band' ) . change ( function ( ) {
var band = $ ( "#band option:selected" ) . text ( ) ;
if ( band != "SAT" ) {
$ ( "#sats" ) . prop ( 'disabled' , true ) ;
} else {
$ ( "#sats" ) . prop ( 'disabled' , false ) ;
}
} ) ;
2023-06-18 20:01:59 +00:00
var map ;
2023-11-27 23:20:47 +00: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 12:06:33 +00:00
function gridPlot ( form , visitor = true ) {
2023-07-15 13:42:42 +00:00
$ ( ".ld-ext-right-plot" ) . addClass ( 'running' ) ;
2023-11-27 23:20:47 +00:00
$ ( ".ld-ext-right-plot" ) . prop ( 'disabled' , true ) ;
2023-06-18 20:01:59 +00: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 09:44:26 +00:00
$ ( "#gridmapcontainer" ) . append ( '<div id="gridsquare_map" class="map-leaflet" style="width: 100%; height: 800px"></div>' ) ;
2023-06-18 20:01:59 +00:00
}
2023-12-01 12:06:33 +00:00
if ( typeof type == 'undefined' ) { type = '' ; }
2023-09-11 14:59:05 +00: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' ;
}
2023-11-27 23:20:47 +00:00
if ( visitor != true ) {
2023-06-18 20:01:59 +00:00
$ . ajax ( {
2023-09-11 14:59:05 +00:00
url : ajax _url ,
2023-06-18 20:01:59 +00:00
type : 'post' ,
data : {
band : $ ( "#band" ) . val ( ) ,
mode : $ ( "#mode" ) . val ( ) ,
qsl : $ ( "#qsl" ) . is ( ":checked" ) ,
lotw : $ ( "#lotw" ) . is ( ":checked" ) ,
2023-06-19 09:29:46 +00:00
eqsl : $ ( "#eqsl" ) . is ( ":checked" ) ,
2023-12-08 12:23:19 +00:00
qrz : $ ( "#qrz" ) . is ( ":checked" ) ,
2023-06-19 09:29:46 +00:00
sat : $ ( "#sats" ) . val ( ) ,
2023-06-18 20:01:59 +00:00
} ,
success : function ( data ) {
2023-07-02 14:50:06 +00:00
$ ( '.cohidden' ) . show ( ) ;
2023-07-15 13:42:42 +00:00
$ ( ".ld-ext-right-plot" ) . removeClass ( 'running' ) ;
$ ( ".ld-ext-right-plot" ) . prop ( 'disabled' , false ) ;
2023-06-18 20:01:59 +00:00
$ ( '#plot' ) . prop ( "disabled" , false ) ;
2023-11-27 23:20:47 +00:00
grid _two = data . grid _2char ;
2023-06-18 20:01:59 +00: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 ;
2023-11-28 07:20:06 +00:00
plot ( visitor , grid _two , grid _four , grid _six , grid _two _confirmed , grid _four _confirmed , grid _six _confirmed ) ;
2023-11-27 23:20:47 +00:00
} ,
error : function ( data ) {
} ,
} ) ;
} else {
2023-11-28 07:20:06 +00:00
plot ( visitor , grid _two , grid _four , grid _six , grid _two _confirmed , grid _four _confirmed , grid _six _confirmed ) ;
2023-11-27 23:20:47 +00:00
} ;
}
2023-11-28 07:20:06 +00:00
function plot ( visitor , grid _two , grid _four , grid _six , grid _two _confirmed , grid _four _confirmed , grid _six _confirmed ) {
2023-06-20 16:39:37 +00:00
var layer = L . tileLayer ( jslayer , {
2023-08-18 08:40:09 +00:00
maxZoom : 12 ,
2023-06-20 16:39:37 +00:00
attribution : jsattribution ,
2023-06-18 20:01:59 +00: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 07:23:26 +00:00
if ( visitor != true ) {
var printer = L . easyPrint ( {
tileLayer : layer ,
sizeModes : [ 'Current' ] ,
filename : 'myMap' ,
exportOnly : true ,
hideControlContainer : true
} ) . addTo ( map ) ;
}
2023-06-19 09:03:29 +00:00
/*Legend specific*/
var legend = L . control ( { position : "topright" } ) ;
legend . onAdd = function ( map ) {
var div = L . DomUtil . create ( "div" , "legend" ) ;
2023-06-20 19:09:13 +00: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 09:03:29 +00:00
return div ;
} ;
legend . addTo ( map ) ;
2023-06-18 20:01:59 +00:00
var maidenhead = L . maidenhead ( ) . addTo ( map ) ;
2023-11-28 07:20:06 +00:00
if ( visitor != true ) {
map . on ( 'mousemove' , onMapMove ) ;
map . on ( 'click' , onMapClick ) ;
}
2023-06-18 20:01:59 +00: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 ,
dom : 'Bfrtip' ,
buttons : [
'csv'
]
} ) ;
// change color of csv-button if dark mode is chosen
if ( isDarkModeTheme ( ) ) {
$ ( ".buttons-csv" ) . css ( "color" , "white" ) ;
}
} ,
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 09:10:16 +00:00
}
2023-07-15 13:42:42 +00: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 09:10:16 +00:00
$ ( document ) . ready ( function ( ) {
2023-11-27 23:20:47 +00:00
gridPlot ( this . form , visitor ) ;
2023-07-12 12:28:08 +00:00
} )