From e531ddc2776b7a0341da691b822f734669b31e25 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 19 Aug 2025 16:03:53 +0000 Subject: [PATCH] Implement map pagination fix for public slug pages Co-authored-by: magicbug <84308+magicbug@users.noreply.github.com> --- application/controllers/Visitor.php | 11 ++++++++++- application/views/visitor/layout/footer.php | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/application/controllers/Visitor.php b/application/controllers/Visitor.php index 496ac3e0..c9cd33ab 100644 --- a/application/controllers/Visitor.php +++ b/application/controllers/Visitor.php @@ -193,7 +193,16 @@ class Visitor extends CI_Controller { show_404('Unknown Public Page.'); } - $qsos = $this->logbook_model->get_qsos('18', null, $logbooks_locations_array); + // Get pagination parameters - if page is provided, calculate offset + $page = $this->input->post('page'); + $per_page = 25; // Match the per_page from index method + $offset = null; + + if ($page && is_numeric($page) && $page > 0) { + $offset = ($page - 1) * $per_page; + } + + $qsos = $this->logbook_model->get_qsos($per_page, $offset, $logbooks_locations_array); // [PLOT] ADD plot // $plot_array = $this->logbook_model->get_plot_array_for_map($qsos->result()); diff --git a/application/views/visitor/layout/footer.php b/application/views/visitor/layout/footer.php index 74ab0e3e..b55718c3 100644 --- a/application/views/visitor/layout/footer.php +++ b/application/views/visitor/layout/footer.php @@ -49,6 +49,27 @@ uri->segment(2) != "search" && $this->uri->segment(2) != "satellites") { ?> initmap(grid); + + // Add pagination click handler for map updates + $(document).on('click', '.pagination a', function(e) { + var href = $(this).attr('href'); + if (href && typeof qso_loc !== 'undefined') { + // Extract offset from URL (last segment after /index/ or default to 0) + var matches = href.match(/\/index(?:\/(\d+))?$/); + var offset = matches && matches[1] ? parseInt(matches[1]) : 0; + var per_page = 25; + var page = Math.floor(offset / per_page) + 1; + + // Refresh map with new page data + console.log('Pagination clicked, refreshing map for page:', page, 'offset:', offset); + if (typeof askForPlots === 'function') { + askForPlots(qso_loc, { + dataPost: { page: page }, + map_id: '#map' + }); + } + } + }); });