move js to a dedicated file

This commit is contained in:
HB9HIL
2024-05-24 21:36:46 +02:00
parent c9a3e1d9e2
commit 6ea710ff27
4 changed files with 70 additions and 72 deletions

View File

@@ -17,7 +17,6 @@ class Activators extends CI_Controller
public function index()
{
// Render Page
$data['page_title'] = "Gridsquare Activators";
$this->load->model('Activators_model');
@@ -36,9 +35,14 @@ class Activators extends CI_Controller
$data['activators_vucc_array'] = $this->Activators_model->get_activators_vucc($band, $this->input->post('leogeo'));
$data['bandselect'] = $band;
$footerData = [];
$footerData['scripts'] = [
'assets/js/sections/activators.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/activators.js")),
];
$this->load->view('interface_assets/header', $data);
$this->load->view('activators/index');
$this->load->view('interface_assets/footer');
$this->load->view('interface_assets/footer', $footerData);
}
public function details()

View File

@@ -16,7 +16,7 @@
</select>
</div>
</div>
<div class="mb-3 row" id="leogeo">
<div class="mb-3 row" id="leogeo" style="display: none;">
<label class="col-md-1 control-label" for="leogeo">LEO/GEO</label>
<div class="col-md-3">
<select id="leogeo" name="leogeo" class="form-select">

View File

@@ -1981,75 +1981,7 @@ $(document).ready(function(){
}
</script>
<?php } ?>
<?php if ($this->uri->segment(1) == "activators") { ?>
<script>
$('.activatorstable').DataTable({
"pageLength": 25,
responsive: false,
ordering: false,
"scrollY": "500px",
"scrollCollapse": true,
"paging": false,
"scrollX": true,
"language": {
url: getDataTablesLanguageUrl(),
},
dom: 'Bfrtip',
buttons: [
'csv'
]
});
// change color of csv-button if dark mode is chosen
if (isDarkModeTheme()) {
$(".buttons-csv").css("color", "white");
}
$(document).ready(function(){
$('#band').change(function()
{
if($(this).val() == "SAT")
{
$('#leogeo').show();
} else {
$('#leogeo').hide();
}
});
<?php if ($this->input->post('band') != "SAT") { ?>
$('#leogeo').hide();
<?php } ?>
});
function displayActivatorsContacts(call, band, leogeo) {
var baseURL= "<?php echo base_url();?>";
$.ajax({
url: baseURL + 'index.php/activators/details',
type: 'post',
data: {'Callsign': call,
'Band': band,
'LeoGeo': leogeo
},
success: function(html) {
BootstrapDialog.show({
title: lang_general_word_qso_data,
size: BootstrapDialog.SIZE_WIDE,
cssClass: 'qso-was-dialog',
nl2br: false,
message: html,
onshown: function(dialog) {
$('[data-bs-toggle="tooltip"]').tooltip();
},
buttons: [{
label: lang_admin_close,
action: function (dialogItself) {
dialogItself.close();
}
}]
});
}
});
}
</script>
<?php } ?>
<?php if ($this->uri->segment(1) == "mode") { ?>
<script src="<?php echo base_url(); ?>assets/js/sections/mode.js"></script>

View File

@@ -0,0 +1,62 @@
$(".activatorstable").DataTable({
pageLength: 25,
responsive: false,
ordering: false,
scrollY: "500px",
scrollCollapse: true,
paging: false,
scrollX: true,
language: {
url: getDataTablesLanguageUrl(),
},
dom: "Bfrtip",
buttons: ["csv"],
});
$(document).ready(function () {
let bandselect = $('#band');
showHideLeoGeo(bandselect);
bandselect.change(function () {
showHideLeoGeo(bandselect);
});
});
function showHideLeoGeo(bandselect) {
if (bandselect.val() == "SAT") {
$("#leogeo").show();
} else {
$("#leogeo").hide();
}
}
function displayActivatorsContacts(call, band, leogeo) {
$.ajax({
url: base_url + "index.php/activators/details",
type: "post",
data: { Callsign: call, Band: band, LeoGeo: leogeo },
success: function (html) {
BootstrapDialog.show({
title: lang_general_word_qso_data,
size: BootstrapDialog.SIZE_WIDE,
cssClass: "qso-was-dialog",
nl2br: false,
message: html,
onshown: function (dialog) {
$('[data-bs-toggle="tooltip"]').tooltip();
},
buttons: [
{
label: lang_admin_close,
action: function (dialogItself) {
dialogItself.close();
},
},
],
});
},
});
}