function renderSearchResults()

in themes/docsy/static/js/offline-search.js [73:95]


function renderSearchResults(results) {
    // Create a list of results
    if (results.length > 0) {
    var ul = document.createElement('ul');
    results.forEach(function(result) {
        // Create result item
        var li = document.createElement('li');
        li.innerHTML = '<a href="' + result.ref + '">' + resultDetails[result.ref].title + '</a><br>' + resultDetails[result.ref].excerpt + '...';
        ul.appendChild(li);
    });

      // Remove any existing content so results aren't continually added as the user types
    while ($searchResults.hasChildNodes()) {
        $searchResults.removeChild(
        $searchResults.lastChild
        );
    }
    } else {
        $searchResults.innerHTML = '<ul><li>No results found</li></ul>';
        }
    // Render the list
    $searchResults.appendChild(ul);
}