Add display of hams of note

This commit is contained in:
phl0
2025-03-21 11:01:54 +01:00
parent 00e436157a
commit 34d60c9e41
9 changed files with 152 additions and 1 deletions

View File

@@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
*/
$config['migration_version'] = 238;
$config['migration_version'] = 239;
/*
|--------------------------------------------------------------------------

View File

@@ -156,6 +156,24 @@ class Lookup extends CI_Controller {
}
}
public function ham_of_note($call) {
session_write_close();
if($call) {
$call = str_replace("-","/",$call);
$uppercase_callsign = strtoupper($call);
}
$this->load->model('Pota');
$query = $this->Pota->ham_of_note($uppercase_callsign);
if ($query->row()) {
header('Content-Type: application/json');
echo json_encode($query->row());
} else {
return null;
}
}
public function get_state_list() {
$this->load->library('subdivisions');

View File

@@ -489,6 +489,15 @@ class Update extends CI_Controller {
$this->load->view('interface_assets/footer');
}
public function update_hamsofnote() {
$this->load->model('Update_model');
$bodyData['satupdates'] = $this->Update_model->update_hams_of_note();
$data['page_title'] = __("Update of Hams of Note");
$this->load->view('interface_assets/header', $data);
$this->load->view('update/hamsofnote', $bodyData);
$this->load->view('interface_assets/footer');
}
function version_check() {
// set the last run in cron table for the correct cron id
$this->load->model('cron_model');

View File

@@ -0,0 +1,52 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Migration_add_hams_of_note extends CI_Migration
{
public function up() {
if (!$this->db->table_exists('hams_of_note')) {
$this->dbforge->add_field(array(
'id' => array(
'type' => 'INT',
'constraint' => 20,
'unsigned' => TRUE,
'auto_increment' => TRUE,
'unique' => TRUE
),
'callsign' => array(
'type' => 'VARCHAR',
'constraint' => 32,
'unsigned' => TRUE,
),
'description' => array(
'type' => 'VARCHAR',
'constraint' => 256,
'unsigned' => TRUE,
),
'linkname' => array(
'type' => 'VARCHAR',
'constraint' => 256,
'unsigned' => TRUE,
'null' => TRUE,
'default' => '',
),
'link' => array(
'type' => 'VARCHAR',
'constraint' => 256,
'unsigned' => TRUE,
'null' => TRUE,
'default' => '',
),
));
$this->dbforge->add_key('id', TRUE);
$this->dbforge->create_table('hams_of_note');
$this->db->query("ALTER TABLE hams_of_note ADD INDEX `callsign` (`callsign`)");
}
}
public function down() {
if ($this->db->table_exists('hams_of_note')) {
$this->dbforge->drop_table('hams_of_note');
}
}
}

View File

@@ -23,6 +23,14 @@ class Pota extends CI_Model {
return $this->db->get($this->config->item('table_name'));
}
function ham_of_note($callsign) {
$this->db->where('callsign', $callsign);
$this->db->limit(1);
return $this->db->get('hams_of_note');
}
}
?>

View File

@@ -484,4 +484,37 @@ class Update_model extends CI_Model {
return;
}
function update_hams_of_note() {
$this->db->empty_table("hams_of_note");
$this->db->query("ALTER TABLE hams_of_note AUTO_INCREMENT 1");
$file = 'https://www.ham2k.com/data/hams-of-note.txt';
$handle = fopen($file, "r");
$i = 0;
while (false !== ($data = fgets($handle))) {
$line = trim($data);
if ($line != "" && $line[0] != '#') {
$index = strpos($line, ' ');
$call = substr($line, 0, $index);
$name = substr($line, strpos($line, ' '));
$linkname = $link = '';
if (strpos($name, '[')) {
$linkname = substr($name, strpos($name, '[')+1, (strpos($name, ']') - strpos($name, '[')-1));
$link= substr($name, strpos($name, '(')+1, (strpos($name, ')') - strpos($name, '(')-1));
$name = substr($name, 0, strpos($name, '['));
}
$hon[$i]['callsign'] = $call;
$hon[$i]['description'] = $name;
$hon[$i]['linkname'] = $linkname;
$hon[$i]['link'] = $link;
if (($i % 100) == 0) {
$this->db->insert_batch('hams_of_note', $hon);
unset($hon);
}
$i++;
}
}
$this->db->insert_batch('hams_of_note', $hon);
return;
}
}

View File

@@ -131,6 +131,7 @@
<span id="hamqth_info" class="input-group-text btn-included-on-field d-none py-0"></span>
</div>
<small id="callsign_info" class="badge text-bg-secondary"></small> <a id="lotw_link"><small id="lotw_info" class="badge text-bg-success"></small></a>
<p id="ham_of_note_line" style="margin-top: 5px; display: none"><small id="ham_of_note_info"></small><small><a id="ham_of_note_link"></a></small></p>
</div>
</div>

View File

@@ -0,0 +1,17 @@
<div class="container">
<h2><?php echo $page_title; ?></h2>
<?php
if ($satupdates) {
echo '<table class="table table-striped table-hover">';
echo '<tr><th>'.__('Name').'</th><th>'.__('Display Name').'</th><th>'.__('Start Date').'</th><th>'.__('End Date').'</th><th>'.__('Status').'</th></tr>';
foreach ($satupdates as $sat) {
echo('<tr><td>'.$sat['name'].'</td><td>'.$sat['displayname'].'</td><td>'.$sat['startDate'].'</td><td>'.$sat['endDate'].'</td><td>'.$sat['status'].'</td></tr>');
}
echo '</table>';
} else {
echo 'No updates found or file could not be parsed.';
}
?>
</div>

View File

@@ -526,6 +526,10 @@ function reset_fields() {
$('#continent').val("");
$('#email').val("");
$('#region').val("");
$('#ham_of_note_info').text("");
$('#ham_of_note_link').html("");
$('#ham_of_note_link').removeAttr('href');
$('#ham_of_note_line').hide();
$('#lotw_info').text("");
$('#lotw_info').attr('data-bs-original-title', "");
$('#lotw_info').removeClass("lotw_info_red");
@@ -724,6 +728,15 @@ $("#callsign").on("focusout", function () {
dok_selectize.clear();
}
$.getJSON(base_url + 'index.php/lookup/ham_of_note/' + $('#callsign').val().toUpperCase().replaceAll('Ø', '0').replaceAll('/','-'), function (result) {
if (result) {
$('#ham_of_note_info').text(result.description);
$('#ham_of_note_link').html(result.linkname);
$('#ham_of_note_link').attr('href', result.link);
$('#ham_of_note_line').show("slow");
}
});
$('#dxcc_id').val(result.dxcc.adif).multiselect('refresh');
await updateStateDropdown('#dxcc_id', '#stateInputLabel', '#location_us_county', '#stationCntyInputEdit');
if (result.callsign_cqz != '' && (result.callsign_cqz >= 1 && result.callsign_cqz <= 40)) {