Skip to content

Commit

Permalink
fix: fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqtw committed Dec 6, 2023
1 parent 084f9a7 commit c6c7270
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions lms/templates/courseware/courses.html
Original file line number Diff line number Diff line change
Expand Up @@ -329,30 +329,29 @@ <h2 class="header-search-facets">${_('Refine Your Search')}</h2>
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 = "<b>" + numberOfCourses + "</b> " + 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();
Expand Down

0 comments on commit c6c7270

Please sign in to comment.