Merge pull request #2432 from phl0/ajaxToPost
这个提交包含在:
		
						当前提交
						e74a949b07
					
				
					共有  5 个文件被更改,包括 124 次插入 和 40 次删除
				
			
		|  | @ -863,7 +863,9 @@ class Logbook extends CI_Controller { | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	/* return station bearing */ | 	/* return station bearing */ | ||||||
| 	function searchbearing($locator, $station_id = null) { | 	function searchbearing() { | ||||||
|  | 			$locator = xss_clean($this->input->post('grid')); | ||||||
|  | 			$station_id = xss_clean($this->input->post('stationProfile')); | ||||||
| 			$this->load->library('Qra'); | 			$this->load->library('Qra'); | ||||||
| 
 | 
 | ||||||
| 			if($locator != null) { | 			if($locator != null) { | ||||||
|  | @ -900,7 +902,9 @@ class Logbook extends CI_Controller { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* return distance */ | 	/* return distance */ | ||||||
| 	function searchdistance($locator, $station_id = null) { | 	function searchdistance() { | ||||||
|  | 			$locator = xss_clean($this->input->post('grid')); | ||||||
|  | 			$station_id = xss_clean($this->input->post('stationProfile')); | ||||||
| 			$this->load->library('Qra'); | 			$this->load->library('Qra'); | ||||||
| 
 | 
 | ||||||
| 			if($locator != null) { | 			if($locator != null) { | ||||||
|  | @ -995,7 +999,8 @@ class Logbook extends CI_Controller { | ||||||
| 		return $latlng; | 		return $latlng; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	function qralatlngjson($qra) { | 	function qralatlngjson() { | ||||||
|  | 		$qra = xss_clean($this->input->post('qra')); | ||||||
| 		$this->load->library('Qra'); | 		$this->load->library('Qra'); | ||||||
| 		$latlng = $this->qra->qra2latlong($qra); | 		$latlng = $this->qra->qra2latlong($qra); | ||||||
| 		print json_encode($latlng); | 		print json_encode($latlng); | ||||||
|  |  | ||||||
|  | @ -26,9 +26,12 @@ class Qra { | ||||||
| 		$my = qra2latlong($tx); | 		$my = qra2latlong($tx); | ||||||
| 		$stn = qra2latlong($rx); | 		$stn = qra2latlong($rx); | ||||||
| 
 | 
 | ||||||
|  | 		if ($my !== false && $stn !== false ) { | ||||||
| 			$bearing = bearing($my[0], $my[1], $stn[0], $stn[1], $unit); | 			$bearing = bearing($my[0], $my[1], $stn[0], $stn[1], $unit); | ||||||
| 
 |  | ||||||
| 			return $bearing; | 			return $bearing; | ||||||
|  | 		} else { | ||||||
|  | 			return false; | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* | 	/* | ||||||
|  | @ -168,6 +171,11 @@ function qra2latlong($strQRA) { | ||||||
|        if (substr_count($strQRA, ',') == 3) { |        if (substr_count($strQRA, ',') == 3) { | ||||||
|           // Handle grid corners
 |           // Handle grid corners
 | ||||||
|           $grids = explode(',', $strQRA); |           $grids = explode(',', $strQRA); | ||||||
|  |           $gridlengths = array(strlen($grids[0]), strlen($grids[1]), strlen($grids[2]), strlen($grids[3])); | ||||||
|  |           $same = array_count_values($gridlengths); | ||||||
|  |           if (count($same) != 1) { | ||||||
|  |              return false; | ||||||
|  |           } | ||||||
|           $coords = array(0, 0); |           $coords = array(0, 0); | ||||||
|           for($i=0; $i<4; $i++) { |           for($i=0; $i<4; $i++) { | ||||||
|               $cornercoords[$i] = qra2latlong($grids[$i]); |               $cornercoords[$i] = qra2latlong($grids[$i]); | ||||||
|  | @ -178,6 +186,9 @@ function qra2latlong($strQRA) { | ||||||
|        } else if (substr_count($strQRA, ',') == 1) { |        } else if (substr_count($strQRA, ',') == 1) { | ||||||
|           // Handle grid lines
 |           // Handle grid lines
 | ||||||
|           $grids = explode(',', $strQRA); |           $grids = explode(',', $strQRA); | ||||||
|  |           if (strlen($grids[0]) != strlen($grids[1])) { | ||||||
|  |              return false; | ||||||
|  |           } | ||||||
|           $coords = array(0, 0); |           $coords = array(0, 0); | ||||||
|           for($i=0; $i<2; $i++) { |           for($i=0; $i<2; $i++) { | ||||||
|               $linecoords[$i] = qra2latlong($grids[$i]); |               $linecoords[$i] = qra2latlong($grids[$i]); | ||||||
|  |  | ||||||
|  | @ -981,18 +981,29 @@ $(document).on('keypress',function(e) { | ||||||
|   var markers = L.layerGroup(); |   var markers = L.layerGroup(); | ||||||
|   var pos = [51.505, -0.09]; |   var pos = [51.505, -0.09]; | ||||||
|   var mymap = L.map('qsomap').setView(pos, 12); |   var mymap = L.map('qsomap').setView(pos, 12); | ||||||
|   <?php |   $.ajax({ | ||||||
|   if ($active_station_info->station_gridsquare != "") { ?>
 |      url: base_url + 'index.php/logbook/qralatlngjson', | ||||||
|   $.getJSON('logbook/qralatlngjson/<?php echo $user_gridsquare; ?>', function(result) { |      type: 'post', | ||||||
|  |      data: { | ||||||
|  | <?php if ($active_station_info->station_gridsquare != "") { ?>
 | ||||||
|  |         qra: '<?php echo $user_gridsquare; ?>', | ||||||
|  | <?php } else if (null !== $this->config->item('locator')) { ?>
 | ||||||
|  |         qra: '<?php echo $this->config->item('locator'); ?>', | ||||||
|  | <?php } else { ?>
 | ||||||
|  |         // Fallback to London in case all else fails
 | ||||||
|  |         qra: 'IO91WM', | ||||||
|  | <?php } ?>
 | ||||||
|  |      }, | ||||||
|  |      success: function(data) { | ||||||
|  |         result = JSON.parse(data); | ||||||
|  |         if (typeof result[0] !== "undefined" && typeof result[1] !== "undefined") { | ||||||
|            mymap.panTo([result[0], result[1]]); |            mymap.panTo([result[0], result[1]]); | ||||||
|            pos = result; |            pos = result; | ||||||
|   }) |         } | ||||||
|   <?php } else if (null !== $this->config->item('locator')) { ?>
 |      }, | ||||||
|   $.getJSON('logbook/qralatlngjson/<?php echo $this->config->item('locator'); ?>', function(result) { |      error: function() { | ||||||
|      mymap.panTo([result[0], result[1]]); |      }, | ||||||
|      pos = result; |   }); | ||||||
|   }) |  | ||||||
|   <?php } ?>
 |  | ||||||
| 
 | 
 | ||||||
|   L.tileLayer('<?php echo $this->optionslib->get_option('option_map_tile_server');?>', { |   L.tileLayer('<?php echo $this->optionslib->get_option('option_map_tile_server');?>', { | ||||||
|     maxZoom: 18, |     maxZoom: 18, | ||||||
|  |  | ||||||
|  | @ -152,9 +152,33 @@ function qso_edit(id) { | ||||||
| 
 | 
 | ||||||
|                     $('#locator').change(function(){ |                     $('#locator').change(function(){ | ||||||
|                         if ($(this).val().length >= 4) { |                         if ($(this).val().length >= 4) { | ||||||
|                             $('#locator_info').load(base_url + "index.php/logbook/searchbearing/" + $(this).val() + "/" + $('#stationProfile').val()).fadeIn("slow"); |                             $.ajax({ | ||||||
|                             $.get(base_url + 'index.php/logbook/searchdistance/' + $(this).val() + "/" + $('#stationProfile').val(), function(result) { |                                url: base_url + 'index.php/logbook/searchbearing', | ||||||
|                                 document.getElementById("distance").value = result; |                                type: 'post', | ||||||
|  |                                data: { | ||||||
|  |                                   grid: $(this).val(), | ||||||
|  |                                   stationProfile: $('#stationProfile').val() | ||||||
|  |                                }, | ||||||
|  |                                success: function(data) { | ||||||
|  |                                   $('#locator_info').html(data).fadeIn("slow"); | ||||||
|  |                                }, | ||||||
|  |                                error: function() { | ||||||
|  |                                   $('#locator_info').text("Error loading bearing!").fadeIn("slow"); | ||||||
|  |                                }, | ||||||
|  |                             }); | ||||||
|  |                             $.ajax({ | ||||||
|  |                                url: base_url + 'index.php/logbook/searchdistance', | ||||||
|  |                                type: 'post', | ||||||
|  |                                data: { | ||||||
|  |                                   grid: $(this).val(), | ||||||
|  |                                   stationProfile: $('#stationProfile').val() | ||||||
|  |                                }, | ||||||
|  |                                success: function(data) { | ||||||
|  |                                   document.getElementById("distance").value = data; | ||||||
|  |                                }, | ||||||
|  |                                error: function() { | ||||||
|  |                                   document.getElementById("distance").value = null; | ||||||
|  |                                }, | ||||||
|                             }); |                             }); | ||||||
|                         } |                         } | ||||||
|                     }); |                     }); | ||||||
|  |  | ||||||
|  | @ -811,11 +811,17 @@ $("#locator").keyup(function(){ | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if(qra_input.length >= 4 && $(this).val().length > 0) { | 		if(qra_input.length >= 4 && $(this).val().length > 0) { | ||||||
| 			$.getJSON(base_url + 'index.php/logbook/qralatlngjson/' + $(this).val(), function(result) | 			$.ajax({ | ||||||
| 			{ | 				url: base_url + 'index.php/logbook/qralatlngjson', | ||||||
|  | 				type: 'post', | ||||||
|  | 				data: { | ||||||
|  | 					qra: $(this).val(), | ||||||
|  | 				}, | ||||||
|  | 				success: function(data) { | ||||||
| 					// Set Map to Lat/Long
 | 					// Set Map to Lat/Long
 | ||||||
|  | 					result = JSON.parse(data); | ||||||
| 					markers.clearLayers(); | 					markers.clearLayers(); | ||||||
| 				if (typeof result !== "undefined") { | 					if (typeof result[0] !== "undefined" && typeof result[1] !== "undefined") { | ||||||
| 						var redIcon = L.icon({ | 						var redIcon = L.icon({ | ||||||
| 							iconUrl: icon_dot_url, | 							iconUrl: icon_dot_url, | ||||||
| 							iconSize:     [18, 18], // size of the icon
 | 							iconSize:     [18, 18], // size of the icon
 | ||||||
|  | @ -825,13 +831,40 @@ $("#locator").keyup(function(){ | ||||||
| 						mymap.setZoom(8); | 						mymap.setZoom(8); | ||||||
| 						mymap.panTo([result[0], result[1]]); | 						mymap.panTo([result[0], result[1]]); | ||||||
| 						mymap.setView([result[0], result[1]], 8); | 						mymap.setView([result[0], result[1]], 8); | ||||||
| 				} |  | ||||||
| 					   markers.addLayer(marker).addTo(mymap); | 					   markers.addLayer(marker).addTo(mymap); | ||||||
| 			}) | 					} | ||||||
|  | 				}, | ||||||
|  | 				error: function() { | ||||||
|  | 				}, | ||||||
|  | 			}); | ||||||
| 
 | 
 | ||||||
| 			$('#locator_info').load(base_url +"index.php/logbook/searchbearing/" + $(this).val() + "/" + $('#stationProfile').val()).fadeIn("slow"); | 			$.ajax({ | ||||||
| 			$.get(base_url + 'index.php/logbook/searchdistance/' + $(this).val() + "/" + $('#stationProfile').val(), function(result) { | 				url: base_url + 'index.php/logbook/searchbearing', | ||||||
| 				document.getElementById("distance").value = result; | 				type: 'post', | ||||||
|  | 				data: { | ||||||
|  | 					grid: $(this).val(), | ||||||
|  | 					stationProfile: $('#stationProfile').val() | ||||||
|  | 				}, | ||||||
|  | 				success: function(data) { | ||||||
|  | 					$('#locator_info').html(data).fadeIn("slow"); | ||||||
|  | 				}, | ||||||
|  | 				error: function() { | ||||||
|  | 					$('#locator_info').text("Error loading bearing!").fadeIn("slow"); | ||||||
|  | 				}, | ||||||
|  | 			}); | ||||||
|  | 			$.ajax({ | ||||||
|  | 				url: base_url + 'index.php/logbook/searchdistance', | ||||||
|  | 				type: 'post', | ||||||
|  | 				data: { | ||||||
|  | 					grid: $(this).val(), | ||||||
|  | 					stationProfile: $('#stationProfile').val() | ||||||
|  | 				}, | ||||||
|  | 				success: function(data) { | ||||||
|  | 					document.getElementById("distance").value = data; | ||||||
|  | 				}, | ||||||
|  | 				error: function() { | ||||||
|  | 					document.getElementById("distance").value = null; | ||||||
|  | 				}, | ||||||
| 			}); | 			}); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
		正在加载…
	
		在新工单中引用