| 
									
										
										
										
											2020-12-08 04:26:16 +08:00
										 |  |  | // Callsign always has focus on load
 | 
					
						
							|  |  |  | $("#callsign").focus(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | $(document).ready(function () { | 
					
						
							|  |  |  | 	restoreContestSession(); | 
					
						
							|  |  |  | 	setRst($("#mode").val()); | 
					
						
							| 
									
										
										
										
											2020-12-27 16:37:48 +08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-29 02:55:51 +08:00
										 |  |  | // This erases the contest logging session which is stored in localStorage
 | 
					
						
							|  |  |  | function reset_contest_session() { | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 	$('#name').val(""); | 
					
						
							|  |  |  | 	$('.callsign-suggestions').text(""); | 
					
						
							|  |  |  | 	$('#callsign').val(""); | 
					
						
							|  |  |  | 	$('#comment').val(""); | 
					
						
							| 
									
										
										
										
											2021-08-13 01:37:16 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	$("#exch_serial_s").val("1"); | 
					
						
							|  |  |  | 	$("#exch_serial_r").val(""); | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 	$('#exch_sent').val(""); | 
					
						
							| 
									
										
										
										
											2022-11-09 06:57:39 +08:00
										 |  |  | 	$('#exch_rcvd').val(""); | 
					
						
							| 
									
										
										
										
											2021-08-13 01:37:16 +08:00
										 |  |  | 	$("#exch_gridsquare_r").val(""); | 
					
						
							|  |  |  | 	$("#exch_gridsquare_s").val(""); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 	$("#callsign").focus(); | 
					
						
							|  |  |  | 	setRst($("#mode").val()); | 
					
						
							| 
									
										
										
										
											2021-08-13 01:37:16 +08:00
										 |  |  | 	$("#exchangetype").val("None"); | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 	setExchangetype("None"); | 
					
						
							|  |  |  | 	$("#contestname").val("Other").change(); | 
					
						
							|  |  |  | 	$(".contest_qso_table_contents").empty(); | 
					
						
							| 
									
										
										
										
											2021-10-16 22:03:54 +08:00
										 |  |  | 	$('#copyexchangetodok').prop('checked', false); | 
					
						
							| 
									
										
										
										
											2020-12-30 00:29:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 	localStorage.removeItem("contestid"); | 
					
						
							|  |  |  | 	localStorage.removeItem("exchangetype"); | 
					
						
							|  |  |  | 	localStorage.removeItem("qso"); | 
					
						
							| 
									
										
										
										
											2021-08-13 01:37:16 +08:00
										 |  |  | 	localStorage.removeItem("exchangereceived"); | 
					
						
							|  |  |  | 	localStorage.removeItem("exchangesent"); | 
					
						
							|  |  |  | 	localStorage.removeItem("serialreceived"); | 
					
						
							|  |  |  | 	localStorage.removeItem("serialsent"); | 
					
						
							|  |  |  | 	localStorage.removeItem("gridsquarereceived"); | 
					
						
							|  |  |  | 	localStorage.removeItem("gridsquaresent"); | 
					
						
							| 
									
										
										
										
											2021-10-16 22:03:54 +08:00
										 |  |  | 	localStorage.removeItem("copytodok"); | 
					
						
							| 
									
										
										
										
											2020-12-27 16:37:48 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Storing the contestid in contest session
 | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | $('#contestname').change(function () { | 
					
						
							|  |  |  | 	localStorage.setItem("contestid", $("#contestname").val()); | 
					
						
							| 
									
										
										
										
											2020-12-27 16:37:48 +08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Storing the exchange type in contest session
 | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | $('#exchangetype').change(function () { | 
					
						
							|  |  |  | 	localStorage.setItem("exchangetype", $('#exchangetype').val()); | 
					
						
							| 
									
										
										
										
											2020-12-27 16:37:48 +08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-08 04:26:16 +08:00
										 |  |  | // realtime clock
 | 
					
						
							| 
									
										
										
										
											2022-03-27 23:33:05 +08:00
										 |  |  | if ( ! manual ) { | 
					
						
							|  |  |  | 	$(function ($) { | 
					
						
							|  |  |  | 		var options = { | 
					
						
							|  |  |  | 			utc: true, | 
					
						
							|  |  |  | 			format: '%H:%M:%S' | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		$('.input_time').jclock(options); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2020-12-08 04:26:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-27 23:33:05 +08:00
										 |  |  | 	$(function ($) { | 
					
						
							|  |  |  | 		var options = { | 
					
						
							|  |  |  | 			utc: true, | 
					
						
							|  |  |  | 			format: '%d-%m-%Y' | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		$('.input_date').jclock(options); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-12-08 04:26:16 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // We don't want spaces to be written in callsign
 | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | $(function () { | 
					
						
							|  |  |  | 	$('#callsign').on('keypress', function (e) { | 
					
						
							|  |  |  | 		if (e.which == 32) { | 
					
						
							|  |  |  | 			return false; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2020-12-08 04:26:16 +08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // We don't want spaces to be written in exchange
 | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | $(function () { | 
					
						
							| 
									
										
										
										
											2022-11-09 06:57:39 +08:00
										 |  |  | 	$('#exch_rcvd').on('keypress', function (e) { | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 		if (e.which == 32) { | 
					
						
							|  |  |  | 			return false; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2020-12-08 04:26:16 +08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-13 01:37:16 +08:00
										 |  |  | // Here we capture keystrokes to execute functions
 | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | document.onkeyup = function (e) { | 
					
						
							|  |  |  | 	// ALT-W wipe
 | 
					
						
							|  |  |  | 	if (e.altKey && e.which == 87) { | 
					
						
							|  |  |  | 		reset_log_fields(); | 
					
						
							|  |  |  | 		// CTRL-Enter logs QSO
 | 
					
						
							|  |  |  | 	} else if ((e.keyCode == 10 || e.keyCode == 13) && (e.ctrlKey || e.metaKey)) { | 
					
						
							|  |  |  | 		logQso(); | 
					
						
							|  |  |  | 		// Enter in sent exchange logs QSO
 | 
					
						
							| 
									
										
										
										
											2022-11-09 06:57:39 +08:00
										 |  |  | 	} else if ((e.which == 13) && ($(document.activeElement).attr("id") == "exch_rcvd")) { | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 		logQso(); | 
					
						
							|  |  |  | 	} else if (e.which == 27) { | 
					
						
							|  |  |  | 		reset_log_fields(); | 
					
						
							|  |  |  | 		// Space to jump to either callsign or the various exchanges
 | 
					
						
							|  |  |  | 	} else if (e.which == 32) { | 
					
						
							| 
									
										
										
										
											2021-08-13 18:47:17 +08:00
										 |  |  | 		var exchangetype = $("#exchangetype").val(); | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 		if (exchangetype == 'Exchange') { | 
					
						
							| 
									
										
										
										
											2021-08-13 18:47:17 +08:00
										 |  |  | 			if ($(document.activeElement).attr("id") == "callsign") { | 
					
						
							| 
									
										
										
										
											2022-11-09 06:57:39 +08:00
										 |  |  | 				$("#exch_rcvd").focus(); | 
					
						
							| 
									
										
										
										
											2021-08-13 18:47:17 +08:00
										 |  |  | 				return false; | 
					
						
							| 
									
										
										
										
											2022-11-09 06:57:39 +08:00
										 |  |  | 			} else if ($(document.activeElement).attr("id") == "exch_rcvd") { | 
					
						
							| 
									
										
										
										
											2021-08-13 18:47:17 +08:00
										 |  |  | 				$("#callsign").focus(); | 
					
						
							|  |  |  | 				return false; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else if (exchangetype == 'Serial') { | 
					
						
							|  |  |  | 			if ($(document.activeElement).attr("id") == "callsign") { | 
					
						
							|  |  |  | 				$("#exch_serial_r").focus(); | 
					
						
							|  |  |  | 				return false; | 
					
						
							|  |  |  | 			} else if ($(document.activeElement).attr("id") == "exch_serial_r") { | 
					
						
							|  |  |  | 				$("#callsign").focus(); | 
					
						
							|  |  |  | 				return false; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else if (exchangetype == 'Serialexchange') { | 
					
						
							|  |  |  | 			if ($(document.activeElement).attr("id") == "callsign") { | 
					
						
							|  |  |  | 				$("#exch_serial_r").focus(); | 
					
						
							|  |  |  | 				return false; | 
					
						
							|  |  |  | 			} else if ($(document.activeElement).attr("id") == "exch_serial_r") { | 
					
						
							| 
									
										
										
										
											2022-11-09 06:57:39 +08:00
										 |  |  | 				$("#exch_rcvd").focus(); | 
					
						
							| 
									
										
										
										
											2021-08-13 18:47:17 +08:00
										 |  |  | 				return false; | 
					
						
							| 
									
										
										
										
											2022-11-09 06:57:39 +08:00
										 |  |  | 			} else if ($(document.activeElement).attr("id") == "exch_rcvd") { | 
					
						
							| 
									
										
										
										
											2021-08-13 18:47:17 +08:00
										 |  |  | 				$("#callsign").focus(); | 
					
						
							|  |  |  | 				return false; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else if (exchangetype == 'Serialgridsquare') { | 
					
						
							|  |  |  | 			if ($(document.activeElement).attr("id") == "callsign") { | 
					
						
							|  |  |  | 				$("#exch_serial_r").focus(); | 
					
						
							|  |  |  | 				return false; | 
					
						
							|  |  |  | 			} else if ($(document.activeElement).attr("id") == "exch_serial_r") { | 
					
						
							|  |  |  | 				$("#exch_gridsquare_r").focus(); | 
					
						
							|  |  |  | 				return false; | 
					
						
							|  |  |  | 			} else if ($(document.activeElement).attr("id") == "exch_gridsquare_r") { | 
					
						
							|  |  |  | 				$("#callsign").focus(); | 
					
						
							|  |  |  | 				return false; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else if (exchangetype == 'Gridsquare') { | 
					
						
							|  |  |  | 			if ($(document.activeElement).attr("id") == "callsign") { | 
					
						
							|  |  |  | 				$("#exch_gridsquare_r").focus(); | 
					
						
							|  |  |  | 				return false; | 
					
						
							|  |  |  | 			} else if ($(document.activeElement).attr("id") == "exch_gridsquare_r") { | 
					
						
							|  |  |  | 				$("#callsign").focus(); | 
					
						
							|  |  |  | 				return false; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-12-08 04:26:16 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-25 18:32:39 +08:00
										 |  |  | /* time input shortcut */ | 
					
						
							|  |  |  | $('#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); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* date input shortcut */ | 
					
						
							|  |  |  | $('#start_date').change(function() { | 
					
						
							|  |  |  | 	 raw_date = $(this).val(); | 
					
						
							|  |  |  | 	if(raw_date.match(/^[12]\d{3}[01]\d[0123]\d$/)) { | 
					
						
							|  |  |  | 		raw_date = raw_date.substring(0,4)+"-"+raw_date.substring(4,6)+"-"+raw_date.substring(6,8); | 
					
						
							|  |  |  | 		$('#start_date').val(raw_date); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-08 04:26:16 +08:00
										 |  |  | // On Key up check and suggest callsigns
 | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | $("#callsign").keyup(function () { | 
					
						
							|  |  |  | 	var call = $(this).val(); | 
					
						
							|  |  |  | 	if (call.length >= 3) { | 
					
						
							|  |  |  | 		$.get('lookup/scp/' + call.toUpperCase(), function (result) { | 
					
						
							|  |  |  | 			$('.callsign-suggestions').text(result); | 
					
						
							|  |  |  | 			highlight(call.toUpperCase()); | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2021-10-24 22:48:23 +08:00
										 |  |  | 		checkIfWorkedBefore(); | 
					
						
							| 
									
										
										
										
											2022-10-30 15:02:32 +08:00
										 |  |  | 		var qTable = $('.qsotable').DataTable(); | 
					
						
							|  |  |  | 		qTable.search(call).draw(); | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else if (call.length <= 2) { | 
					
						
							|  |  |  | 		$('.callsign-suggestions').text(""); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-12-08 04:26:16 +08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-24 22:48:23 +08:00
										 |  |  | function checkIfWorkedBefore() { | 
					
						
							|  |  |  | 	$('#callsign_info').text(""); | 
					
						
							|  |  |  | 	$.ajax({ | 
					
						
							|  |  |  | 		url: base_url + 'index.php/contesting/checkIfWorkedBefore', | 
					
						
							|  |  |  | 		type: 'post', | 
					
						
							|  |  |  | 		data: { | 
					
						
							|  |  |  | 			'call': $("#callsign").val(), | 
					
						
							|  |  |  | 			'mode': $("#mode").val(), | 
					
						
							|  |  |  | 			'band': $("#band").val(), | 
					
						
							|  |  |  | 			'contest': $("#contestname").val(), | 
					
						
							|  |  |  | 			'qso': localStorage.getItem("qso") | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		success: function (result) { | 
					
						
							|  |  |  | 			if (result.message == 'Worked before') { | 
					
						
							|  |  |  | 				$('#callsign_info').text("Worked before!"); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-08 04:26:16 +08:00
										 |  |  | function reset_log_fields() { | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 	$('#name').val(""); | 
					
						
							|  |  |  | 	$('.callsign-suggestions').text(""); | 
					
						
							|  |  |  | 	$('#callsign').val(""); | 
					
						
							|  |  |  | 	$('#comment').val(""); | 
					
						
							| 
									
										
										
										
											2022-11-09 06:57:39 +08:00
										 |  |  | 	$('#exch_rcvd').val(""); | 
					
						
							| 
									
										
										
										
											2021-08-13 01:37:16 +08:00
										 |  |  | 	$('#exch_serial_r').val(""); | 
					
						
							|  |  |  | 	$('#exch_gridsquare_r').val(""); | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 	$("#callsign").focus(); | 
					
						
							|  |  |  | 	setRst($("#mode").val()); | 
					
						
							| 
									
										
										
										
											2021-10-24 22:48:23 +08:00
										 |  |  | 	$('#callsign_info').text(""); | 
					
						
							| 
									
										
										
										
											2022-10-30 15:02:32 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	var qTable = $('.qsotable').DataTable(); | 
					
						
							|  |  |  | 	qTable.search('').draw(); | 
					
						
							| 
									
										
										
										
											2020-12-08 04:26:16 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | RegExp.escape = function (text) { | 
					
						
							|  |  |  | 	return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); | 
					
						
							| 
									
										
										
										
											2020-12-08 04:26:16 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function highlight(term, base) { | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 	if (!term) return; | 
					
						
							|  |  |  | 	base = base || document.body; | 
					
						
							|  |  |  | 	var re = new RegExp("(" + RegExp.escape(term) + ")", "gi"); | 
					
						
							|  |  |  | 	var replacement = "<span class=\"text-primary\">" + term + "</span>"; | 
					
						
							|  |  |  | 	$(".callsign-suggestions", base).contents().each(function (i, el) { | 
					
						
							|  |  |  | 		if (el.nodeType === 3) { | 
					
						
							|  |  |  | 			var data = el.data; | 
					
						
							|  |  |  | 			if (data = data.replace(re, replacement)) { | 
					
						
							|  |  |  | 				var wrapper = $("<span>").html(data); | 
					
						
							|  |  |  | 				$(el).before(wrapper.contents()).remove(); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2020-12-08 04:26:16 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Only set the frequency when not set by userdata/PHP.
 | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | if ($('#frequency').val() == "") { | 
					
						
							|  |  |  | 	$.get('qso/band_to_freq/' + $('#band').val() + '/' + $('.mode').val(), function (result) { | 
					
						
							|  |  |  | 		$('#frequency').val(result); | 
					
						
							|  |  |  | 		$('#frequency_rx').val(""); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2020-12-08 04:26:16 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* on mode change */ | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | $('#mode').change(function () { | 
					
						
							|  |  |  | 	$.get('qso/band_to_freq/' + $('#band').val() + '/' + $('.mode').val(), function (result) { | 
					
						
							|  |  |  | 		$('#frequency').val(result); | 
					
						
							|  |  |  | 		$('#frequency_rx').val(""); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2021-08-13 01:37:16 +08:00
										 |  |  | 	setRst($("#mode").val()); | 
					
						
							| 
									
										
										
										
											2021-10-24 22:48:23 +08:00
										 |  |  | 	checkIfWorkedBefore(); | 
					
						
							| 
									
										
										
										
											2020-12-08 04:26:16 +08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Calculate Frequency */ | 
					
						
							|  |  |  | /* on band change */ | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | $('#band').change(function () { | 
					
						
							|  |  |  | 	$.get('qso/band_to_freq/' + $(this).val() + '/' + $('.mode').val(), function (result) { | 
					
						
							|  |  |  | 		$('#frequency').val(result); | 
					
						
							|  |  |  | 		$('#frequency_rx').val(""); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2021-10-24 22:48:23 +08:00
										 |  |  | 	checkIfWorkedBefore(); | 
					
						
							| 
									
										
										
										
											2021-03-14 19:44:42 +08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | $('#exchangetype').change(function () { | 
					
						
							| 
									
										
										
										
											2021-08-11 04:32:15 +08:00
										 |  |  | 	var exchangetype = $("#exchangetype").val(); | 
					
						
							| 
									
										
										
										
											2021-08-12 17:52:36 +08:00
										 |  |  | 	setExchangetype(exchangetype); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function setExchangetype(exchangetype) { | 
					
						
							| 
									
										
										
										
											2021-10-12 19:10:54 +08:00
										 |  |  | 	// Perhaps a better approach is to hide everything, then just enable the things you need
 | 
					
						
							|  |  |  | 	$(".exchanger").hide(); | 
					
						
							|  |  |  | 	$(".exchanges").hide(); | 
					
						
							|  |  |  | 	$(".serials").hide(); | 
					
						
							|  |  |  | 	$(".serialr").hide(); | 
					
						
							|  |  |  | 	$(".gridsquarer").hide(); | 
					
						
							|  |  |  | 	$(".gridsquares").hide(); | 
					
						
							|  |  |  | 	$("#exch_serial_s").val(""); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var serialsent = localStorage.getItem("serialsent"); | 
					
						
							|  |  |  | 	if (serialsent == null) { | 
					
						
							|  |  |  | 		serialsent = 1; | 
					
						
							| 
									
										
										
										
											2021-08-07 16:13:38 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-10-12 19:10:54 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (exchangetype == 'Exchange') { | 
					
						
							| 
									
										
										
										
											2021-08-12 17:52:36 +08:00
										 |  |  | 		$(".exchanger").show(); | 
					
						
							|  |  |  | 		$(".exchanges").show(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (exchangetype == 'Serial') { | 
					
						
							| 
									
										
										
										
											2021-10-12 19:10:54 +08:00
										 |  |  | 		$("#exch_serial_s").val(serialsent); | 
					
						
							|  |  |  | 		$(".serials").show(); | 
					
						
							|  |  |  | 		$(".serialr").show(); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-08-12 17:52:36 +08:00
										 |  |  | 	else if (exchangetype == 'Serialexchange') { | 
					
						
							| 
									
										
										
										
											2021-10-12 19:10:54 +08:00
										 |  |  | 		$("#exch_serial_s").val(serialsent); | 
					
						
							| 
									
										
										
										
											2021-08-11 04:32:15 +08:00
										 |  |  | 		$(".exchanger").show(); | 
					
						
							|  |  |  | 		$(".exchanges").show(); | 
					
						
							|  |  |  | 		$(".serials").show(); | 
					
						
							|  |  |  | 		$(".serialr").show(); | 
					
						
							| 
									
										
										
										
											2021-08-07 16:13:38 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-08-12 17:52:36 +08:00
										 |  |  | 	else if (exchangetype == 'Serialgridsquare') { | 
					
						
							| 
									
										
										
										
											2021-10-12 19:10:54 +08:00
										 |  |  | 		$("#exch_serial_s").val(serialsent); | 
					
						
							| 
									
										
										
										
											2021-08-11 04:32:15 +08:00
										 |  |  | 		$(".serials").show(); | 
					
						
							|  |  |  | 		$(".serialr").show(); | 
					
						
							|  |  |  | 		$(".gridsquarer").show(); | 
					
						
							|  |  |  | 		$(".gridsquares").show(); | 
					
						
							| 
									
										
										
										
											2021-08-07 16:13:38 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-08-12 17:52:36 +08:00
										 |  |  | 	else if (exchangetype == 'Gridsquare') { | 
					
						
							| 
									
										
										
										
											2021-08-11 04:32:15 +08:00
										 |  |  | 		$(".gridsquarer").show(); | 
					
						
							|  |  |  | 		$(".gridsquares").show(); | 
					
						
							| 
									
										
										
										
											2021-08-07 16:13:38 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-08-12 17:52:36 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2021-08-07 16:13:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-11 14:54:24 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	Function: logQso | 
					
						
							|  |  |  | 	Job: this handles the logging done in the contesting module. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | function logQso() { | 
					
						
							|  |  |  | 	if ($("#callsign").val().length > 0) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$('.callsign-suggestions').text(""); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		var table = $('.qsotable').DataTable(); | 
					
						
							| 
									
										
										
										
											2021-08-13 18:47:17 +08:00
										 |  |  | 		var gridsquare = $("#exch_gridsquare_r").val(); | 
					
						
							|  |  |  | 		var vucc = ''; | 
					
						
							| 
									
										
										
										
											2021-08-11 14:54:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-13 18:47:17 +08:00
										 |  |  | 		if (gridsquare.indexOf(',') != -1) { | 
					
						
							|  |  |  | 			vucc = gridsquare; | 
					
						
							|  |  |  | 			gridsquare = ''; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		var data = [[ | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 			$("#start_date").val() + ' ' + $("#start_time").val(), | 
					
						
							| 
									
										
										
										
											2021-08-11 14:54:24 +08:00
										 |  |  | 			$("#callsign").val().toUpperCase(), | 
					
						
							|  |  |  | 			$("#band").val(), | 
					
						
							|  |  |  | 			$("#mode").val(), | 
					
						
							|  |  |  | 			$("#rst_sent").val(), | 
					
						
							| 
									
										
										
										
											2022-11-09 06:57:39 +08:00
										 |  |  | 			$("#rst_rcvd").val(), | 
					
						
							| 
									
										
										
										
											2021-08-11 14:54:24 +08:00
										 |  |  | 			$("#exch_sent").val(), | 
					
						
							| 
									
										
										
										
											2022-11-09 06:57:39 +08:00
										 |  |  | 			$("#exch_rcvd").val(), | 
					
						
							| 
									
										
										
										
											2021-08-13 18:47:17 +08:00
										 |  |  | 			$("#exch_serial_s").val(), | 
					
						
							|  |  |  | 			$("#exch_serial_r").val(), | 
					
						
							|  |  |  | 			gridsquare, | 
					
						
							|  |  |  | 			vucc, | 
					
						
							|  |  |  | 		]]; | 
					
						
							| 
									
										
										
										
											2021-08-11 14:54:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		table.rows.add(data).draw(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		var formdata = new FormData(document.getElementById("qso_input")); | 
					
						
							|  |  |  | 		$.ajax({ | 
					
						
							|  |  |  | 			url: base_url + 'index.php/qso/saveqso', | 
					
						
							|  |  |  | 			type: 'post', | 
					
						
							|  |  |  | 			data: formdata, | 
					
						
							|  |  |  | 			processData: false, | 
					
						
							|  |  |  | 			contentType: false, | 
					
						
							|  |  |  | 			enctype: 'multipart/form-data', | 
					
						
							|  |  |  | 			success: function (html) { | 
					
						
							|  |  |  | 				if (localStorage.getItem("qso") == null) { | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 					localStorage.setItem("qso", $("#start_date").val() + ' ' + $("#start_time").val() + ',' + $("#callsign").val().toUpperCase() + ',' + $("#contestname").val()); | 
					
						
							| 
									
										
										
										
											2021-08-11 14:54:24 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$('#name').val(""); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$('#callsign').val(""); | 
					
						
							|  |  |  | 				$('#comment').val(""); | 
					
						
							| 
									
										
										
										
											2022-11-09 06:57:39 +08:00
										 |  |  | 				$('#exch_rcvd').val(""); | 
					
						
							| 
									
										
										
										
											2021-08-13 18:47:17 +08:00
										 |  |  | 				$('#exch_gridsquare_r').val(""); | 
					
						
							|  |  |  | 				$('#exch_serial_r').val(""); | 
					
						
							| 
									
										
										
										
											2021-08-12 17:52:36 +08:00
										 |  |  | 				var exchangetype = $("#exchangetype").val(); | 
					
						
							|  |  |  | 				if (exchangetype == "Serial" || exchangetype == 'Serialexchange' || exchangetype == 'Serialgridsquare') { | 
					
						
							| 
									
										
										
										
											2021-08-13 01:37:16 +08:00
										 |  |  | 					$("#exch_serial_s").val(+$("#exch_serial_s").val() + 1); | 
					
						
							| 
									
										
										
										
											2021-08-11 14:54:24 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 				$("#callsign").focus(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// Store contest session
 | 
					
						
							|  |  |  | 				localStorage.setItem("contestid", $("#contestname").val()); | 
					
						
							| 
									
										
										
										
											2021-08-12 17:52:36 +08:00
										 |  |  | 				localStorage.setItem("exchangetype", $("#exchangetype").val()); | 
					
						
							| 
									
										
										
										
											2022-11-09 06:57:39 +08:00
										 |  |  | 				localStorage.setItem("exchangereceived", $("#exch_rcvd").val()); | 
					
						
							| 
									
										
										
										
											2021-08-13 01:37:16 +08:00
										 |  |  | 				localStorage.setItem("exchangesent", $("#exch_sent").val()); | 
					
						
							|  |  |  | 				localStorage.setItem("serialreceived", $("#exch_serial_r").val()); | 
					
						
							|  |  |  | 				localStorage.setItem("serialsent", $("#exch_serial_s").val()); | 
					
						
							|  |  |  | 				localStorage.setItem("gridsquarereceived", $("#exch_gridsquare_r").val()); | 
					
						
							|  |  |  | 				localStorage.setItem("gridsquaresent", $("#exch_gridsquare_s").val()); | 
					
						
							| 
									
										
										
										
											2021-10-16 22:03:54 +08:00
										 |  |  | 				localStorage.setItem("copytodok", $('#copyexchangetodok').is(":checked")); | 
					
						
							| 
									
										
										
										
											2022-10-30 15:02:32 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				var qTable = $('.qsotable').DataTable(); | 
					
						
							|  |  |  | 				qTable.search('').draw(); | 
					
						
							| 
									
										
										
										
											2021-08-11 14:54:24 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // We are restoring the settings in the contest logging form here
 | 
					
						
							|  |  |  | function restoreContestSession() { | 
					
						
							| 
									
										
										
										
											2021-10-16 22:03:54 +08:00
										 |  |  | 	var dokcopy = localStorage.getItem("copytodok"); | 
					
						
							|  |  |  | 	if (dokcopy != null) { | 
					
						
							|  |  |  | 		$('#copyexchangetodok').prop('checked', true); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-08-11 14:54:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-16 22:03:54 +08:00
										 |  |  | 	var contestname = localStorage.getItem("contestid"); | 
					
						
							| 
									
										
										
										
											2021-08-11 14:54:24 +08:00
										 |  |  | 	if (contestname != null) { | 
					
						
							|  |  |  | 		$("#contestname").val(contestname); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var exchangetype = localStorage.getItem("exchangetype"); | 
					
						
							| 
									
										
										
										
											2021-08-13 01:37:16 +08:00
										 |  |  | 	if (exchangetype != null) { | 
					
						
							|  |  |  | 		$("#exchangetype").val(exchangetype); | 
					
						
							|  |  |  | 		setExchangetype(exchangetype); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var exchangereceived = localStorage.getItem("exchangereceived"); | 
					
						
							|  |  |  | 	if (exchangereceived != null) { | 
					
						
							| 
									
										
										
										
											2022-11-09 06:57:39 +08:00
										 |  |  | 		$("#exch_rcvd").val(exchangereceived); | 
					
						
							| 
									
										
										
										
											2021-08-13 01:37:16 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var exchangesent = localStorage.getItem("exchangesent"); | 
					
						
							|  |  |  | 	if (exchangesent != null) { | 
					
						
							|  |  |  | 		$("#exch_sent").val(exchangesent); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var serialreceived = localStorage.getItem("serialreceived"); | 
					
						
							|  |  |  | 	if (serialreceived != null) { | 
					
						
							|  |  |  | 		$("#exch_serial_r").val(serialreceived); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var serialsent = localStorage.getItem("serialsent"); | 
					
						
							|  |  |  | 	if (serialsent != null) { | 
					
						
							|  |  |  | 		$("#exch_serial_s").val(serialsent); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var gridsquarereceived = localStorage.getItem("gridsquarereceived"); | 
					
						
							|  |  |  | 	if (gridsquarereceived != null) { | 
					
						
							|  |  |  | 		$("#exch_gridsquare_r").val(gridsquarereceived); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var gridsquaresent = localStorage.getItem("gridsquaresent"); | 
					
						
							|  |  |  | 	if (gridsquaresent != null) { | 
					
						
							|  |  |  | 		$("#exch_gridsquare_s").val(gridsquaresent); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-08-11 14:54:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (localStorage.getItem("qso") != null) { | 
					
						
							|  |  |  | 		var qsodata = localStorage.getItem("qso"); | 
					
						
							|  |  |  | 		$.ajax({ | 
					
						
							|  |  |  | 			url: base_url + 'index.php/contesting/getSessionQsos', | 
					
						
							|  |  |  | 			type: 'post', | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 			data: { 'qso': qsodata, }, | 
					
						
							| 
									
										
										
										
											2021-08-11 14:54:24 +08:00
										 |  |  | 			success: function (html) { | 
					
						
							|  |  |  | 				var mode = ''; | 
					
						
							| 
									
										
										
										
											2021-08-13 18:47:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 				$.each(html, function () { | 
					
						
							| 
									
										
										
										
											2021-08-11 14:54:24 +08:00
										 |  |  | 					if (this.col_submode == null || this.col_submode == '') { | 
					
						
							|  |  |  | 						mode = this.col_mode; | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 						mode = this.col_submode; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					$(".qsotable tbody").prepend('<tr>' + | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 						'<td>' + this.col_time_on + '</td>' + | 
					
						
							|  |  |  | 						'<td>' + this.col_call + '</td>' + | 
					
						
							|  |  |  | 						'<td>' + this.col_band + '</td>' + | 
					
						
							|  |  |  | 						'<td>' + mode + '</td>' + | 
					
						
							|  |  |  | 						'<td>' + this.col_rst_sent + '</td>' + | 
					
						
							|  |  |  | 						'<td>' + this.col_rst_rcvd + '</td>' + | 
					
						
							|  |  |  | 						'<td>' + this.col_stx_string + '</td>' + | 
					
						
							|  |  |  | 						'<td>' + this.col_srx_string + '</td>' + | 
					
						
							|  |  |  | 						'<td>' + this.col_stx + '</td>' + | 
					
						
							|  |  |  | 						'<td>' + this.col_srx + '</td>' + | 
					
						
							|  |  |  | 						'<td>' + this.col_gridsquare + '</td>' + | 
					
						
							|  |  |  | 						'<td>' + this.col_vucc_grids + '</td>' + | 
					
						
							| 
									
										
										
										
											2021-08-11 14:54:24 +08:00
										 |  |  | 						'</tr>'); | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 				if (!$.fn.DataTable.isDataTable('.qsotable')) { | 
					
						
							|  |  |  | 					$('.qsotable').DataTable({ | 
					
						
							|  |  |  | 						"pageLength": 25, | 
					
						
							|  |  |  | 						responsive: false, | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 						"scrollY": "400px", | 
					
						
							| 
									
										
										
										
											2021-08-11 14:54:24 +08:00
										 |  |  | 						"scrollCollapse": true, | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 						"paging": false, | 
					
						
							| 
									
										
										
										
											2021-08-11 14:54:24 +08:00
										 |  |  | 						"scrollX": true, | 
					
						
							| 
									
										
										
										
											2021-10-12 00:54:48 +08:00
										 |  |  | 						"order": [[0, "desc"]] | 
					
						
							| 
									
										
										
										
											2021-08-11 14:54:24 +08:00
										 |  |  | 					}); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |