"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() {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
searchResultsContainerElement.innerHTML = los.getLoadingParagraphHTML(`Loading ${los.escapedAliases.Maps}...`);
let searchResultCount = 0;
const searchResultsTbodyElement = document.createElement('tbody');
const filterStringSplit = searchFilterElement.value
.trim()
.toLowerCase()
.split(' ');
for (const map of maps) {
const mapSearchString = `${(_a = map.mapName) !== null && _a !== void 0 ? _a : ''} ${(_b = map.mapDescription) !== null && _b !== void 0 ? _b : ''} ${(_c = map.mapAddress1) !== null && _c !== void 0 ? _c : ''} ${(_d = map.mapAddress2) !== null && _d !== void 0 ? _d : ''}`.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)' : map.mapName) +
' ' +
'' +
cityssm.escapeHTML((_e = map.mapDescription) !== null && _e !== void 0 ? _e : '') +
'' +
' | ') +
('' +
(((_f = map.mapAddress1) !== null && _f !== void 0 ? _f : '') === ''
? ''
: cityssm.escapeHTML(map.mapAddress1) + ' ') +
(((_g = map.mapAddress2) !== null && _g !== void 0 ? _g : '') === ''
? ''
: cityssm.escapeHTML(map.mapAddress2) + ' ') +
(map.mapCity || map.mapProvince
? cityssm.escapeHTML((_h = map.mapCity) !== null && _h !== void 0 ? _h : '') +
', ' +
cityssm.escapeHTML((_j = map.mapProvince) !== null && _j !== void 0 ? _j : '') +
' '
: '') +
(((_k = map.mapPostalCode) !== null && _k !== void 0 ? _k : '') === ''
? ''
: cityssm.escapeHTML(map.mapPostalCode)) +
' | ') +
('' + cityssm.escapeHTML((_l = map.mapPhoneNumber) !== null && _l !== void 0 ? _l : '') + ' | ') +
'' +
(map.mapLatitude && map.mapLongitude
? ''
: '') +
' | ' +
'' +
(((_m = map.mapSVG) !== null && _m !== void 0 ? _m : '') === ''
? ''
: '') +
' | ' +
`
${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();
})();