use sessiodata for map_custom instead ajax

This commit is contained in:
HB9HIL
2024-05-31 12:51:42 +02:00
parent 27d1269470
commit 01aa4a3659
6 changed files with 39 additions and 34 deletions

View File

@@ -47,18 +47,6 @@ class User_Options extends CI_Controller {
echo json_encode($jsonout);
}
// [MAP Custom] //
public function get_map_custom() {
$result=$this->user_options_model->get_options('map_custom');
$jsonout=[];
foreach($result->result() as $options) {
if ($options->option_name=='icon') $jsonout[$options->option_key]=json_decode($options->option_value,true);
else $jsonout[$options->option_name.'_'.$options->option_key]=$options->option_value;
}
header('Content-Type: application/json');
echo json_encode($jsonout);
}
public function dismissVersionDialog() {
$this->user_options_model->set_option('version_dialog', 'confirmed', array('boolean' => 'true'));
}

View File

@@ -138,4 +138,23 @@ class OptionsLib {
}
}
function get_map_custom() {
$CI =& get_instance();
$jsonout = [];
$result = $CI->user_options_model->get_options('map_custom');
foreach($result->result() as $options) {
if ($options->option_name == 'icon') {
$jsonout[$options->option_key] = json_decode($options->option_value,true);
} else {
$jsonout[$options->option_name.'_'.$options->option_key]=$options->option_value;
}
}
return json_encode($jsonout);
}
}

View File

@@ -437,6 +437,7 @@ class User_Model extends CI_Model {
'user_column3' => isset($u->row()->user_column3) ? $u->row()->user_column3: 'RSTR',
'user_column4' => isset($u->row()->user_column4) ? $u->row()->user_column4: 'Band',
'user_column5' => isset($u->row()->user_column5) ? $u->row()->user_column5: 'Country',
'user_map_custom' => $this->optionslib->get_map_custom(),
'user_previous_qsl_type' => isset($u->row()->user_previous_qsl_type) ? $u->row()->user_previous_qsl_type: 0,
'user_amsat_status_upload' => isset($u->row()->user_amsat_status_upload) ? $u->row()->user_amsat_status_upload: 0,
'user_mastodon_url' => $u->row()->user_mastodon_url,

View File

@@ -55,6 +55,9 @@
<script>
var userName = '<?php echo $this->session->userdata('user_name'); ?>';
let user_map_custom = JSON.parse('<?php echo $this->session->userdata('user_map_custom') ?? ''; ?>');
<?php
if ($this->uri->segment(1) == "qso") {
$actstation=$this->stations->find_active() ?? '';

View File

@@ -51,15 +51,17 @@ function initplot(_url_qso, options={}) {
if (_visitor) {
askForPlots(_url_qso, options);
} else {
$.ajax({
url: base_url+'index.php/user_options/get_map_custom', type: 'GET', dataType: 'json',
error: function() { askForPlots(_url_qso, options); console.log('[ERROR] ajax get_map_custom() function return error.'); },
success: function(json_mapinfo) {
if (typeof json_mapinfo.qso !== "undefined") { iconsList = json_mapinfo; }
if(json_mapinfo.gridsquare_show == "1") { maidenhead.addTo(map); }
askForPlots(_url_qso, options);
}
});
let json_mapinfo = user_map_custom;
if (typeof json_mapinfo.qso !== "undefined") {
iconsList = json_mapinfo;
}
if(json_mapinfo.gridsquare_show == "1") {
maidenhead.addTo(map);
}
askForPlots(_url_qso, options);
}
}
}

View File

@@ -504,19 +504,11 @@ function createContentMessageDx(qso) {
}
function loadMapOptions(data) {
$.ajax({
url: base_url + 'index.php/user_options/get_map_custom',
type: 'GET',
dataType: 'json',
error: function () {
},
success: function (json_mapinfo) {
if (typeof json_mapinfo.qso !== "undefined") {
iconsList = json_mapinfo;
}
loadMap(data, iconsList)
}
});
let json_mapinfo = user_map_custom;
if (typeof json_mapinfo.qso !== "undefined") {
iconsList = json_mapinfo;
}
loadMap(data, iconsList)
}
function mapQsos(form) {