From f88128fa6440c1d0c0fd69d8de99583af728345f Mon Sep 17 00:00:00 2001 From: campbell-m <87438215+campbell-m@users.noreply.github.com> Date: Sat, 26 Oct 2024 13:58:51 +0100 Subject: [PATCH 1/5] Restructure --- web/index.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/web/index.php b/web/index.php index ffa75621c5..53bb9c6212 100644 --- a/web/index.php +++ b/web/index.php @@ -156,7 +156,7 @@ function make_room_select_html (string $view, int $view_all, int $year, int $mon // Gets the link to the next/previous day/week/month -function get_adjacent_link(string $view, int $view_all, int $year, int $month, int $day, int $area, int $room, bool $next=false) : string +function get_adjacent_link(string $view, int $view_all, int $year, int $month, int $day, int $area, int $room, int $increment) : string { $date = new DateTime(); $date->setDate($year, $month, $day); @@ -164,7 +164,7 @@ function get_adjacent_link(string $view, int $view_all, int $year, int $month, i switch ($view) { case 'day': - $modifier = ($next) ? '+1 day' : '-1 day'; + $modifier = "$increment day"; // find the next non-hidden day $i = 0; do { @@ -173,12 +173,11 @@ function get_adjacent_link(string $view, int $view_all, int $year, int $month, i } while ($date->isHiddenDay() && ($i < DAYS_PER_WEEK)); // break the loop if all days are hidden break; case 'week': - $modifier = ($next) ? '+1 week' : '-1 week'; + $modifier = "$increment week"; $date->modify($modifier); break; case 'month': - $n = ($next) ? 1 : -1; - $date->modifyMonthsNoOverflow($n); + $date->modifyMonthsNoOverflow($increment); break; default: throw new \Exception("Unknown view '$view'"); @@ -292,9 +291,9 @@ function get_arrow_nav(string $view, int $view_all, int $year, int $month, int $ $title_prev = htmlspecialchars($title_prev); $title_next = htmlspecialchars($title_next); - $link_prev = get_adjacent_link($view, $view_all, $year, $month, $day, $area, $room, false); + $link_prev = get_adjacent_link($view, $view_all, $year, $month, $day, $area, $room, -1); $link_today = get_today_link($view, $view_all, $area, $room); - $link_next = get_adjacent_link($view, $view_all, $year, $month, $day, $area, $room, true); + $link_next = get_adjacent_link($view, $view_all, $year, $month, $day, $area, $room, 1); $link_prev = multisite($link_prev); $link_today = multisite($link_today); From 39cf8decea085665cad76afe70d26c0f584f38f6 Mon Sep 17 00:00:00 2001 From: campbell-m <87438215+campbell-m@users.noreply.github.com> Date: Sun, 27 Oct 2024 12:10:05 +0000 Subject: [PATCH 2/5] Add buttons in the day view to go back/forward by a week --- web/css/mrbs.css.php | 19 ++++++++++++++++--- web/index.php | 35 +++++++++++++++++++++++++++-------- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/web/css/mrbs.css.php b/web/css/mrbs.css.php index 568eedd1dd..0fc6b27b3e 100644 --- a/web/css/mrbs.css.php +++ b/web/css/mrbs.css.php @@ -644,12 +644,25 @@ text-decoration: none; } +nav a.symbol::before { + font-size: large; + line-height: 0; +} + nav a.prev::before { - content: '\00276e'; /* HEAVY LEFT-POINTING ANGLE QUOTATION MARK ORNAMENT */ + content: '\002039'; /* Single left-pointing angle quotation mark */ +} + +nav a.next::before { + content: '\00203a'; /* Single left-pointing angle quotation mark */ +} + +nav a.prev_week::before { + content: '\0000ab'; /* Left-pointing double angle quotation mark */ } -nav a.next::after { - content: '\00276f'; /* HEAVY RIGHT-POINTING ANGLE QUOTATION MARK ORNAMENT */ +nav a.next_week::before { + content: '\0000bb'; /* Right-pointing double angle quotation mark */ } .message_top { diff --git a/web/index.php b/web/index.php index 53bb9c6212..669119bd62 100644 --- a/web/index.php +++ b/web/index.php @@ -165,12 +165,17 @@ function get_adjacent_link(string $view, int $view_all, int $year, int $month, i { case 'day': $modifier = "$increment day"; - // find the next non-hidden day - $i = 0; - do { - $i++; - $date->modify($modifier); - } while ($date->isHiddenDay() && ($i < DAYS_PER_WEEK)); // break the loop if all days are hidden + $date->modify($modifier); + if ($increment === 1) + { + // find the next non-hidden day + $i = 0; + while ($date->isHiddenDay() && ($i < DAYS_PER_WEEK)) // break the loop if all days are hidden + { + $i++; + $date->modify($modifier); + } + } break; case 'week': $modifier = "$increment week"; @@ -272,6 +277,10 @@ function get_arrow_nav(string $view, int $view_all, int $year, int $month, int $ $title_prev = get_vocab('daybefore'); $title_this = get_vocab('gototoday'); $title_next = get_vocab('dayafter'); + $title_prev_week = get_vocab('weekbefore'); + $title_next_week = get_vocab('weekafter'); + $link_prev_week = get_adjacent_link($view, $view_all, $year, $month, $day, $area, $room, -7); + $link_next_week = get_adjacent_link($view, $view_all, $year, $month, $day, $area, $room, +7); break; case 'week': $title_prev = get_vocab('weekbefore'); @@ -299,10 +308,20 @@ function get_arrow_nav(string $view, int $view_all, int $year, int $month, int $ $link_today = multisite($link_today); $link_next = multisite($link_next); + // For the day view we also offer buttons to go back/forward by one week. + // The links without any text have their content filled by CSS. $html .= ""; return $html; From 293730278d30f9641c6d5c63bb5002bbf6ba37dd Mon Sep 17 00:00:00 2001 From: campbell-m <87438215+campbell-m@users.noreply.github.com> Date: Sun, 27 Oct 2024 12:18:38 +0000 Subject: [PATCH 3/5] Prefetch the << and >> buttons --- web/index.php | 8 ++++---- web/js/index.js.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/web/index.php b/web/index.php index 669119bd62..bdaf308ac4 100644 --- a/web/index.php +++ b/web/index.php @@ -313,14 +313,14 @@ function get_arrow_nav(string $view, int $view_all, int $year, int $month, int $ $html .= ""; diff --git a/web/js/index.js.php b/web/js/index.js.php index 7fedd70bc4..819feaffa4 100644 --- a/web/js/index.js.php +++ b/web/js/index.js.php @@ -218,8 +218,8 @@ var delay = * 1000; var hrefs = []; - ['a.prev', 'a.next'].forEach(function(anchor) { - var a = $(anchor); + $('a.prefetch').each(function() { + var a = $(this); Date: Sun, 27 Oct 2024 16:51:45 +0000 Subject: [PATCH 4/5] Fix problem resulting in many outstanding requests --- web/js/index.js.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web/js/index.js.php b/web/js/index.js.php index 819feaffa4..8fa2de36e8 100644 --- a/web/js/index.js.php +++ b/web/js/index.js.php @@ -216,8 +216,10 @@ return; } + var activeConnections = 0; var delay = * 1000; var hrefs = []; + $('a.prefetch').each(function() { var a = $(this); }) .done(function(response) { updateBody.prefetched[href] = response; + activeConnections--; - if (Object.keys(updateBody.prefetched).length === hrefs.length) + if (activeConnections === 0) { prefetch.timeoutId = setTimeout(prefetch, delay); } From 7bc7f873e05f22bb2762609680918b63d62dd925 Mon Sep 17 00:00:00 2001 From: campbell-m <87438215+campbell-m@users.noreply.github.com> Date: Sun, 27 Oct 2024 17:11:57 +0000 Subject: [PATCH 5/5] Don't display the << and >> buttons on narrow screens --- web/css/mrbs.css.php | 11 +++++++++-- web/index.php | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/web/css/mrbs.css.php b/web/css/mrbs.css.php index 0fc6b27b3e..214f499d6a 100644 --- a/web/css/mrbs.css.php +++ b/web/css/mrbs.css.php @@ -657,14 +657,21 @@ content: '\00203a'; /* Single left-pointing angle quotation mark */ } -nav a.prev_week::before { +nav a.prev.week::before { content: '\0000ab'; /* Left-pointing double angle quotation mark */ } -nav a.next_week::before { +nav a.next.week::before { content: '\0000bb'; /* Right-pointing double angle quotation mark */ } +> buttons on narrow screens ?> +@media (max-width: 30rem) { + nav a.week { + display: none; + } +} + .message_top { font-weight: bold; color: red; diff --git a/web/index.php b/web/index.php index bdaf308ac4..b12144f850 100644 --- a/web/index.php +++ b/web/index.php @@ -313,14 +313,14 @@ function get_arrow_nav(string $view, int $view_all, int $year, int $month, int $ $html .= "";