mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Refactor QRB language and improve UI
This commit is contained in:
@@ -23,8 +23,13 @@ class Qrbcalc extends CI_Controller {
|
||||
}
|
||||
|
||||
public function calculate() {
|
||||
$locator1 = $this->input->post("locator1");
|
||||
$locator2 = $this->input->post("locator2");
|
||||
|
||||
if(!$this->load->is_loaded('Qra')) {
|
||||
$this->load->library('Qra');
|
||||
}
|
||||
|
||||
$locator1 = strtoupper($this->input->post("locator1", TRUE));
|
||||
$locator2 = strtoupper($this->input->post("locator2", TRUE));
|
||||
|
||||
if ($this->session->userdata('user_measurement_base') == NULL) {
|
||||
$measurement_base = $this->config->item('measurement_base');
|
||||
@@ -33,34 +38,40 @@ class Qrbcalc extends CI_Controller {
|
||||
$measurement_base = $this->session->userdata('user_measurement_base');
|
||||
}
|
||||
|
||||
switch ($measurement_base) {
|
||||
case 'M':
|
||||
$var_dist = " miles";
|
||||
break;
|
||||
case 'N':
|
||||
$var_dist = " nautic miles";
|
||||
break;
|
||||
case 'K':
|
||||
$var_dist = " kilometers";
|
||||
break;
|
||||
}
|
||||
|
||||
if(!$this->load->is_loaded('Qra')) {
|
||||
$this->load->library('Qra');
|
||||
}
|
||||
|
||||
$data['result'] = $this->qra->bearing($locator1, $locator2, $measurement_base);
|
||||
$data['distance'] = $this->qra->distance($locator1, $locator2, $measurement_base) . $var_dist;
|
||||
$data['bearing'] = $this->qra->get_bearing($locator1, $locator2) . "º";
|
||||
$latlng1 = $this->qra->qra2latlong($locator1);
|
||||
$latlng2 = $this->qra->qra2latlong($locator2);
|
||||
$latlng1[0] = number_format((float)$latlng1[0], 3, '.', '');;
|
||||
$latlng1[1] = number_format((float)$latlng1[1], 3, '.', '');;
|
||||
$latlng2[0] = number_format((float)$latlng2[0], 3, '.', '');;
|
||||
$latlng2[1] = number_format((float)$latlng2[1], 3, '.', '');;
|
||||
$distance = $this->qra->distance($locator1, $locator2, $measurement_base);
|
||||
|
||||
$text_latlng1 = $locator1 . ' ' . sprintf(__("Latitude: %s, Longitude: %s"), $latlng1[0], $latlng1[1]);
|
||||
$text_latlng2 = $locator2 . ' ' . sprintf(__("Latitude: %s, Longitude: %s"), $latlng2[0], $latlng2[1]);
|
||||
|
||||
switch ($measurement_base) {
|
||||
case 'M':
|
||||
$var_dist = sprintf(_ngettext("The distance between %s and %s is %s mile.", "The distance between %s and %s is %s miles.", intval($distance)), $locator1, $locator2, $distance);
|
||||
break;
|
||||
case 'N':
|
||||
$var_dist = sprintf(_ngettext("The distance between %s and %s is %s nautical mile.", "The distance between %s and %s is %s nautical miles.", intval($distance)), $locator1, $locator2, $distance);
|
||||
break;
|
||||
case 'K':
|
||||
$var_dist = sprintf(_ngettext("The distance between %s and %s is %s kilometer.", "The distance between %s and %s is %s kilometers.", intval($distance)), $locator1, $locator2, $distance);
|
||||
break;
|
||||
}
|
||||
|
||||
$data['result'] = $this->qra->bearing($locator1, $locator2, $measurement_base);
|
||||
$data['distance'] = $var_dist;
|
||||
$data['bearing'] = sprintf(__("The bearing is %s."), $this->qra->get_bearing($locator1, $locator2) . "º");
|
||||
$data['latlng1'] = $latlng1;
|
||||
$data['text_latlng1'] = $text_latlng1;
|
||||
$data['text_latlng2'] = $text_latlng2;
|
||||
$data['latlng2'] = $latlng2;
|
||||
|
||||
$data['latlong_info_text'] = __("Negative latitudes are south of the equator, negative longitudes are west of Greenwich.");
|
||||
$data['error_msg'] = __("Error in locators. Please check.");
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
var lang_admin_clear = "<?= __("Clear"); ?>";
|
||||
var lang_lotw_propmode_hint = "<?= __("Propagation mode is not supported by LoTW. LoTW QSL fields disabled."); ?>";
|
||||
var lang_no_states_for_dxcc_available = "<?= __("No states for this DXCC available"); ?>";
|
||||
var lang_qrbcalc_title = '<?= __("Compute QRB and QTF"); ?>';
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
<div class="mb-3 row">
|
||||
<div class="col-md-2 control-label" for="input"><?= __("Locator 1"); ?></div>
|
||||
<div class="col-md-4">
|
||||
<input class="form-control input-group-sm" id="qrbcalc_locator1" type="text" name="locator1" placeholder="" value="<?php if ($station_locator != "0") echo $station_locator; ?>" aria-label="locator1">
|
||||
<input class="form-control input-group-sm uppercase" id="qrbcalc_locator1" type="text" name="locator1" placeholder="" value="<?php if ($station_locator != "0") echo $station_locator; ?>" aria-label="locator1">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 row">
|
||||
<div class="col-md-2 control-label" for="input"><?= __("Locator 2"); ?></div>
|
||||
<div class="col-md-4">
|
||||
<input class="form-control input-group-sm" id="qrbcalc_locator2" type="text" name="locator2" placeholder="" aria-label="locator2">
|
||||
<input class="form-control input-group-sm uppercase" id="qrbcalc_locator2" type="text" name="locator2" placeholder="" aria-label="locator2">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -602,7 +602,7 @@ function spawnQrbCalculator(locator1, locator2) {
|
||||
type: 'post',
|
||||
success: function (html) {
|
||||
BootstrapDialog.show({
|
||||
title: 'Compute QRB and QTF',
|
||||
title: lang_qrbcalc_title,
|
||||
size: BootstrapDialog.SIZE_WIDE,
|
||||
cssClass: 'lookup-dialog',
|
||||
nl2br: false,
|
||||
@@ -666,18 +666,18 @@ function calculateQrb() {
|
||||
'locator2': locator2},
|
||||
success: function (html) {
|
||||
|
||||
var result = "<h5>Negative latitudes are south of the equator, negative longitudes are west of Greenwich. <br/>";
|
||||
result += ' ' + locator1.toUpperCase() + ' Latitude = ' + html['latlng1'][0] + ' Longitude = ' + html['latlng1'][1] + '<br/>';
|
||||
result += ' ' + locator2.toUpperCase() + ' Latitude = ' + html['latlng2'][0] + ' Longitude = ' + html['latlng2'][1] + '<br/>';
|
||||
result += 'Distance between ' + locator1.toUpperCase() + ' and ' + locator2.toUpperCase() + ' is ' + html['distance'] + '.<br />';
|
||||
result += 'The bearing is ' + html['bearing'] + '.</h5>';
|
||||
var result = "<h5>" + html['latlong_info_text'] + "<br><br>";
|
||||
result += html['text_latlng1'] + '<br>';
|
||||
result += html['text_latlng2'] + '<br><br>';
|
||||
result += html['distance'] + ' ';
|
||||
result += html['bearing'] + '</h5>';
|
||||
|
||||
$(".qrbResult").html(result);
|
||||
newpath(html['latlng1'], html['latlng2'], locator1, locator2);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$('.qrbResult').html('<div class="qrbalert alert alert-danger" role="alert">Error in locators. Please check.</div>');
|
||||
$('.qrbResult').html('<div class="qrbalert alert alert-danger" role="alert">' + html['error_msg'] + '</div>');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user