"use strict"; /* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ Object.defineProperty(exports, "__esModule", { value: true }); (() => { const los = exports.los; const searchFilterFormElement = document.querySelector("#form--searchFilters"); const searchResultsContainerElement = document.querySelector("#container--searchResults"); const limit = Number.parseInt(document.querySelector("#searchFilter--limit").value, 10); const offsetElement = document.querySelector("#searchFilter--offset"); function renderLots(responseJSON) { if (responseJSON.lots.length === 0) { searchResultsContainerElement.innerHTML = '
' + '

There are no ' + los.escapedAliases.lots + " that meet the search criteria.

" + "
"; return; } const resultsTbodyElement = document.createElement("tbody"); for (const lot of responseJSON.lots) { resultsTbodyElement.insertAdjacentHTML("beforeend", "" + ("" + '' + cityssm.escapeHTML(lot.lotName || "") + "" + "") + ("" + '' + (lot.mapName ? cityssm.escapeHTML(lot.mapName) : '(No Name)') + "" + "") + ("" + cityssm.escapeHTML(lot.lotType || "") + "") + ("" + (lot.lotStatusId ? cityssm.escapeHTML(lot.lotStatus || "") : '(No Status)') + "
" + (lot.lotOccupancyCount > 0 ? 'Currently Occupied' : "") + "") + ""); } searchResultsContainerElement.innerHTML = '' + "" + ("") + ("") + ("") + "" + "" + "
" + los.escapedAliases.Lot + "" + los.escapedAliases.Map + "" + los.escapedAliases.Lot + " TypeStatus
" + '
' + ('
' + '
' + "Displaying " + (responseJSON.offset + 1).toString() + " to " + Math.min(responseJSON.count, limit + responseJSON.offset) + " of " + responseJSON.count + "
" + "
") + ('
' + (responseJSON.offset > 0 ? '
' + '" + "
" : "") + (limit + responseJSON.offset < responseJSON.count ? '
' + '" + "
" : "") + "
") + "
"; searchResultsContainerElement.querySelector("table").append(resultsTbodyElement); if (responseJSON.offset > 0) { searchResultsContainerElement.querySelector("button[data-page='previous']").addEventListener("click", previousAndGetLots); } if (limit + responseJSON.offset < responseJSON.count) { searchResultsContainerElement.querySelector("button[data-page='next']").addEventListener("click", nextAndGetLots); } } function getLots() { searchResultsContainerElement.innerHTML = '
' + '
' + "Loading " + los.escapedAliases.Lots + "..." + "
"; cityssm.postJSON(los.urlPrefix + "/lots/doSearchLots", searchFilterFormElement, renderLots); } function resetOffsetAndGetLots() { offsetElement.value = "0"; getLots(); } function previousAndGetLots() { offsetElement.value = Math.max(Number.parseInt(offsetElement.value, 10) - limit, 0).toString(); getLots(); } function nextAndGetLots() { offsetElement.value = (Number.parseInt(offsetElement.value, 10) + limit).toString(); getLots(); } const filterElements = searchFilterFormElement.querySelectorAll("input, select"); for (const filterElement of filterElements) { filterElement.addEventListener("change", resetOffsetAndGetLots); } searchFilterFormElement.addEventListener("submit", (formEvent) => { formEvent.preventDefault(); resetOffsetAndGetLots(); }); getLots(); })();