var hamsAtTimer; var workableRows = 0; function loadHamsAt(show_workable_only) { clearInterval(hamsAtTimer); workable_only = show_workable_only.value; $.ajax({ dataType: "json", url: base_url + 'index.php/hamsat/activations', type: 'post', success: function(result) { loadActivationsTable(result, workable_only); } }); obj = { value: workable_only, }; hamsAtTimer = setInterval(function() { loadHamsAt(obj); }, 60000); } function configureButton(rowLength) { if (feed_key_set > 1) { if (workableRows != rowLength) { if (workable_only == '1') { $('#workable_hint').text("Only workable passes shown."); $('#toggle_workable').prop('value', 0); if (rowLength > workableRows) { $('#toggle_workable').html('Show all passes ('+rowLength+')'); } else { $('#toggle_workable').html('Show all passes'); } $('#toggle_workable').show() } else { $('#workable_hint').text("All passes shown."); $('#toggle_workable').prop('value', 1); if (workableRows < rowLength) { $('#toggle_workable').html('Show workable passes only ('+workableRows+')'); } else { $('#toggle_workable').html('Show workable passes only'); } $('#toggle_workable').show() } } } } function loadActivationsTable(rows, show_workable_only) { var uninitialized = $('#activationsList').filter(function() { if ($.fn.DataTable.isDataTable(this)) { return false; } else { configureButton(rows.length); return true; } }); $.fn.dataTable.ext.buttons.clear = { className: 'buttons-clear', action: function ( e, dt, node, config ) { dt.search('').draw(); } }; uninitialized.each(function() { $.fn.dataTable.moment(custom_date_format); $(this).DataTable({ "pageLength": 25, "columnDefs": [ { "defaultContent": "-", "targets": "_all" },{ "targets": [8, 9, 10], "orderable": false } ], searching: true, responsive: false, ordering: true, "scrollY": window.innerHeight - $('#searchForm').innerHeight() - 250, "scrollCollapse": true, createdRow: function (row, data, dataIndex) { $(row).attr('id',data.id); }, "language": { url: getDataTablesLanguageUrl(), }, dom: 'Bfrtip', buttons: [ { extend: 'csv' }, { extend: 'clear', text: lang_admin_clear }, ], initComplete: function () { configureButton(rows.length); }, }); }); configureButton(rows.length); var table = $('#activationsList').DataTable(); table.clear(); workableRows = 0; for (i = 0; i < rows.length; i++) { let activation = rows[i]; if (workable_only == "1" && activation.is_workable == false) { continue; } else { if (activation.is_workable == true) { workableRows++; } } var data = []; data.push(activation.aos_at_date); data.push(activation.aos_to_los); if (activation.callsign_wkd == 1) {; data.push(""+activation.callsign.replaceAll('0', 'Ø')+""); } else { data.push(activation.callsign.replaceAll('0', 'Ø')); } data.push(activation.comment); if (activation.satellite.name != activation.sat_export_name) { sat = activation.sat_export_name; } else { sat = activation.satellite.name; } if (activation.mhz != null) { freq = parseFloat(activation.mhz).toFixed(3); dir = ''; if (activation.mhz_direction == "up") { dir = '↑'; } else if (activation.mhz_direction == "down") { dir = '↓'; } data.push(""+sat+""); } else { data.push(sat); } data.push(""+activation.mode+""); grids = []; for (var j=0; j < activation.grids_wkd.length; j++) { if (!grids.some(str => str.includes(activation.grids[j].substring(0, 4)))) { switch (activation.grids_wkd[j]) { case 1: grids.push(""+activation.grids[j].substring(0, 4)+"") break; case 2: grids.push(""+activation.grids[j].substring(0, 4)+"") break; default: grids.push(""+activation.grids[j].substring(0, 4)+"") break; } } } data.push(grids.join(' ')); if (feed_key_set > 0) { if (activation.is_workable == true) { data.push(activation.workable_from_to); } else { data.push('No'); } } else { data.push('Unknown'); } if (activation.likes != '0') { data.push('