Uses Callbytxt to lookup Gridsquare & name if not in logbook

This commit is contained in:
Peter Goodhall
2011-11-08 17:42:59 +00:00
parent 1cfef832b2
commit 3993326b08
3 changed files with 43 additions and 1 deletions

View File

@@ -137,5 +137,15 @@ class Dashboard extends CI_Controller {
echo "}";
}
function test() {
$this->load->library('callbytxt');
$callbook = $this->callbytxt->callsign('m3ph');
print_r($callbook);
}
}

View File

@@ -0,0 +1,32 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Callbytxt {
/*
Communicates with the Callbytxt API functions
*/
public function callsign($callsign)
{
ini_set ('display_errors', 1);
$jsonurl = "http://callbytxt.org/db/".$callsign.".json";
$json = @file_get_contents($jsonurl,0,null,null);
$json_output = json_decode($json);
if(isset($json_output)) {
$data['callsign'] = $json_output->calls->callsign;
$data['name'] = ucfirst(strtolower(($json_output->calls->first_name)));
$data['gridsquare'] = ucfirst($json_output->calls->gridsquare);
$data['city'] = ucfirst(strtolower(($json_output->calls->city)));
$data['lat'] = ucfirst($json_output->calls->lat);
$data['long'] = ucfirst($json_output->calls->long);
return $data;
}
}
}
/* End of file Callbytxt.php */

View File

@@ -330,7 +330,7 @@
});
/* On Callsign Change */
$("#callsign").keyup(function(){
$("#callsign").focusout(function(){
if ($(this).val()) {
/* Find Callsign Matches */
$('#partial_view').load("logbook/partial/" + $(this).val()).fadeIn("slow");