From 693a71fc729da44a7b63d58e5e7967aefc08ba18 Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Thu, 29 Dec 2022 13:23:18 -0500 Subject: [PATCH] reduce nesting --- .../doSearchLotOccupancies.js | 1 + .../doSearchLotOccupancies.ts | 1 + public-typescript/lotOccupancySearch.js | 336 +++++++-------- public-typescript/lotOccupancySearch.ts | 386 +++++++++--------- public/javascripts/lotOccupancySearch.min.js | 2 +- 5 files changed, 366 insertions(+), 360 deletions(-) diff --git a/handlers/lotOccupancies-post/doSearchLotOccupancies.js b/handlers/lotOccupancies-post/doSearchLotOccupancies.js index f93ddf61..d7db2a47 100644 --- a/handlers/lotOccupancies-post/doSearchLotOccupancies.js +++ b/handlers/lotOccupancies-post/doSearchLotOccupancies.js @@ -7,6 +7,7 @@ export const handler = async (request, response) => { }); response.json({ count: result.count, + offset: Number.parseInt(request.body.offset, 10), lotOccupancies: result.lotOccupancies }); }; diff --git a/handlers/lotOccupancies-post/doSearchLotOccupancies.ts b/handlers/lotOccupancies-post/doSearchLotOccupancies.ts index eb21bc88..a80f1579 100644 --- a/handlers/lotOccupancies-post/doSearchLotOccupancies.ts +++ b/handlers/lotOccupancies-post/doSearchLotOccupancies.ts @@ -11,6 +11,7 @@ export const handler: RequestHandler = async (request, response) => { response.json({ count: result.count, + offset: Number.parseInt(request.body.offset, 10), lotOccupancies: result.lotOccupancies }); }; diff --git a/public-typescript/lotOccupancySearch.js b/public-typescript/lotOccupancySearch.js index 0ddf4020..1d04b8b9 100644 --- a/public-typescript/lotOccupancySearch.js +++ b/public-typescript/lotOccupancySearch.js @@ -7,8 +7,166 @@ Object.defineProperty(exports, "__esModule", { value: true }); const searchResultsContainerElement = document.querySelector("#container--searchResults"); const limit = Number.parseInt(document.querySelector("#searchFilter--limit").value, 10); const offsetElement = document.querySelector("#searchFilter--offset"); - const getLotOccupancies = () => { - const offset = Number.parseInt(offsetElement.value, 10); + function renderLotOccupancies(responseJSON) { + if (responseJSON.lotOccupancies.length === 0) { + searchResultsContainerElement.innerHTML = + '
' + + '

There are no ' + + cityssm.escapeHTML(exports.aliases.occupancy.toLowerCase()) + + " records that meet the search criteria.

" + + "
"; + return; + } + const resultsTbodyElement = document.createElement("tbody"); + const nowDateString = cityssm.dateToString(new Date()); + for (const lotOccupancy of responseJSON.lotOccupancies) { + let occupancyTimeHTML = ""; + if (lotOccupancy.occupancyStartDateString <= nowDateString && + (lotOccupancy.occupancyEndDateString === "" || + lotOccupancy.occupancyEndDateString >= nowDateString)) { + occupancyTimeHTML = + '' + + ('') + + ""; + } + else if (lotOccupancy.occupancyStartDateString > nowDateString) { + occupancyTimeHTML = + '' + + ('') + + ""; + } + else { + occupancyTimeHTML = + '' + + ('') + + ""; + } + let occupantsHTML = ""; + for (const occupant of lotOccupancy.lotOccupancyOccupants) { + occupantsHTML += + '' + + (' ') + + cityssm.escapeHTML(occupant.occupantName || "") + + "
"; + } + resultsTbodyElement.insertAdjacentHTML("beforeend", "" + + ('' + occupancyTimeHTML + "") + + ("" + + '' + + cityssm.escapeHTML(lotOccupancy.occupancyType) + + "" + + "") + + ("" + + (lotOccupancy.lotName + ? '' + + cityssm.escapeHTML(lotOccupancy.lotName) + + "" + : '(No ' + + cityssm.escapeHTML(exports.aliases.lot) + + ")") + + "
" + + ('' + + cityssm.escapeHTML(lotOccupancy.mapName || "") + + "") + + "") + + ("" + lotOccupancy.occupancyStartDateString + "") + + ("" + + (lotOccupancy.occupancyEndDate + ? lotOccupancy.occupancyEndDateString + : '(No End Date)') + + "") + + ("" + occupantsHTML + "") + + "" + + (lotOccupancy.printEJS + ? '' + + '' + + "" + : "") + + "" + + ""); + } + searchResultsContainerElement.innerHTML = + '' + + "" + + '' + + ("") + + ("") + + ("") + + "" + + ("") + + '' + + "" + + "
" + cityssm.escapeHTML(exports.aliases.occupancy) + " Type" + cityssm.escapeHTML(exports.aliases.lot) + "" + cityssm.escapeHTML(exports.aliases.occupancyStartDate) + "End Date" + cityssm.escapeHTML(exports.aliases.occupants) + "Print
" + + '
' + + ('
' + + '
' + + "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", previousAndGetLotOccupancies); + } + if (limit + responseJSON.offset < responseJSON.count) { + searchResultsContainerElement.querySelector("button[data-page='next']").addEventListener("click", nextAndGetLotOccupancies); + } + } + function getLotOccupancies() { searchResultsContainerElement.innerHTML = '
' + '
' + @@ -16,178 +174,20 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.aliases.occupancies + "..." + "
"; - cityssm.postJSON(los.urlPrefix + "/lotOccupancies/doSearchLotOccupancies", searchFilterFormElement, (responseJSON) => { - if (responseJSON.lotOccupancies.length === 0) { - searchResultsContainerElement.innerHTML = - '
' + - '

There are no ' + - cityssm.escapeHTML(exports.aliases.occupancy.toLowerCase()) + - " records that meet the search criteria.

" + - "
"; - return; - } - const resultsTbodyElement = document.createElement("tbody"); - const nowDateString = cityssm.dateToString(new Date()); - for (const lotOccupancy of responseJSON.lotOccupancies) { - let occupancyTimeHTML = ""; - if (lotOccupancy.occupancyStartDateString <= nowDateString && - (lotOccupancy.occupancyEndDateString === "" || - lotOccupancy.occupancyEndDateString >= nowDateString)) { - occupancyTimeHTML = - '' + - ('') + - ""; - } - else if (lotOccupancy.occupancyStartDateString > nowDateString) { - occupancyTimeHTML = - '' + - ('') + - ""; - } - else { - occupancyTimeHTML = - '' + - ('') + - ""; - } - let occupantsHTML = ""; - for (const occupant of lotOccupancy.lotOccupancyOccupants) { - occupantsHTML += - '' + - (' ') + - cityssm.escapeHTML(occupant.occupantName || "") + - "
"; - } - resultsTbodyElement.insertAdjacentHTML("beforeend", "" + - ('") + - ("") + - ("") + - ("") + - ("") + - ("") + - "" + - ""); - } - searchResultsContainerElement.innerHTML = - '
' + occupancyTimeHTML + "" + - '' + - cityssm.escapeHTML(lotOccupancy.occupancyType) + - "" + - "" + - (lotOccupancy.lotName - ? '' + - cityssm.escapeHTML(lotOccupancy.lotName) + - "" - : '(No ' + - cityssm.escapeHTML(exports.aliases.lot) + - ")") + - "
" + - ('' + - cityssm.escapeHTML(lotOccupancy.mapName || "") + - "") + - "
" + lotOccupancy.occupancyStartDateString + "" + - (lotOccupancy.occupancyEndDate - ? lotOccupancy.occupancyEndDateString - : '(No End Date)') + - "" + occupantsHTML + "" + - (lotOccupancy.printEJS - ? '' + - '' + - "" - : "") + - "
' + - "" + - '' + - ("") + - ("") + - ("") + - "" + - ("") + - '' + - "" + - "
" + cityssm.escapeHTML(exports.aliases.occupancy) + " Type" + cityssm.escapeHTML(exports.aliases.lot) + "" + cityssm.escapeHTML(exports.aliases.occupancyStartDate) + "End Date" + cityssm.escapeHTML(exports.aliases.occupants) + "Print
" + - '
' + - ('
' + - '
' + - "Displaying " + - (offset + 1).toString() + - " to " + - Math.min(responseJSON.count, limit + offset) + - " of " + - responseJSON.count + - "
" + - "
") + - ('
' + - (offset > 0 - ? '
' + - '" + - "
" - : "") + - (limit + offset < responseJSON.count - ? '
' + - '" + - "
" - : "") + - "
") + - "
"; - searchResultsContainerElement.querySelector("table").append(resultsTbodyElement); - if (offset > 0) { - searchResultsContainerElement.querySelector("button[data-page='previous']").addEventListener("click", previousAndGetLotOccupancies); - } - if (limit + offset < responseJSON.count) { - searchResultsContainerElement.querySelector("button[data-page='next']").addEventListener("click", nextAndGetLotOccupancies); - } - }); - }; - const resetOffsetAndGetLotOccupancies = () => { + cityssm.postJSON(los.urlPrefix + "/lotOccupancies/doSearchLotOccupancies", searchFilterFormElement, renderLotOccupancies); + } + function resetOffsetAndGetLotOccupancies() { offsetElement.value = "0"; getLotOccupancies(); - }; - const previousAndGetLotOccupancies = () => { + } + function previousAndGetLotOccupancies() { offsetElement.value = Math.max(Number.parseInt(offsetElement.value, 10) - limit, 0).toString(); getLotOccupancies(); - }; - const nextAndGetLotOccupancies = () => { + } + function nextAndGetLotOccupancies() { offsetElement.value = (Number.parseInt(offsetElement.value, 10) + limit).toString(); getLotOccupancies(); - }; + } const filterElements = searchFilterFormElement.querySelectorAll("input, select"); for (const filterElement of filterElements) { filterElement.addEventListener("change", resetOffsetAndGetLotOccupancies); diff --git a/public-typescript/lotOccupancySearch.ts b/public-typescript/lotOccupancySearch.ts index 356cc8df..9311da53 100644 --- a/public-typescript/lotOccupancySearch.ts +++ b/public-typescript/lotOccupancySearch.ts @@ -24,9 +24,194 @@ declare const cityssm: cityssmGlobal; ); const offsetElement = document.querySelector("#searchFilter--offset") as HTMLInputElement; - const getLotOccupancies = () => { - const offset = Number.parseInt(offsetElement.value, 10); + function renderLotOccupancies(responseJSON: { + count: number; + offset: number; + lotOccupancies: recordTypes.LotOccupancy[]; + }) { + if (responseJSON.lotOccupancies.length === 0) { + searchResultsContainerElement.innerHTML = + '
' + + '

There are no ' + + cityssm.escapeHTML(exports.aliases.occupancy.toLowerCase()) + + " records that meet the search criteria.

" + + "
"; + return; + } + + const resultsTbodyElement = document.createElement("tbody"); + + const nowDateString = cityssm.dateToString(new Date()); + + for (const lotOccupancy of responseJSON.lotOccupancies) { + let occupancyTimeHTML = ""; + + if ( + lotOccupancy.occupancyStartDateString! <= nowDateString && + (lotOccupancy.occupancyEndDateString === "" || + lotOccupancy.occupancyEndDateString! >= nowDateString) + ) { + occupancyTimeHTML = + '' + + ('') + + ""; + } else if (lotOccupancy.occupancyStartDateString! > nowDateString) { + occupancyTimeHTML = + '' + + ('') + + ""; + } else { + occupancyTimeHTML = + '' + + ('') + + ""; + } + + let occupantsHTML = ""; + + for (const occupant of lotOccupancy.lotOccupancyOccupants!) { + occupantsHTML += + '' + + (' ') + + cityssm.escapeHTML(occupant.occupantName || "") + + "
"; + } + + resultsTbodyElement.insertAdjacentHTML( + "beforeend", + "" + + ('") + + ("") + + ("") + + ("") + + ("") + + ("") + + "" + + "" + ); + } + + searchResultsContainerElement.innerHTML = + '
' + occupancyTimeHTML + "" + + '' + + cityssm.escapeHTML(lotOccupancy.occupancyType as string) + + "" + + "" + + (lotOccupancy.lotName + ? '' + + cityssm.escapeHTML(lotOccupancy.lotName) + + "" + : '(No ' + + cityssm.escapeHTML(exports.aliases.lot) + + ")") + + "
" + + ('' + + cityssm.escapeHTML(lotOccupancy.mapName || "") + + "") + + "
" + lotOccupancy.occupancyStartDateString + "" + + (lotOccupancy.occupancyEndDate + ? lotOccupancy.occupancyEndDateString + : '(No End Date)') + + "" + occupantsHTML + "" + + (lotOccupancy.printEJS + ? '' + + '' + + "" + : "") + + "
' + + "" + + '' + + ("") + + ("") + + ("") + + "" + + ("") + + '' + + "" + + "
" + cityssm.escapeHTML(exports.aliases.occupancy) + " Type" + cityssm.escapeHTML(exports.aliases.lot) + "" + cityssm.escapeHTML(exports.aliases.occupancyStartDate) + "End Date" + cityssm.escapeHTML(exports.aliases.occupants) + "Print
" + + '
' + + ('
' + + '
' + + "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']" + ) as HTMLButtonElement + ).addEventListener("click", previousAndGetLotOccupancies); + } + + if (limit + responseJSON.offset < responseJSON.count) { + ( + searchResultsContainerElement.querySelector( + "button[data-page='next']" + ) as HTMLButtonElement + ).addEventListener("click", nextAndGetLotOccupancies); + } + } + + function getLotOccupancies() { searchResultsContainerElement.innerHTML = '
' + '
' + @@ -38,208 +223,27 @@ declare const cityssm: cityssmGlobal; cityssm.postJSON( los.urlPrefix + "/lotOccupancies/doSearchLotOccupancies", searchFilterFormElement, - (responseJSON: { count: number; lotOccupancies: recordTypes.LotOccupancy[] }) => { - if (responseJSON.lotOccupancies.length === 0) { - searchResultsContainerElement.innerHTML = - '
' + - '

There are no ' + - cityssm.escapeHTML(exports.aliases.occupancy.toLowerCase()) + - " records that meet the search criteria.

" + - "
"; - - return; - } - - const resultsTbodyElement = document.createElement("tbody"); - - const nowDateString = cityssm.dateToString(new Date()); - - for (const lotOccupancy of responseJSON.lotOccupancies) { - let occupancyTimeHTML = ""; - - if ( - lotOccupancy.occupancyStartDateString! <= nowDateString && - (lotOccupancy.occupancyEndDateString === "" || - lotOccupancy.occupancyEndDateString! >= nowDateString) - ) { - occupancyTimeHTML = - '' + - ('') + - ""; - } else if (lotOccupancy.occupancyStartDateString! > nowDateString) { - occupancyTimeHTML = - '' + - ('') + - ""; - } else { - occupancyTimeHTML = - '' + - ('') + - ""; - } - - let occupantsHTML = ""; - - for (const occupant of lotOccupancy.lotOccupancyOccupants!) { - occupantsHTML += - '' + - (' ') + - cityssm.escapeHTML(occupant.occupantName || "") + - "
"; - } - - resultsTbodyElement.insertAdjacentHTML( - "beforeend", - "
" + - ('") + - ("") + - ("") + - ("") + - ("") + - ("") + - "" + - "" - ); - } - - searchResultsContainerElement.innerHTML = - '
' + occupancyTimeHTML + "" + - '' + - cityssm.escapeHTML(lotOccupancy.occupancyType as string) + - "" + - "" + - (lotOccupancy.lotName - ? '' + - cityssm.escapeHTML(lotOccupancy.lotName) + - "" - : '(No ' + - cityssm.escapeHTML(exports.aliases.lot) + - ")") + - "
" + - ('' + - cityssm.escapeHTML(lotOccupancy.mapName || "") + - "") + - "
" + lotOccupancy.occupancyStartDateString + "" + - (lotOccupancy.occupancyEndDate - ? lotOccupancy.occupancyEndDateString - : '(No End Date)') + - "" + occupantsHTML + "" + - (lotOccupancy.printEJS - ? '' + - '' + - "" - : "") + - "
' + - "" + - '' + - ("") + - ("") + - ("") + - "" + - ("") + - '' + - "" + - "
" + cityssm.escapeHTML(exports.aliases.occupancy) + " Type" + cityssm.escapeHTML(exports.aliases.lot) + "" + cityssm.escapeHTML(exports.aliases.occupancyStartDate) + "End Date" + cityssm.escapeHTML(exports.aliases.occupants) + "Print
" + - '
' + - ('
' + - '
' + - "Displaying " + - (offset + 1).toString() + - " to " + - Math.min(responseJSON.count, limit + offset) + - " of " + - responseJSON.count + - "
" + - "
") + - ('
' + - (offset > 0 - ? '
' + - '" + - "
" - : "") + - (limit + offset < responseJSON.count - ? '
' + - '" + - "
" - : "") + - "
") + - "
"; - - searchResultsContainerElement.querySelector("table")!.append(resultsTbodyElement); - - if (offset > 0) { - ( - searchResultsContainerElement.querySelector( - "button[data-page='previous']" - ) as HTMLButtonElement - ).addEventListener("click", previousAndGetLotOccupancies); - } - - if (limit + offset < responseJSON.count) { - ( - searchResultsContainerElement.querySelector( - "button[data-page='next']" - ) as HTMLButtonElement - ).addEventListener("click", nextAndGetLotOccupancies); - } - } + renderLotOccupancies ); - }; + } - const resetOffsetAndGetLotOccupancies = () => { + function resetOffsetAndGetLotOccupancies() { offsetElement.value = "0"; getLotOccupancies(); - }; + } - const previousAndGetLotOccupancies = () => { + function previousAndGetLotOccupancies() { offsetElement.value = Math.max( Number.parseInt(offsetElement.value, 10) - limit, 0 ).toString(); getLotOccupancies(); - }; + } - const nextAndGetLotOccupancies = () => { + function nextAndGetLotOccupancies() { offsetElement.value = (Number.parseInt(offsetElement.value, 10) + limit).toString(); getLotOccupancies(); - }; + } const filterElements = searchFilterFormElement.querySelectorAll("input, select") as NodeListOf< HTMLInputElement | HTMLSelectElement diff --git a/public/javascripts/lotOccupancySearch.min.js b/public/javascripts/lotOccupancySearch.min.js index 6564b9b6..85fe67c7 100644 --- a/public/javascripts/lotOccupancySearch.min.js +++ b/public/javascripts/lotOccupancySearch.min.js @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{const t=exports.los,a=document.querySelector("#form--searchFilters"),e=document.querySelector("#container--searchResults"),s=Number.parseInt(document.querySelector("#searchFilter--limit").value,10),c=document.querySelector("#searchFilter--offset"),i=()=>{const i=Number.parseInt(c.value,10);e.innerHTML='

Loading '+exports.aliases.occupancies+"...
",cityssm.postJSON(t.urlPrefix+"/lotOccupancies/doSearchLotOccupancies",a,a=>{if(0===a.lotOccupancies.length)return void(e.innerHTML='

There are no '+cityssm.escapeHTML(exports.aliases.occupancy.toLowerCase())+" records that meet the search criteria.

");const c=document.createElement("tbody"),r=cityssm.dateToString(new Date);for(const e of a.lotOccupancies){let a="";a=e.occupancyStartDateString<=r&&(""===e.occupancyEndDateString||e.occupancyEndDateString>=r)?'':e.occupancyStartDateString>r?'':'';let s="";for(const t of e.lotOccupancyOccupants)s+=' '+cityssm.escapeHTML(t.occupantName||"")+"
";c.insertAdjacentHTML("beforeend",'")}e.innerHTML='
'+a+''+cityssm.escapeHTML(e.occupancyType)+""+(e.lotName?''+cityssm.escapeHTML(e.lotName)+"":'(No '+cityssm.escapeHTML(exports.aliases.lot)+")")+'
'+cityssm.escapeHTML(e.mapName||"")+"
"+e.occupancyStartDateString+""+(e.occupancyEndDate?e.occupancyEndDateString:'(No End Date)')+""+s+""+(e.printEJS?'':"")+"
'+cityssm.escapeHTML(exports.aliases.occupancy)+" Type"+cityssm.escapeHTML(exports.aliases.lot)+""+cityssm.escapeHTML(exports.aliases.occupancyStartDate)+"End Date"+cityssm.escapeHTML(exports.aliases.occupants)+'Print
Displaying '+(i+1).toString()+" to "+Math.min(a.count,s+i)+" of "+a.count+'
'+(i>0?'
':"")+(s+i
':"")+"
",e.querySelector("table").append(c),i>0&&e.querySelector("button[data-page='previous']").addEventListener("click",o),s+i{c.value="0",i()},o=()=>{c.value=Math.max(Number.parseInt(c.value,10)-s,0).toString(),i()},n=()=>{c.value=(Number.parseInt(c.value,10)+s).toString(),i()},l=a.querySelectorAll("input, select");for(const t of l)t.addEventListener("change",r);a.addEventListener("submit",t=>{t.preventDefault(),r()}),i()})(); \ No newline at end of file +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{const t=exports.los,e=document.querySelector("#form--searchFilters"),a=document.querySelector("#container--searchResults"),s=Number.parseInt(document.querySelector("#searchFilter--limit").value,10),c=document.querySelector("#searchFilter--offset");function i(e){if(0===e.lotOccupancies.length)return void(a.innerHTML='

There are no '+cityssm.escapeHTML(exports.aliases.occupancy.toLowerCase())+" records that meet the search criteria.

");const c=document.createElement("tbody"),i=cityssm.dateToString(new Date);for(const a of e.lotOccupancies){let e="";e=a.occupancyStartDateString<=i&&(""===a.occupancyEndDateString||a.occupancyEndDateString>=i)?'':a.occupancyStartDateString>i?'':'';let s="";for(const t of a.lotOccupancyOccupants)s+=' '+cityssm.escapeHTML(t.occupantName||"")+"
";c.insertAdjacentHTML("beforeend",'
")}a.innerHTML='
'+e+''+cityssm.escapeHTML(a.occupancyType)+""+(a.lotName?''+cityssm.escapeHTML(a.lotName)+"":'(No '+cityssm.escapeHTML(exports.aliases.lot)+")")+'
'+cityssm.escapeHTML(a.mapName||"")+"
"+a.occupancyStartDateString+""+(a.occupancyEndDate?a.occupancyEndDateString:'(No End Date)')+""+s+""+(a.printEJS?'':"")+"
'+cityssm.escapeHTML(exports.aliases.occupancy)+" Type"+cityssm.escapeHTML(exports.aliases.lot)+""+cityssm.escapeHTML(exports.aliases.occupancyStartDate)+"End Date"+cityssm.escapeHTML(exports.aliases.occupants)+'Print
Displaying '+(e.offset+1).toString()+" to "+Math.min(e.count,s+e.offset)+" of "+e.count+'
'+(e.offset>0?'
':"")+(s+e.offset
':"")+"
",a.querySelector("table").append(c),e.offset>0&&a.querySelector("button[data-page='previous']").addEventListener("click",r),s+e.offset",cityssm.postJSON(t.urlPrefix+"/lotOccupancies/doSearchLotOccupancies",e,i)}function n(){c.value="0",o()}function r(){c.value=Math.max(Number.parseInt(c.value,10)-s,0).toString(),o()}function l(){c.value=(Number.parseInt(c.value,10)+s).toString(),o()}const p=e.querySelectorAll("input, select");for(const t of p)t.addEventListener("change",n);e.addEventListener("submit",t=>{t.preventDefault(),n()}),o()})(); \ No newline at end of file