From c6c727057302b87f8ba41fac891b78832ba0f3b3 Mon Sep 17 00:00:00 2001 From: qtw97 Date: Tue, 5 Dec 2023 19:58:46 -0500 Subject: [PATCH] fix: fix style --- lms/templates/courseware/courses.html | 47 +++++++++++++-------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/lms/templates/courseware/courses.html b/lms/templates/courseware/courses.html index 34f417cd0d80..05a1312bee41 100644 --- a/lms/templates/courseware/courses.html +++ b/lms/templates/courseware/courses.html @@ -329,30 +329,29 @@

${_('Refine Your Search')}

var searchForm = document.getElementById('discovery-form'); function updateSearchResultsCount(currentMessage, searchTerm) { - var message; - - if (searchTerm === '') { - // If no search term is entered, use the current discovery message - message = currentMessage; - } else { - // If a search term is entered, format the message - var numberOfCourses = currentMessage.includes("any") ? 0 : parseInt(currentMessage.match(/\d+/)[0]); - var courseWord = numberOfCourses === 1 ? "course" : "courses"; // Singular or plural - message = "" + numberOfCourses + " " + courseWord + " find for \"" + searchTerm + "\""; - } - - var resultsContainer = document.getElementById('search-results-container'); - var existingElement = resultsContainer.querySelector('.search-results-count'); - - if (existingElement) { - existingElement.innerHTML = message; // Use innerHTML to interpret HTML tags - } else { - var newElement = document.createElement('div'); - newElement.className = 'search-results-count'; - newElement.innerHTML = message; // Use innerHTML to interpret HTML tags - resultsContainer.appendChild(newElement); - } - } + // ... + + var resultsContainer = document.getElementById('search-results-container'); + var existingElement = resultsContainer.querySelector('.search-results-count'); + + if (!existingElement) { + existingElement = document.createElement('div'); + existingElement.className = 'search-results-count'; + resultsContainer.appendChild(existingElement); + } + + // Clear existing content + existingElement.innerHTML = ''; + + // Create and append the bold element for the number of courses + var boldElement = document.createElement('b'); + boldElement.textContent = numberOfCourses; + existingElement.appendChild(boldElement); + + // Append the rest of the text + existingElement.appendChild(document.createTextNode(" " + courseWord + " found for \"" + escapeHtml(searchTerm) + "\"")); + } + searchForm.addEventListener('submit', function (event) { event.preventDefault();