From 58f6c4ed529a2f854b5e4e67b66d4a8977ba63e1 Mon Sep 17 00:00:00 2001 From: Jack Rhoa Date: Fri, 13 Feb 2026 14:27:08 -0500 Subject: [PATCH 1/2] modify logic --- tcf_website/static/common/recently_viewed.js | 7 +++++-- tcf_website/templates/base/index.html | 3 +++ .../templates/common/view_limit_modal.html | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 tcf_website/templates/common/view_limit_modal.html diff --git a/tcf_website/static/common/recently_viewed.js b/tcf_website/static/common/recently_viewed.js index a4926d152..925f81e42 100644 --- a/tcf_website/static/common/recently_viewed.js +++ b/tcf_website/static/common/recently_viewed.js @@ -67,11 +67,14 @@ function saveCourseInfoIfPresent() { previousPaths.unshift(currentUrl); previousPathsTitles.unshift(title); - // Keep only the top 10 items + // Only display last 10 items if (previousPaths.length > 10) { - previousPaths = previousPaths.slice(0, 10); previousPathsTitles = previousPathsTitles.slice(0, 10); } + if (previousPaths.length % 5 === 0 && previousPaths.length >= 10) { + previousPaths = previousPaths.slice(0, 0); + $('#viewLimitModal').modal('show'); + } // Save back to localStorage localStorage.setItem("previous_paths", JSON.stringify(previousPaths)); diff --git a/tcf_website/templates/base/index.html b/tcf_website/templates/base/index.html index 73d53549c..d87e5959b 100644 --- a/tcf_website/templates/base/index.html +++ b/tcf_website/templates/base/index.html @@ -73,6 +73,9 @@ {% include "common/adblock_modal.html" %} + + {% include "common/view_limit_modal.html" %} + diff --git a/tcf_website/templates/common/view_limit_modal.html b/tcf_website/templates/common/view_limit_modal.html new file mode 100644 index 000000000..1237bb50b --- /dev/null +++ b/tcf_website/templates/common/view_limit_modal.html @@ -0,0 +1,15 @@ + +{% load static %} + From afe201b4b30de125dc4fff849250adf38ccfa200 Mon Sep 17 00:00:00 2001 From: Jack Rhoa Date: Fri, 13 Feb 2026 15:50:48 -0500 Subject: [PATCH 2/2] improve handling --- tcf_website/static/common/recently_viewed.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tcf_website/static/common/recently_viewed.js b/tcf_website/static/common/recently_viewed.js index 925f81e42..3c53df3c9 100644 --- a/tcf_website/static/common/recently_viewed.js +++ b/tcf_website/static/common/recently_viewed.js @@ -69,11 +69,22 @@ function saveCourseInfoIfPresent() { // Only display last 10 items if (previousPaths.length > 10) { + // previousPaths = previousPaths.slice(0, 10); previousPathsTitles = previousPathsTitles.slice(0, 10); } + // Prevent too many courses from being stored, max 20 + if (previousPaths.length > 20) { + previousPaths = previousPaths.slice(0, 20); + previousPathsTitles = previousPathsTitles.slice(0, 20); + } + + if (previousPaths.length % 5 === 0 && previousPaths.length >= 10) { - previousPaths = previousPaths.slice(0, 0); - $('#viewLimitModal').modal('show'); + // Check if URL matches .../course/[letters]/[numbers] and ends there + const courseRegex = /course\/[a-zA-Z]+\/\d+\/?$/; + if (courseRegex.test(currentUrl)) { + $('#viewLimitModal').modal('show'); + } } // Save back to localStorage