diff --git a/api.php b/api.php index 9991bf8..87e72a3 100644 --- a/api.php +++ b/api.php @@ -76,6 +76,10 @@ } echo lookup($call, 'json', $date); break; + case 'member_lookup': + $call = validate_get('hiscall'); + echo member_lookup($call); + break; case 'overview': echo stats($_SESSION['callsign']); break; diff --git a/functions.php b/functions.php index 0809aa4..b40fc20 100644 --- a/functions.php +++ b/functions.php @@ -181,7 +181,7 @@ function aca($c, $y) { echo mysqli_error($db); } $cnt = 1; - $ret .= "\n"; + $ret .= "
CountCWopsCallDateBand
\n"; while ($r = mysqli_fetch_row($q)) { $ret .= "\n"; } @@ -199,7 +199,7 @@ function cma($c) { echo mysqli_error($db); } $cnt = 1; - $ret .= "
CountCWopsCallDateBand (m)
".$cnt++."".$r[0]."".$r[1]."".$r[2]."".$r[3]."
\n"; + $ret .= "
CountCWopsCallDateBand
\n"; while ($r = mysqli_fetch_row($q)) { $ret .= "\n"; } @@ -748,6 +748,17 @@ function f2b ($f) { return 0; } +function member_lookup($call) { + global $associates; + $members = get_memberlist($call); + + foreach ($members as $m) { + if ($m["callsign"] == $call) { + return json_encode($m); + } + } +} + # look up calls on HamQTH's API # Save all data in a local Redis Database to avoid flooding the API # Also load exceptions from OK1RR's country file. @@ -963,7 +974,7 @@ function editformline($hiscallv, $nrv, $datev, $bandv, $dxccv, $wazv, $wasv, $wa -onblur="javascript:dxcc_lookup(this.value);" +onblur="javascript:dxcc_lookup(this.value);member_lookup(this.value);" size=10> diff --git a/index.php b/index.php index fbdf652..c4ccb5d 100755 --- a/index.php +++ b/index.php @@ -219,6 +219,31 @@ if (array_key_exists("id", $_SESSION)) { request.send(); } + // When entering a QSO manually, fill FOC nr and status + function member_lookup(c) { + console.log("member_lookup=" + c); + var request = new XMLHttpRequest(); + request.open("GET", '/api?action=member_lookup&hiscall=' + c, true); + request.onreadystatechange = function() { + var done = 4, ok = 200; + if (request.readyState == done && request.status == ok) { + if (request.responseText) { + try { + var o = JSON.parse(request.responseText); + if (o['nr']) { + var d = document.getElementById('nr0'); + d.value = o['nr']; + } + } + catch (e) { + console.log("parsing lookup json failed"); + } + } + } + } + request.send(); + } + function clear_form (nr) { var items = ['hiscall', 'nr', 'date', 'band'];
CountCWopsCallDateBand (m)
".$cnt++."".$r[0]."".$r[1]."".$r[2]."".$r[3]."