"use strict"; /* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ Object.defineProperty(exports, "__esModule", { value: true }); (() => { const los = exports.los; const maps = exports.maps; const searchFilterElement = document.querySelector("#searchFilter--map"); const searchResultsContainerElement = document.querySelector("#container--searchResults"); function renderResults() { searchResultsContainerElement.innerHTML = los.getLoadingParagraphHTML(`Loading ${exports.aliases.maps}...`); let searchResultCount = 0; const searchResultsTbodyElement = document.createElement("tbody"); const filterStringSplit = searchFilterElement.value.trim().toLowerCase().split(" "); for (const map of maps) { const mapSearchString = `${map.mapName} ${map.mapDescription} ${map.mapAddress1} ${map.mapAddress2}`.toLowerCase(); let showMap = true; for (const filterStringPiece of filterStringSplit) { if (!mapSearchString.includes(filterStringPiece)) { showMap = false; break; } } if (!showMap) { continue; } searchResultCount += 1; searchResultsTbodyElement.insertAdjacentHTML("beforeend", "" + ("" + '' + cityssm.escapeHTML(map.mapName || "(No Name)") + "
" + '' + cityssm.escapeHTML(map.mapDescription || "") + "" + "") + ("" + (map.mapAddress1 ? cityssm.escapeHTML(map.mapAddress1) + "
" : "") + (map.mapAddress2 ? cityssm.escapeHTML(map.mapAddress2) + "
" : "") + (map.mapCity || map.mapProvince ? cityssm.escapeHTML(map.mapCity || "") + ", " + cityssm.escapeHTML(map.mapProvince || "") + "
" : "") + (map.mapPostalCode ? cityssm.escapeHTML(map.mapPostalCode) : "") + "") + ("" + cityssm.escapeHTML(map.mapPhoneNumber || "") + "") + '' + (map.mapLatitude && map.mapLongitude ? '' : "") + "" + '' + (map.mapSVG ? '' : "") + "" + ('' + '' + map.lotCount + "" + "") + ""); } searchResultsContainerElement.innerHTML = ""; if (searchResultCount === 0) { searchResultsContainerElement.innerHTML = `

There are no ${los.escapedAliases.maps} that meet the search criteria.

`; } else { const searchResultsTableElement = document.createElement("table"); searchResultsTableElement.className = "table is-fullwidth is-striped is-hoverable has-sticky-header"; searchResultsTableElement.innerHTML = ` ${los.escapedAliases.Map} Address Phone Number Coordinates Image ${los.escapedAliases.Lot} Count `; searchResultsTableElement.append(searchResultsTbodyElement); searchResultsContainerElement.append(searchResultsTableElement); } } searchFilterElement.addEventListener("keyup", renderResults); document.querySelector("#form--searchFilters").addEventListener("submit", (formEvent) => { formEvent.preventDefault(); renderResults(); }); renderResults(); })();