Merge pull request #1445 from phl0/removeRegex

Remove regex
这个提交包含在:
Peter Goodhall 2022-03-31 22:23:10 +01:00 提交者 GitHub
当前提交 9b595b281b
找不到此签名对应的密钥
GPG 密钥 ID: 4AEE18F83AFDEB23
共有 5 个文件被更改,包括 43 次插入7 次删除

查看文件

@ -44,6 +44,7 @@ class QSO extends CI_Controller {
$this->form_validation->set_rules('start_date', 'Date', 'required');
$this->form_validation->set_rules('start_time', 'Time', 'required');
$this->form_validation->set_rules('callsign', 'Callsign', 'required');
$this->form_validation->set_rules('locator', 'Locator', 'callback_check_locator');
if ($this->form_validation->run() == FALSE)
{
@ -443,4 +444,26 @@ class QSO extends CI_Controller {
header('Content-Type: application/json');
echo $input;
}
function check_locator($grid) {
$grid = $this->input->post('locator');
// Allow empty locator
if (preg_match('/^$/', $grid)) return true;
// Allow 6-digit locator
if (preg_match('/^[A-Ra-r]{2}[0-9]{2}[A-Ra-r]{2}$/', $grid)) return true;
// Allow 4-digit locator
else if (preg_match('/^[A-Ra-r]{2}[0-9]{2}$/', $grid)) return true;
// Allow 4-digit grid line
else if (preg_match('/^[A-Ra-r]{2}[0-9]{2},[A-Ra-r]{2}[0-9]{2}$/', $grid)) return true;
// Allow 4-digit grid corner
else if (preg_match('/^[A-Ra-r]{2}[0-9]{2},[A-Ra-r]{2}[0-9]{2},[A-Ra-r]{2}[0-9]{2},[A-Ra-r]{2}[0-9]{2}$/', $grid)) return true;
// Allow 2-digit locator
else if (preg_match('/^[A-Ra-r]{2}$/', $grid)) return true;
// Allow 8-digit locator
else if (preg_match('/^[A-Ra-r]{2}[0-9]{2}[A-Ra-r]{2}[0-9]{2}$/', $grid)) return true;
else {
$this->form_validation->set_message('check_locator', 'Please check value for grid locator ('.strtoupper($grid).').');
return false;
}
}
}

查看文件

@ -61,7 +61,7 @@ class Activators_model extends CI_Model
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = "SELECT DISTINCT COL_CALL AS `call`, GROUP_CONCAT(REGEXP_REPLACE(COL_VUCC_GRIDS, '([A-Z]{2}[0-9]{2})[A-Z]{2}', '$1')) AS `vucc_grids` FROM ".$this->config->item('table_name')." WHERE station_id in (" . $location_list . ")";
$sql = "SELECT DISTINCT COL_CALL AS `call`, GROUP_CONCAT(COL_VUCC_GRIDS) AS `vucc_grids` FROM ".$this->config->item('table_name')." WHERE station_id in (" . $location_list . ")";
if ($band != 'All') {
if ($band == 'SAT') {
switch ($leogeo) {

查看文件

@ -70,17 +70,20 @@
$vucc_grids[$line->call] = $line->vucc_grids;
}
}
if ($activators_array) {
if( $this->input->post('band') != NULL) {
if ($activators_array) {
$result = write_activators($activators_array, $vucc_grids, $custom_date_format, $this->input->post('band'), $this->input->post('leogeo'));
}
else {
echo '<div class="alert alert-danger" role="alert"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>Nothing found!</div>';
$result = write_activators($activators_array, $vucc_grids, $custom_date_format, $this->input->post('band'), $this->input->post('leogeo'));
}
else {
echo '<div class="alert alert-danger" role="alert"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>Nothing found!</div>';
}
}
?>
</div>
<?php
function write_activators($activators_array, $vucc_grids, $custom_date_format, $band, $leogeo) {

查看文件

@ -155,7 +155,7 @@
</div>
<div class="form-group row">
<label for="locator" class="col-sm-3 col-form-label"><?php echo $this->lang->line('gen_hamradio_locator'); ?></label>
<label for="locator" class="col-sm-3 col-form-label"><?php echo $this->lang->line('gen_hamradio_gridsquare'); ?></label>
<div class="col-sm-9">
<input type="text" class="form-control form-control-sm" name="locator" id="locator" value="">
<small id="locator_info" class="form-text text-muted"></small>

查看文件

@ -1,4 +1,14 @@
$( document ).ready(function() {
$("#locator")
.popover({ placement: 'top', title: 'Gridsquare Formatting', content: "Enter multiple (4-digit) grids separated with commas. For example: IO77,IO78" })
.focus(function () {
$('#locator').popover('show');
})
.blur(function () {
$('#locator').popover('hide');
});
$("#sat_name").change(function(){
var sat = $("#sat_name").val();
if (sat == "") {