new QueryResultsView(term, confirmed)
Initializes the query results view, setting up the display elements for the search term.
Parameters:
Name | Type | Description |
---|---|---|
term |
string | The search term. |
confirmed |
boolean | Indicates if the search is confirmed (e.g., by pressing Enter). |
Methods
-
private, static clearList()
-
Clears all items from the results list.
-
private, static createContainer() → {HTMLElement}
-
Creates and returns the main container element for the query results.
Returns:
HTMLElement -- The container element for the results.
-
private, static createHeader() → {HTMLElement}
-
Creates and appends a header to the container based on the search term.
Returns:
HTMLElement -- The header element displaying the search term or a loading message.
-
private, static createList() → {HTMLElement}
-
Creates and appends an initial list element to display the search results.
Returns:
HTMLElement -- The list element for displaying the results.
-
private, static createListItem(result) → {HTMLElement}
-
Creates and returns a list item for an individual search result.
Parameters:
Name Type Description result
Object The search result object with properties such as title, description, and icon.
Returns:
HTMLElement -- The list item element representing the search result.
-
private, static remove()
-
Removes the results container from the page.
-
static renderIn(selector)
-
Appends the results container to a specified selector on the page.
Parameters:
Name Type Description selector
string The selector string for the target container.
-
static renderResults(results, onResultInteraction)
-
Renders the search results within the list container and sets up event interactions.
Parameters:
Name Type Description results
Array.<Object> An array of search result objects to display.
onResultInteraction
function A callback function for handling interaction events on results.
-
private, static setupAccordion()
-
Sets up the accordion functionality for expanding and collapsing results.