| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | $( document ).ready(function() { | 
					
						
							| 
									
										
										
										
											2022-04-01 01:35:25 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	$("#locator") | 
					
						
							| 
									
										
										
										
											2022-04-01 01:36:35 +08:00
										 |  |  | 		.popover({ placement: 'top', title: 'Gridsquare Formatting', content: "Enter multiple (4-digit) grids separated with commas. For example: IO77,IO78" }) | 
					
						
							| 
									
										
										
										
											2022-04-01 05:09:50 +08:00
										 |  |  | 		.focus(function () { | 
					
						
							|  |  |  | 			$('#locator').popover('show'); | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2022-04-01 01:35:25 +08:00
										 |  |  | 		.blur(function () { | 
					
						
							| 
									
										
										
										
											2022-04-01 05:09:50 +08:00
										 |  |  | 			$('#locator').popover('hide'); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-12 03:50:01 +08:00
										 |  |  | 	$("#sat_name").change(function(){ | 
					
						
							|  |  |  | 		var sat = $("#sat_name").val(); | 
					
						
							|  |  |  | 		if (sat == "") { | 
					
						
							|  |  |  | 			$("#sat_mode").val(""); | 
					
						
							|  |  |  | 			$("#selectPropagation").val(""); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	$('#input_usa_state').change(function(){ | 
					
						
							|  |  |  | 		var state = $("#input_usa_state option:selected").text(); | 
					
						
							|  |  |  | 		if (state != "") { | 
					
						
							|  |  |  | 			$("#stationCntyInput").prop('disabled', false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			$('#stationCntyInput').selectize({ | 
					
						
							|  |  |  | 				maxItems: 1, | 
					
						
							|  |  |  | 				closeAfterSelect: true, | 
					
						
							|  |  |  | 				loadThrottle: 250, | 
					
						
							|  |  |  | 				valueField: 'name', | 
					
						
							|  |  |  | 				labelField: 'name', | 
					
						
							|  |  |  | 				searchField: 'name', | 
					
						
							|  |  |  | 				options: [], | 
					
						
							|  |  |  | 				create: false, | 
					
						
							|  |  |  | 				load: function(query, callback) { | 
					
						
							|  |  |  | 					var state = $("#input_usa_state option:selected").text(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					if (!query || state == "") return callback(); | 
					
						
							|  |  |  | 					$.ajax({ | 
					
						
							|  |  |  | 						url: base_url+'index.php/qso/get_county', | 
					
						
							|  |  |  | 						type: 'GET', | 
					
						
							|  |  |  | 						dataType: 'json', | 
					
						
							|  |  |  | 						data: { | 
					
						
							|  |  |  | 							query: query, | 
					
						
							|  |  |  | 							state: state, | 
					
						
							|  |  |  | 						}, | 
					
						
							|  |  |  | 						error: function() { | 
					
						
							|  |  |  | 							callback(); | 
					
						
							|  |  |  | 						}, | 
					
						
							|  |  |  | 						success: function(res) { | 
					
						
							|  |  |  | 							callback(res); | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					}); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			$("#stationCntyInput").prop('disabled', true); | 
					
						
							|  |  |  | 			//$('#stationCntyInput')[0].selectize.destroy();
 | 
					
						
							|  |  |  | 			$("#stationCntyInput").val(""); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$('#sota_ref').selectize({ | 
					
						
							|  |  |  | 		maxItems: 1, | 
					
						
							|  |  |  | 		closeAfterSelect: true, | 
					
						
							|  |  |  | 		loadThrottle: 250, | 
					
						
							|  |  |  | 		valueField: 'name', | 
					
						
							|  |  |  | 		labelField: 'name', | 
					
						
							|  |  |  | 		searchField: 'name', | 
					
						
							|  |  |  | 		options: [], | 
					
						
							| 
									
										
										
										
											2023-02-07 02:07:30 +08:00
										 |  |  | 		create: true, | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 		load: function(query, callback) { | 
					
						
							|  |  |  | 			if (!query || query.length < 3) return callback();  // Only trigger if 3 or more characters are entered
 | 
					
						
							|  |  |  | 			$.ajax({ | 
					
						
							|  |  |  | 				url: base_url+'index.php/qso/get_sota', | 
					
						
							|  |  |  | 				type: 'GET', | 
					
						
							|  |  |  | 				dataType: 'json', | 
					
						
							|  |  |  | 				data: { | 
					
						
							|  |  |  | 					query: query, | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 				error: function() { | 
					
						
							|  |  |  | 					callback(); | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 				success: function(res) { | 
					
						
							|  |  |  | 					callback(res); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-02 19:52:39 +08:00
										 |  |  | 	$('#sota_ref').change(function(){ | 
					
						
							|  |  |  | 		$('#sota_info').html('<a target="_blank" href="https://summits.sota.org.uk/summit/'+$('#sota_ref').val()+'"><img width="32" height="32" src="'+base_url+'images/icons/sota.org.uk.png"></a>');  | 
					
						
							|  |  |  | 		$('#sota_info').attr('title', 'Lookup '+$('#sota_ref').val()+' summit info on sota.org.uk'); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-15 22:04:33 +08:00
										 |  |  | 	$('#wwff_ref').selectize({ | 
					
						
							|  |  |  | 		maxItems: 1, | 
					
						
							|  |  |  | 		closeAfterSelect: true, | 
					
						
							|  |  |  | 		loadThrottle: 250, | 
					
						
							|  |  |  | 		valueField: 'name', | 
					
						
							|  |  |  | 		labelField: 'name', | 
					
						
							|  |  |  | 		searchField: 'name', | 
					
						
							|  |  |  | 		options: [], | 
					
						
							| 
									
										
										
										
											2023-02-06 15:33:19 +08:00
										 |  |  | 		create: true, | 
					
						
							| 
									
										
										
										
											2022-08-15 22:04:33 +08:00
										 |  |  | 		load: function(query, callback) { | 
					
						
							|  |  |  | 			if (!query || query.length < 3) return callback();  // Only trigger if 3 or more characters are entered
 | 
					
						
							|  |  |  | 			$.ajax({ | 
					
						
							|  |  |  | 				url: base_url+'index.php/qso/get_wwff', | 
					
						
							|  |  |  | 				type: 'GET', | 
					
						
							|  |  |  | 				dataType: 'json', | 
					
						
							|  |  |  | 				data: { | 
					
						
							|  |  |  | 					query: query, | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 				error: function() { | 
					
						
							|  |  |  | 					callback(); | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 				success: function(res) { | 
					
						
							|  |  |  | 					callback(res); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$('#wwff_ref').change(function(){ | 
					
						
							| 
									
										
										
										
											2022-10-19 00:54:50 +08:00
										 |  |  | 		$('#wwff_info').html('<a target="_blank" href="https://www.cqgma.org/zinfo.php?ref='+$('#wwff_ref').val()+'"><img width="32" height="32" src="'+base_url+'images/icons/wwff.co.png"></a>');  | 
					
						
							|  |  |  | 		$('#wwff_info').attr('title', 'Lookup '+$('#wwff_ref').val()+' reference info on cqgma.org'); | 
					
						
							| 
									
										
										
										
											2022-08-15 22:04:33 +08:00
										 |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-05 23:05:53 +08:00
										 |  |  | 	$('#pota_ref').selectize({ | 
					
						
							|  |  |  | 		maxItems: 1, | 
					
						
							|  |  |  | 		closeAfterSelect: true, | 
					
						
							|  |  |  | 		loadThrottle: 250, | 
					
						
							|  |  |  | 		valueField: 'name', | 
					
						
							|  |  |  | 		labelField: 'name', | 
					
						
							|  |  |  | 		searchField: 'name', | 
					
						
							|  |  |  | 		options: [], | 
					
						
							| 
									
										
										
										
											2023-02-07 02:07:30 +08:00
										 |  |  | 		create: true, | 
					
						
							| 
									
										
										
										
											2022-10-05 23:05:53 +08:00
										 |  |  | 		load: function(query, callback) { | 
					
						
							|  |  |  | 			if (!query || query.length < 3) return callback();  // Only trigger if 3 or more characters are entered
 | 
					
						
							|  |  |  | 			$.ajax({ | 
					
						
							|  |  |  | 				url: base_url+'index.php/qso/get_pota', | 
					
						
							|  |  |  | 				type: 'GET', | 
					
						
							|  |  |  | 				dataType: 'json', | 
					
						
							|  |  |  | 				data: { | 
					
						
							|  |  |  | 					query: query, | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 				error: function() { | 
					
						
							|  |  |  | 					callback(); | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 				success: function(res) { | 
					
						
							|  |  |  | 					callback(res); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$('#pota_ref').change(function(){ | 
					
						
							|  |  |  | 		$('#pota_info').html('<a target="_blank" href="https://pota.app/#/park/'+$('#pota_ref').val()+'"><img width="32" height="32" src="'+base_url+'images/icons/pota.app.png"></a>');  | 
					
						
							|  |  |  | 		$('#pota_info').attr('title', 'Lookup '+$('#pota_ref').val()+' reference info on pota.co'); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 	$('#darc_dok').selectize({ | 
					
						
							|  |  |  | 		maxItems: 1, | 
					
						
							|  |  |  | 		closeAfterSelect: true, | 
					
						
							|  |  |  | 		loadThrottle: 250, | 
					
						
							|  |  |  | 		valueField: 'name', | 
					
						
							|  |  |  | 		labelField: 'name', | 
					
						
							|  |  |  | 		searchField: 'name', | 
					
						
							|  |  |  | 		options: [], | 
					
						
							| 
									
										
										
										
											2021-08-09 00:30:07 +08:00
										 |  |  | 		create: true, | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 		load: function(query, callback) { | 
					
						
							|  |  |  | 			if (!query) return callback();  // Only trigger if at least 1 character is entered
 | 
					
						
							|  |  |  | 			$.ajax({ | 
					
						
							|  |  |  | 				url: base_url+'index.php/qso/get_dok', | 
					
						
							|  |  |  | 				type: 'GET', | 
					
						
							|  |  |  | 				dataType: 'json', | 
					
						
							|  |  |  | 				data: { | 
					
						
							|  |  |  | 					query: query, | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 				error: function() { | 
					
						
							|  |  |  | 					callback(); | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 				success: function(res) { | 
					
						
							|  |  |  | 					callback(res); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* | 
					
						
							|  |  |  | 	  Populate the Satellite Names Field on the QSO Panel | 
					
						
							|  |  |  | 	*/ | 
					
						
							|  |  |  | 	$.getJSON(base_url+"assets/json/satellite_data.json", function( data ) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Build the options array
 | 
					
						
							|  |  |  | 		var items = []; | 
					
						
							|  |  |  | 		$.each( data, function( key, val ) { | 
					
						
							|  |  |  | 			items.push( | 
					
						
							|  |  |  | 				'<option value="' + key + '">' + key + '</option>' | 
					
						
							|  |  |  | 			); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Add to the datalist
 | 
					
						
							|  |  |  | 		$('.satellite_names_list').append(items.join( "" )); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var selected_sat; | 
					
						
							|  |  |  | var selected_sat_mode; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $(document).on('change', 'input', function(){ | 
					
						
							|  |  |  | 	var optionslist = $('.satellite_modes_list')[0].options; | 
					
						
							|  |  |  | 	var value = $(this).val(); | 
					
						
							|  |  |  | 	for (var x=0;x<optionslist.length;x++){ | 
					
						
							|  |  |  | 		if (optionslist[x].value === value) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// Store selected sat mode
 | 
					
						
							|  |  |  | 			selected_sat_mode = value; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// get Json file
 | 
					
						
							|  |  |  | 			$.getJSON(base_url + "assets/json/satellite_data.json", function( data ) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// Build the options array
 | 
					
						
							|  |  |  | 				var sat_modes = []; | 
					
						
							|  |  |  | 				$.each( data, function( key, val ) { | 
					
						
							|  |  |  | 					if (key == selected_sat) { | 
					
						
							|  |  |  | 						$.each( val.Modes, function( key1, val2 ) { | 
					
						
							|  |  |  | 							if(key1 == selected_sat_mode) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 								if (val2[0].Uplink_Mode == "LSB" || val2[0].Uplink_Mode == "USB") { | 
					
						
							|  |  |  | 									$("#mode").val("SSB"); | 
					
						
							|  |  |  | 								} else { | 
					
						
							|  |  |  | 									$("#mode").val(val2[0].Uplink_Mode); | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 								$("#band").val(frequencyToBand(val2[0].Uplink_Freq)); | 
					
						
							|  |  |  | 								$("#band_rx").val(frequencyToBand(val2[0].Downlink_Freq)); | 
					
						
							|  |  |  | 								$("#frequency").val(val2[0].Uplink_Freq); | 
					
						
							|  |  |  | 								$("#frequency_rx").val(val2[0].Downlink_Freq); | 
					
						
							|  |  |  | 								$("#selectPropagation").val('SAT'); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						}); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $(document).on('change', 'input', function(){ | 
					
						
							|  |  |  | 	var optionslist = $('.satellite_names_list')[0].options; | 
					
						
							|  |  |  | 	var value = $(this).val(); | 
					
						
							|  |  |  | 	for (var x=0;x<optionslist.length;x++){ | 
					
						
							|  |  |  | 		if (optionslist[x].value === value) { | 
					
						
							|  |  |  | 			$("#sat_mode").val(""); | 
					
						
							|  |  |  | 			$('.satellite_modes_list').find('option').remove().end(); | 
					
						
							|  |  |  | 			selected_sat = value; | 
					
						
							|  |  |  | 			// get Json file
 | 
					
						
							|  |  |  | 			$.getJSON( base_url+"assets/json/satellite_data.json", function( data ) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// Build the options array
 | 
					
						
							|  |  |  | 				var sat_modes = []; | 
					
						
							|  |  |  | 				$.each( data, function( key, val ) { | 
					
						
							|  |  |  | 					if (key == value) { | 
					
						
							|  |  |  | 						$.each( val.Modes, function( key1, val2 ) { | 
					
						
							|  |  |  | 							//console.log (key1);
 | 
					
						
							|  |  |  | 							sat_modes.push('<option value="' + key1 + '">' + key1 + '</option>'); | 
					
						
							|  |  |  | 						}); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// Add to the datalist
 | 
					
						
							|  |  |  | 				$('.satellite_modes_list').append(sat_modes.join( "" )); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function changebadge(entityname) { | 
					
						
							|  |  |  | 	if($("#sat_name" ).val() != "") { | 
					
						
							|  |  |  | 		$.getJSON('logbook/jsonlookupdxcc/' + convert_case(entityname) + '/SAT/0/0', function(result) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			$('#callsign_info').removeClass("badge-secondary"); | 
					
						
							|  |  |  | 			$('#callsign_info').removeClass("badge-success"); | 
					
						
							|  |  |  | 			$('#callsign_info').removeClass("badge-danger"); | 
					
						
							|  |  |  | 			$('#callsign_info').attr('title', ''); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if (result.workedBefore) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				$('#callsign_info').addClass("badge-success"); | 
					
						
							|  |  |  | 				$('#callsign_info').attr('title', 'DXCC was already worked in the past on this band and mode!'); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			else | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				$('#callsign_info').addClass("badge-danger"); | 
					
						
							|  |  |  | 				$('#callsign_info').attr('title', 'New DXCC, not worked on this band and mode!'); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		$.getJSON('logbook/jsonlookupdxcc/' + convert_case(entityname) + '/0/' + $("#band").val() +'/' + $("#mode").val(), function(result) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			// Reset CSS values before updating
 | 
					
						
							|  |  |  | 			$('#callsign_info').removeClass("badge-secondary"); | 
					
						
							|  |  |  | 			$('#callsign_info').removeClass("badge-success"); | 
					
						
							|  |  |  | 			$('#callsign_info').removeClass("badge-danger"); | 
					
						
							|  |  |  | 			$('#callsign_info').attr('title', ''); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if (result.workedBefore) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				$('#callsign_info').addClass("badge-success"); | 
					
						
							|  |  |  | 				$('#callsign_info').attr('title', 'DXCC was already worked in the past on this band and mode!'); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			else | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				$('#callsign_info').addClass("badge-danger"); | 
					
						
							|  |  |  | 				$('#callsign_info').attr('title', 'New DXCC, not worked on this band and mode!'); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Function: reset_fields is used to reset the fields on the QSO page */ | 
					
						
							|  |  |  | function reset_fields() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$('#locator_info').text(""); | 
					
						
							|  |  |  | 	$('#country').val(""); | 
					
						
							| 
									
										
										
										
											2023-02-05 00:41:21 +08:00
										 |  |  | 	$('#continent').val(""); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 	$('#lotw_info').text(""); | 
					
						
							| 
									
										
										
										
											2021-12-19 21:22:49 +08:00
										 |  |  | 	$('#qrz_info').text(""); | 
					
						
							| 
									
										
										
										
											2021-12-20 05:07:51 +08:00
										 |  |  | 	$('#hamqth_info').text(""); | 
					
						
							| 
									
										
										
										
											2022-01-02 19:52:39 +08:00
										 |  |  | 	$('#sota_info').text(""); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 	$('#dxcc_id').val(""); | 
					
						
							|  |  |  | 	$('#cqz').val(""); | 
					
						
							|  |  |  | 	$('#name').val(""); | 
					
						
							|  |  |  | 	$('#qth').val(""); | 
					
						
							|  |  |  | 	$('#locator').val(""); | 
					
						
							|  |  |  | 	$('#iota_ref').val(""); | 
					
						
							| 
									
										
										
										
											2022-01-02 19:52:39 +08:00
										 |  |  | 	$('#sota_ref').val(""); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 	$("#locator").removeClass("workedGrid"); | 
					
						
							|  |  |  | 	$("#locator").removeClass("newGrid"); | 
					
						
							|  |  |  | 	$("#callsign").removeClass("workedGrid"); | 
					
						
							|  |  |  | 	$("#callsign").removeClass("newGrid"); | 
					
						
							|  |  |  | 	$('#callsign_info').removeClass("badge-secondary"); | 
					
						
							|  |  |  | 	$('#callsign_info').removeClass("badge-success"); | 
					
						
							|  |  |  | 	$('#callsign_info').removeClass("badge-danger"); | 
					
						
							| 
									
										
										
										
											2022-04-03 16:28:36 +08:00
										 |  |  | 	$('#callsign-image').attr('style', 'display: none;'); | 
					
						
							|  |  |  | 	$('#callsign-image-content').text(""); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 	$('#qsl_via').val(""); | 
					
						
							|  |  |  | 	$('#callsign_info').text(""); | 
					
						
							|  |  |  | 	$('#input_usa_state').val(""); | 
					
						
							|  |  |  | 	$('#qso-last-table').show(); | 
					
						
							|  |  |  | 	$('#partial_view').hide(); | 
					
						
							| 
									
										
										
										
											2022-08-15 22:04:33 +08:00
										 |  |  | 	var $select = $('#wwff_ref').selectize(); | 
					
						
							|  |  |  | 	var selectize = $select[0].selectize; | 
					
						
							|  |  |  | 	selectize.clear(); | 
					
						
							| 
									
										
										
										
											2022-10-05 23:05:53 +08:00
										 |  |  | 	var $select = $('#pota_ref').selectize(); | 
					
						
							|  |  |  | 	var selectize = $select[0].selectize; | 
					
						
							|  |  |  | 	selectize.clear(); | 
					
						
							| 
									
										
										
										
											2022-04-15 04:36:47 +08:00
										 |  |  | 	var $select = $('#darc_dok').selectize(); | 
					
						
							|  |  |  | 	var selectize = $select[0].selectize; | 
					
						
							|  |  |  | 	selectize.clear(); | 
					
						
							| 
									
										
										
										
											2022-04-17 04:07:13 +08:00
										 |  |  | 	$select = $('#stationCntyInput').selectize(); | 
					
						
							|  |  |  | 	selectize = $select[0].selectize; | 
					
						
							|  |  |  | 	selectize.clear(); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-05 22:21:26 +08:00
										 |  |  | 	mymap.setView(pos, 12); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 	mymap.removeLayer(markers); | 
					
						
							|  |  |  | 	$('.callsign-suggest').hide(); | 
					
						
							| 
									
										
										
										
											2023-01-26 16:10:56 +08:00
										 |  |  | 	$('.dxccsummary').remove(); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $("#callsign").focusout(function() { | 
					
						
							|  |  |  | 	if ($(this).val().length >= 3) { | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Temp store the callsign
 | 
					
						
							|  |  |  | 		var temp_callsign = $(this).val(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 		/* Find and populate DXCC */ | 
					
						
							|  |  |  | 		$('.callsign-suggest').hide(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if($("#sat_name").val() != ""){ | 
					
						
							|  |  |  | 			var sat_type = "SAT"; | 
					
						
							|  |  |  | 			var json_band = "0"; | 
					
						
							|  |  |  | 			var json_mode = "0"; | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			var sat_type = "0"; | 
					
						
							|  |  |  | 			var json_band = $("#band").val(); | 
					
						
							|  |  |  | 			var json_mode = $("#mode").val(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		var find_callsign = $(this).val().toUpperCase(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		find_callsign.replace(/\//g, "-"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Replace / in a callsign with - to stop urls breaking
 | 
					
						
							| 
									
										
										
										
											2022-01-01 00:49:44 +08:00
										 |  |  | 		$.getJSON('logbook/json/' + find_callsign.replace(/\//g, "-") + '/' + sat_type + '/' + json_band + '/' + json_mode + '/' + $('#stationProfile').val(), function(result) | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2022-12-01 22:01:15 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// Make sure the typed callsign and json result match
 | 
					
						
							|  |  |  | 			if($('#callsign').val = result.callsign) { | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-01 22:08:30 +08:00
										 |  |  | 				// Reset QSO fields
 | 
					
						
							|  |  |  | 				resetDefaultQSOFields(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 				if(result.dxcc.entity != undefined) { | 
					
						
							|  |  |  | 					$('#country').val(convert_case(result.dxcc.entity)); | 
					
						
							|  |  |  | 					$('#callsign_info').text(convert_case(result.dxcc.entity)); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 					if($("#sat_name" ).val() != "") { | 
					
						
							|  |  |  | 						//logbook/jsonlookupgrid/io77/SAT/0/0
 | 
					
						
							|  |  |  | 						$.getJSON('logbook/jsonlookupcallsign/' + find_callsign.replace(/\//g, "-") + '/SAT/0/0', function(result) | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 						{ | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 							// Reset CSS values before updating
 | 
					
						
							|  |  |  | 							$('#callsign').removeClass("workedGrid"); | 
					
						
							|  |  |  | 							$('#callsign').removeClass("newGrid"); | 
					
						
							|  |  |  | 							$('#callsign').attr('title', ''); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 							if (result.workedBefore) | 
					
						
							|  |  |  | 							{ | 
					
						
							|  |  |  | 								$('#callsign').addClass("workedGrid"); | 
					
						
							|  |  |  | 								$('#callsign').attr('title', 'Callsign was already worked in the past on this band and mode!'); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 							else | 
					
						
							|  |  |  | 							{ | 
					
						
							|  |  |  | 								$('#callsign').addClass("newGrid"); | 
					
						
							|  |  |  | 								$('#callsign').attr('title', 'New Callsign!'); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						}) | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 						$.getJSON('logbook/jsonlookupcallsign/' + find_callsign.replace(/\//g, "-") + '/0/' + $("#band").val() +'/' + $("#mode").val(), function(result) | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 						{ | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 							// Reset CSS values before updating
 | 
					
						
							|  |  |  | 							$('#callsign').removeClass("workedGrid"); | 
					
						
							|  |  |  | 							$('#callsign').removeClass("newGrid"); | 
					
						
							|  |  |  | 							$('#callsign').attr('title', ''); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 							if (result.workedBefore) | 
					
						
							|  |  |  | 							{ | 
					
						
							|  |  |  | 								$('#callsign').addClass("workedGrid"); | 
					
						
							|  |  |  | 								$('#callsign').attr('title', 'Callsign was already worked in the past on this band and mode!'); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 							else | 
					
						
							|  |  |  | 							{ | 
					
						
							|  |  |  | 								$('#callsign').addClass("newGrid"); | 
					
						
							|  |  |  | 								$('#callsign').attr('title', 'New Callsign!'); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						}) | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 					changebadge(result.dxcc.entity); | 
					
						
							| 
									
										
										
										
											2023-02-20 23:20:16 +08:00
										 |  |  | 					 | 
					
						
							|  |  |  | 					getDxccResult(result.dxcc.adif, convert_case(result.dxcc.entity)); | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 				if(result.lotw_member == "active") { | 
					
						
							|  |  |  | 					$('#lotw_info').text("LoTW"); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2022-01-02 06:17:21 +08:00
										 |  |  | 				$('#qrz_info').html('<a target="_blank" href="https://www.qrz.com/db/'+find_callsign+'"><img width="32" height="32" src="'+base_url+'images/icons/qrz.com.png"></a>');  | 
					
						
							| 
									
										
										
										
											2021-12-20 05:07:51 +08:00
										 |  |  | 				$('#qrz_info').attr('title', 'Lookup '+find_callsign+' info on qrz.com'); | 
					
						
							| 
									
										
										
										
											2022-01-02 06:17:21 +08:00
										 |  |  | 				$('#hamqth_info').html('<a target="_blank" href="https://www.hamqth.com/'+find_callsign+'"><img width="32" height="32" src="'+base_url+'images/icons/hamqth.com.png"></a>');  | 
					
						
							| 
									
										
										
										
											2021-12-20 05:07:51 +08:00
										 |  |  | 				$('#hamqth_info').attr('title', 'Lookup '+find_callsign+' info on hamqth.com'); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-23 04:45:01 +08:00
										 |  |  | 				var $dok_select = $('#darc_dok').selectize(); | 
					
						
							|  |  |  | 				var dok_selectize = $dok_select[0].selectize; | 
					
						
							| 
									
										
										
										
											2022-04-15 04:36:47 +08:00
										 |  |  | 				if (result.dxcc.adif == '230') { | 
					
						
							| 
									
										
										
										
											2022-04-15 05:24:37 +08:00
										 |  |  | 					$.get('lookup/dok/' + $('#callsign').val().toUpperCase(), function(result) { | 
					
						
							|  |  |  | 						if (result) { | 
					
						
							| 
									
										
										
										
											2022-09-23 04:45:01 +08:00
										 |  |  | 							dok_selectize.addOption({name: result}); | 
					
						
							|  |  |  | 							dok_selectize.setValue(result, false); | 
					
						
							| 
									
										
										
										
											2022-04-15 05:24:37 +08:00
										 |  |  | 						} | 
					
						
							|  |  |  | 					}); | 
					
						
							| 
									
										
										
										
											2022-04-15 04:36:47 +08:00
										 |  |  | 				} else { | 
					
						
							| 
									
										
										
										
											2022-09-23 04:45:01 +08:00
										 |  |  | 					dok_selectize.clear(); | 
					
						
							| 
									
										
										
										
											2022-04-15 04:36:47 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 				$('#dxcc_id').val(result.dxcc.adif); | 
					
						
							|  |  |  | 				$('#cqz').val(result.dxcc.cqz); | 
					
						
							|  |  |  | 				$('#ituz').val(result.dxcc.ituz); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 				var redIcon = L.icon({ | 
					
						
							|  |  |  | 					iconUrl: icon_dot_url, | 
					
						
							|  |  |  | 					iconSize:     [18, 18], // size of the icon
 | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 				// Set Map to Lat/Long
 | 
					
						
							|  |  |  | 				markers.clearLayers(); | 
					
						
							|  |  |  | 				mymap.setZoom(8); | 
					
						
							|  |  |  | 				if (typeof result.latlng !== "undefined" && result.latlng !== false) { | 
					
						
							|  |  |  | 					var marker = L.marker([result.latlng[0], result.latlng[1]], {icon: redIcon}); | 
					
						
							|  |  |  | 					mymap.panTo([result.latlng[0], result.latlng[1]]); | 
					
						
							| 
									
										
										
										
											2022-01-09 00:57:17 +08:00
										 |  |  | 					mymap.setView([result.latlng[0], result.latlng[1]], 8); | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 				} else { | 
					
						
							|  |  |  | 					var marker = L.marker([result.dxcc.lat, result.dxcc.long], {icon: redIcon}); | 
					
						
							|  |  |  | 					mymap.panTo([result.dxcc.lat, result.dxcc.long]); | 
					
						
							| 
									
										
										
										
											2022-01-09 00:57:17 +08:00
										 |  |  | 					mymap.setView([result.dxcc.lat, result.dxcc.long], 8); | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 				markers.addLayer(marker).addTo(mymap); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 				/* Find Locator if the field is empty */ | 
					
						
							|  |  |  | 				if($('#locator').val() == "") { | 
					
						
							|  |  |  | 					$('#locator').val(result.callsign_qra); | 
					
						
							|  |  |  | 					$('#locator_info').html(result.bearing); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 					if (result.callsign_qra != "") | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 					{ | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 						if (result.workedBefore) | 
					
						
							|  |  |  | 						{ | 
					
						
							|  |  |  | 							$('#locator').addClass("workedGrid"); | 
					
						
							|  |  |  | 							$('#locator').attr('title', 'Grid was already worked in the past'); | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 						else | 
					
						
							|  |  |  | 						{ | 
					
						
							|  |  |  | 							$('#locator').addClass("newGrid"); | 
					
						
							|  |  |  | 							$('#locator').attr('title', 'New grid!'); | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 					} | 
					
						
							|  |  |  | 					else | 
					
						
							|  |  |  | 					{ | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 						$('#locator').removeClass("workedGrid"); | 
					
						
							|  |  |  | 						$('#locator').removeClass("newGrid"); | 
					
						
							|  |  |  | 						$('#locator').attr('title', ''); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 				/* Find Operators Name */ | 
					
						
							|  |  |  | 				if($('#qsl_via').val() == "") { | 
					
						
							|  |  |  | 					$('#qsl_via').val(result.qsl_manager); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 				/* Find Operators Name */ | 
					
						
							|  |  |  | 				if($('#name').val() == "") { | 
					
						
							|  |  |  | 					$('#name').val(result.callsign_name); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-05 00:41:21 +08:00
										 |  |  | 				if($('#continent').val() == "") { | 
					
						
							|  |  |  | 					$('#continent').val(result.dxcc.cont); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 				if($('#qth').val() == "") { | 
					
						
							|  |  |  | 					$('#qth').val(result.callsign_qth); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-03 16:28:36 +08:00
										 |  |  | 				/* Find link to qrz.com picture */ | 
					
						
							|  |  |  | 				if (result.image != "n/a") { | 
					
						
							|  |  |  | 					$('#callsign-image-content').html('<img class="callsign-image-pic" src="'+result.image+'">'); | 
					
						
							|  |  |  | 					$('#callsign-image').attr('style', 'display: true;'); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 				/* | 
					
						
							|  |  |  | 				* Update state with returned value | 
					
						
							|  |  |  | 				*/ | 
					
						
							|  |  |  | 				if($("#input_usa_state").val() == "") { | 
					
						
							|  |  |  | 					$("#input_usa_state").val(result.callsign_state).trigger('change'); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-17 04:07:13 +08:00
										 |  |  | 				/* | 
					
						
							|  |  |  | 				* Update county with returned value | 
					
						
							|  |  |  | 				*/ | 
					
						
							|  |  |  | 				if( $('#stationCntyInput').has('option').length == 0 && result.callsign_us_county != "") { | 
					
						
							| 
									
										
										
										
											2022-09-23 04:45:01 +08:00
										 |  |  | 					var $county_select = $('#stationCntyInput').selectize(); | 
					
						
							|  |  |  | 					var county_selectize = $county_select[0].selectize; | 
					
						
							|  |  |  | 					county_selectize.addOption({name: result.callsign_us_county}); | 
					
						
							|  |  |  | 					county_selectize.setValue(result.callsign_us_county, false); | 
					
						
							| 
									
										
										
										
											2022-04-17 04:07:13 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-31 23:51:32 +08:00
										 |  |  | 				if($('#iota_ref').val() == "") { | 
					
						
							|  |  |  | 					$('#iota_ref').val(result.callsign_iota); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				// Hide the last QSO table
 | 
					
						
							|  |  |  | 				$('#qso-last-table').hide(); | 
					
						
							|  |  |  | 				$('#partial_view').show(); | 
					
						
							|  |  |  | 				/* display past QSOs */ | 
					
						
							|  |  |  | 				$('#partial_view').html(result.partial); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2022-12-01 22:08:30 +08:00
										 |  |  | 		// Reset QSO fields
 | 
					
						
							|  |  |  | 		resetDefaultQSOFields(); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Only set the frequency when not set by userdata/PHP.
 | 
					
						
							|  |  |  | if ($('#frequency').val() == "") | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	$.get('qso/band_to_freq/' + $('#band').val() + '/' + $('.mode').val(), function(result) { | 
					
						
							|  |  |  | 		$('#frequency').val(result); | 
					
						
							|  |  |  | 		$('#frequency_rx').val(""); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-30 03:17:43 +08:00
										 |  |  | /* time input shortcut */ | 
					
						
							| 
									
										
										
										
											2021-08-30 03:08:34 +08:00
										 |  |  | $('#start_time').change(function() { | 
					
						
							|  |  |  | 	var raw_time = $(this).val(); | 
					
						
							|  |  |  | 	if(raw_time.match(/^\d\[0-6]d$/)) { | 
					
						
							|  |  |  | 		raw_time = "0"+raw_time; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if(raw_time.match(/^[012]\d[0-5]\d$/)) { | 
					
						
							|  |  |  | 		raw_time = raw_time.substring(0,2)+":"+raw_time.substring(2,4); | 
					
						
							|  |  |  | 		$('#start_time').val(raw_time); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-30 03:17:43 +08:00
										 |  |  | /* date input shortcut */ | 
					
						
							|  |  |  | $('#start_date').change(function() { | 
					
						
							|  |  |  | 	 raw_date = $(this).val(); | 
					
						
							| 
									
										
										
										
											2021-08-30 15:03:39 +08:00
										 |  |  | 	if(raw_date.match(/^[12]\d{3}[01]\d[0123]\d$/)) { | 
					
						
							| 
									
										
										
										
											2021-08-30 03:17:43 +08:00
										 |  |  | 		raw_date = raw_date.substring(0,4)+"-"+raw_date.substring(4,6)+"-"+raw_date.substring(6,8); | 
					
						
							|  |  |  | 		$('#start_date').val(raw_date); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | /* on mode change */ | 
					
						
							|  |  |  | $('.mode').change(function() { | 
					
						
							|  |  |  | 	$.get('qso/band_to_freq/' + $('#band').val() + '/' + $('.mode').val(), function(result) { | 
					
						
							|  |  |  | 		$('#frequency').val(result); | 
					
						
							|  |  |  | 		$('#frequency_rx').val(""); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Calculate Frequency */ | 
					
						
							|  |  |  | /* on band change */ | 
					
						
							|  |  |  | $('#band').change(function() { | 
					
						
							|  |  |  | 	$.get('qso/band_to_freq/' + $(this).val() + '/' + $('.mode').val(), function(result) { | 
					
						
							|  |  |  | 		$('#frequency').val(result); | 
					
						
							|  |  |  | 		$('#frequency_rx').val(""); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* On Key up Calculate Bearing and Distance */ | 
					
						
							|  |  |  | $("#locator").keyup(function(){ | 
					
						
							|  |  |  | 	if ($(this).val()) { | 
					
						
							|  |  |  | 		var qra_input = $(this).val(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		var qra_lookup = qra_input.substring(0, 4); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if(qra_lookup.length >= 4) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// Check Log if satname is provided
 | 
					
						
							|  |  |  | 			if($("#sat_name" ).val() != "") { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				//logbook/jsonlookupgrid/io77/SAT/0/0
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$.getJSON('logbook/jsonlookupgrid/' + qra_lookup.toUpperCase() + '/SAT/0/0', function(result) | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					// Reset CSS values before updating
 | 
					
						
							|  |  |  | 					$('#locator').removeClass("workedGrid"); | 
					
						
							|  |  |  | 					$('#locator').removeClass("newGrid"); | 
					
						
							|  |  |  | 					$('#locator').attr('title', ''); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					if (result.workedBefore) | 
					
						
							|  |  |  | 					{ | 
					
						
							|  |  |  | 						$('#locator').addClass("workedGrid"); | 
					
						
							|  |  |  | 						$('#locator').attr('title', 'Grid was already worked in the past'); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					else | 
					
						
							|  |  |  | 					{ | 
					
						
							|  |  |  | 						$('#locator').addClass("newGrid"); | 
					
						
							|  |  |  | 						$('#locator').attr('title', 'New grid!'); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$.getJSON('logbook/jsonlookupgrid/' + qra_lookup.toUpperCase() + '/0/' + $("#band").val() +'/' + $("#mode").val(), function(result) | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					// Reset CSS values before updating
 | 
					
						
							|  |  |  | 					$('#locator').removeClass("workedGrid"); | 
					
						
							|  |  |  | 					$('#locator').removeClass("newGrid"); | 
					
						
							|  |  |  | 					$('#locator').attr('title', ''); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					if (result.workedBefore) | 
					
						
							|  |  |  | 					{ | 
					
						
							|  |  |  | 						$('#locator').addClass("workedGrid"); | 
					
						
							|  |  |  | 						$('#locator').attr('title', 'Grid was already worked in the past'); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					else | 
					
						
							|  |  |  | 					{ | 
					
						
							|  |  |  | 						$('#locator').addClass("newGrid"); | 
					
						
							|  |  |  | 						$('#locator').attr('title', 'New grid!'); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if(qra_input.length >= 4 && $(this).val().length > 0) { | 
					
						
							|  |  |  | 			$.getJSON('logbook/qralatlngjson/' + $(this).val(), function(result) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				// Set Map to Lat/Long
 | 
					
						
							|  |  |  | 				markers.clearLayers(); | 
					
						
							|  |  |  | 				if (typeof result !== "undefined") { | 
					
						
							|  |  |  | 					var redIcon = L.icon({ | 
					
						
							|  |  |  | 						iconUrl: icon_dot_url, | 
					
						
							|  |  |  | 						iconSize:     [18, 18], // size of the icon
 | 
					
						
							|  |  |  | 					}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					var marker = L.marker([result[0], result[1]], {icon: redIcon}); | 
					
						
							|  |  |  | 					mymap.setZoom(8); | 
					
						
							|  |  |  | 					mymap.panTo([result[0], result[1]]); | 
					
						
							| 
									
										
										
										
											2022-01-09 00:57:17 +08:00
										 |  |  | 					mymap.setView([result[0], result[1]], 8); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 				markers.addLayer(marker).addTo(mymap); | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-22 20:31:01 +08:00
										 |  |  | 			$('#locator_info').load("logbook/searchbearing/" + $(this).val() + "/" + $('#stationProfile').val()).fadeIn("slow"); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Change report based on mode
 | 
					
						
							|  |  |  | $('.mode').change(function(){ | 
					
						
							|  |  |  | 	setRst($('.mode') .val()); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function convert_case(str) { | 
					
						
							|  |  |  | 	var lower = str.toLowerCase(); | 
					
						
							|  |  |  | 	return lower.replace(/(^| )(\w)/g, function(x) { | 
					
						
							|  |  |  | 		return x.toUpperCase(); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $('#dxcc_id').on('change', function() { | 
					
						
							|  |  |  | 	$.getJSON('logbook/jsonentity/' + $(this).val(), function (result) { | 
					
						
							|  |  |  | 		if (result.dxcc.name != undefined) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			$('#country').val(convert_case(result.dxcc.name)); | 
					
						
							|  |  |  | 			$('#cqz').val(convert_case(result.dxcc.cqz)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			$('#callsign_info').removeClass("badge-secondary"); | 
					
						
							|  |  |  | 			$('#callsign_info').removeClass("badge-success"); | 
					
						
							|  |  |  | 			$('#callsign_info').removeClass("badge-danger"); | 
					
						
							|  |  |  | 			$('#callsign_info').attr('title', ''); | 
					
						
							|  |  |  | 			$('#callsign_info').text(convert_case(result.dxcc.name)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			changebadge(result.dxcc.name); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// Set Map to Lat/Long it locator is not empty
 | 
					
						
							|  |  |  | 			if($('#locator').val() == "") { | 
					
						
							|  |  |  | 				var redIcon = L.icon({ | 
					
						
							|  |  |  | 					iconUrl: icon_dot_url, | 
					
						
							|  |  |  | 					iconSize:     [18, 18], // size of the icon
 | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				markers.clearLayers(); | 
					
						
							|  |  |  | 				var marker = L.marker([result.dxcc.lat, result.dxcc.long], {icon: redIcon}); | 
					
						
							|  |  |  | 				mymap.setZoom(8); | 
					
						
							|  |  |  | 				mymap.panTo([result.dxcc.lat, result.dxcc.long]); | 
					
						
							|  |  |  | 				markers.addLayer(marker).addTo(mymap); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //Spacebar moves to the name field when you're entering a callsign
 | 
					
						
							|  |  |  | //Similar to contesting ux, good for pileups.
 | 
					
						
							|  |  |  | $("#callsign").on("keypress", function(e) { | 
					
						
							|  |  |  | 	if (e.which == 32){ | 
					
						
							|  |  |  | 		$("#name").focus(); | 
					
						
							|  |  |  | 		return false; //Eliminate space char
 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // On Key up check and suggest callsigns
 | 
					
						
							|  |  |  | $("#callsign").keyup(function() { | 
					
						
							|  |  |  | 	if ($(this).val().length >= 3) { | 
					
						
							|  |  |  | 		$('.callsign-suggest').show(); | 
					
						
							|  |  |  | 		$.get('lookup/scp/' + $(this).val().toUpperCase(), function(result) { | 
					
						
							|  |  |  | 			$('.callsign-suggestions').text(result); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2022-12-01 22:08:30 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | //Reset QSO form Fields function
 | 
					
						
							|  |  |  | function resetDefaultQSOFields() { | 
					
						
							|  |  |  | 	$('#callsign_info').text(""); | 
					
						
							|  |  |  | 	$('#locator_info').text(""); | 
					
						
							|  |  |  | 	$('#country').val(""); | 
					
						
							| 
									
										
										
										
											2023-02-05 00:41:21 +08:00
										 |  |  | 	$('#continent').val(""); | 
					
						
							| 
									
										
										
										
											2022-12-01 22:08:30 +08:00
										 |  |  | 	$('#dxcc_id').val(""); | 
					
						
							|  |  |  | 	$('#cqz').val(""); | 
					
						
							|  |  |  | 	$('#name').val(""); | 
					
						
							|  |  |  | 	$('#qth').val(""); | 
					
						
							|  |  |  | 	$('#locator').val(""); | 
					
						
							|  |  |  | 	$('#iota_ref').val(""); | 
					
						
							|  |  |  | 	$('#sota_ref').val(""); | 
					
						
							|  |  |  | 	$("#locator").removeClass("workedGrid"); | 
					
						
							|  |  |  | 	$("#locator").removeClass("newGrid"); | 
					
						
							|  |  |  | 	$("#callsign").removeClass("workedGrid"); | 
					
						
							|  |  |  | 	$("#callsign").removeClass("newGrid"); | 
					
						
							|  |  |  | 	$('#callsign_info').removeClass("badge-secondary"); | 
					
						
							|  |  |  | 	$('#callsign_info').removeClass("badge-success"); | 
					
						
							|  |  |  | 	$('#callsign_info').removeClass("badge-danger"); | 
					
						
							|  |  |  | 	$('#input_usa_state').val(""); | 
					
						
							| 
									
										
										
										
											2022-12-01 22:43:24 +08:00
										 |  |  | 	$('#callsign-image').attr('style', 'display: none;'); | 
					
						
							|  |  |  | 	$('#callsign-image-content').text(""); | 
					
						
							| 
									
										
										
										
											2023-01-26 16:10:56 +08:00
										 |  |  | 	$('.dxccsummary').remove(); | 
					
						
							| 
									
										
										
										
											2022-12-01 22:43:24 +08:00
										 |  |  | } |