PageSourceSearch

https://www.highpointmarket.org/js/exhibitor.js?v=ZJhCrqr6SNVhlrOfWqYfPhHV1rs2Mi2kK5O1Lnf74cM

js highpointmarket.org collected 2026-09-24 08:56:29 UTC 14,015 bytes, 312 lines download raw bytes

1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4    return new (P || (P = Promise))(function (resolve, reject) {
5        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8        step((generator = generator.apply(thisArg, _arguments || [])).next());
9    });
10};
11var hpmkt;
12(function (hpmkt) {
13    // Attribute used to hold FilterItem as a JSON string
14    const DATA_ATTRIBUTE_FILTER = "data-filter";
15    // IDs for form elements
16    const ID_FORM_FILTERS = "form-filters";
17    const ID_FORM_FILTERS_INPUTS = "form-filters-inputs";
18    const ID_FORM_FILTERS_TAGS = "form-filters-tags";
19    const ID_DIV_AVAILABLE_FILTERS = "available-filters";
20    const ID_DIV_ALPHA_FILTER_CONTAINER = "alpha-filter-container";
21    const ID_DIV_REMOVE_ALPHA_FILTER = "removeAlphaFilter";
22    const FORM_NAME_FILTERS = "filters";
23    let ExhibitorFilterType;
24    (function (ExhibitorFilterType) {
25        ExhibitorFilterType[ExhibitorFilterType["Categories"] = 1] = "Categories";
26        ExhibitorFilterType[ExhibitorFilterType["Style"] = 2] = "Style";
27        ExhibitorFilterType[ExhibitorFilterType["PricePoint"] = 3] = "PricePoint";
28        ExhibitorFilterType[ExhibitorFilterType["Options"] = 4] = "Options";
29        ExhibitorFilterType[ExhibitorFilterType["Buildings"] = 5] = "Buildings";
30        ExhibitorFilterType[ExhibitorFilterType["Areas"] = 6] = "Areas";
31        ExhibitorFilterType[ExhibitorFilterType["Neighborhoods"] = 7] = "Neighborhoods";
32        ExhibitorFilterType[ExhibitorFilterType["Country"] = 8] = "Country";
33        ExhibitorFilterType[ExhibitorFilterType["Alpha"] = 10] = "Alpha";
34    })(ExhibitorFilterType || (ExhibitorFilterType = {}));
35    class FilterItem {
36        constructor(type, values) {
37            this.Type = type;
38            this.Values = values;
39        }
40        /**
41         * Creates a new FilterItem from a JSON string
42         * @param json
43         * @returns
44         */
45        static fromJson(json) {
46            const jsonObj = JSON.parse(json);
47            return new FilterItem(jsonObj.Type, jsonObj.Values);
48        }
49        /**
50         * Determines if other filter has the same Type and Values as this filter
51         * @param other
52         * @returns
53         */
54        isEqual(other) {
55            if (other.Type !== this.Type)
56                return false;
57            if (other.Values.length !== this.Values.length)
58                return false;
59            for (let i = 0; i < other.Values.length; i++) {
60                if (other.Values[i] !== this.Values[i])
61                    return false;
62            }
63            return true;
64        }
65        /**
66         * Returns the display text: type and values
67         * @returns
68         */
69        getDisplayText() {
70            return this.Type.toString() + ': ' + this.Values.join(' - ');
71        }
72    }
73    /**
74     * Gets the filter form used to hold filter inputs and dislay tags
75     * @returns
76     */
77    const getFilterForm = () => { var _a; return (_a = document.getElementById(ID_FORM_FILTERS)) !== null && _a !== void 0 ? _a : (() => { throw new Error("Cannot find filter form"); })(); };
78    ;
79    function getFormChildContainerById(form, id) {
80        const container = form.querySelector(`#${id}`);
81        if (container === null)
82            throw new Error(`Form container with ID #${id} not found`);
83        return container;
84    }
85    function getFormChildUlById(form, id) {
86        const ul = form.querySelector(`ul#${id}`);
87        if (ul === null)
88            throw new Error(`Form UL with ID #${id} not found`);
89        return ul;
90    }
91    /**
92     * Finds an HtmlElement that is a child of a LI element where the child's
93     * data attribute JSON matches the data for the supplied filterItem
94     * @param ul List to search on
95     * @param filterItem The FilterItem to search for
96     * @returns The child HTMLElement item or null if no match is found
97     */
98    function findFilterFormListItem(ul, filterItem) {
99        var _a;
100        const liCollection = ul.getElementsByTagName("li");
101        if (liCollection === null || liCollection.length === 0)
102            return null;
103        const lis = Array.from(liCollection);
104        let li;
105        for (li of liCollection) {
106            let firstChild = li.firstChild;
107            if (firstChild !== null) {
108                let firstChildElement = firstChild;
109                let filterJson = (_a = firstChildElement.getAttribute(DATA_ATTRIBUTE_FILTER)) !== null && _a !== void 0 ? _a : (() => { throw new Error(`data-filter is null on '${li.innerText}'`); })();
110                let filter = FilterItem.fromJson(filterJson);
111                if (filterItem.isEqual(filter)) {
112                    return firstChildElement;
113                }
114            }
115        }
116        return null;
117    }
118    /**
119     * Creates the display tags. First clears all tags and
120     * then rebuilds them based on the hidden inputs
121     */
122    function createFilterTagsFromInputs() {
123        const form = getFilterForm();
124        const ulInputs = getFormChildUlById(form, ID_FORM_FILTERS_INPUTS);
125        const ulTags = getFormChildUlById(form, ID_FORM_FILTERS_TAGS);
126        ulTags.innerHTML = '';
127        const inputCollection = ulInputs.getElementsByTagName("input");
128        let input;
129        for (input of inputCollection) {
130            let filterJson = input.getAttribute(DATA_ATTRIBUTE_FILTER);
131            if (filterJson === null)
132                continue;
133            let filter = FilterItem.fromJson(filterJson);
134            let tag = document.createElement('a');
135            tag.setAttribute(DATA_ATTRIBUTE_FILTER, filterJson);
136            tag.innerText = filter.getDisplayText();
137            tag.classList.add('single-filter-remove');
138            let li = document.createElement('li');
139            li.appendChild(tag);
140            ulTags.appendChild(li);
141        }
142    }
143    /**
144     * Adds a filter, if it does not already exist.
145     * @param anchor An anchor tag which has JSON filter data
146     */
147    function addFilter(anchor) {
148        var _a;
149        const filterJson = (_a = anchor.getAttribute(DATA_ATTRIBUTE_FILTER)) !== null && _a !== void 0 ? _a : (() => { throw new Error(`data-filter is null on '${anchor.href}'`); })();
150        const filterItem = FilterItem.fromJson(filterJson);
151        //Alpha filters only show one at a time
152        if (filterItem.Type.toString() == ExhibitorFilterType[ExhibitorFilterType.Alpha]) {
153            removeAlphaFilters();
154        }
155        const form = getFilterForm();
156        const ul = getFormChildUlById(form, ID_FORM_FILTERS_INPUTS);
157        // Add filter as hidden input if it does not already exist
158        let input = findFilterFormListItem(ul, filterItem);
159        if (input === null) {
160            input = document.createElement("input");
161            input.name = FORM_NAME_FILTERS;
162            input.type = "hidden";
163            input.setAttribute(DATA_ATTRIBUTE_FILTER, filterJson);
164            input.value = filterJson;
165            const li = document.createElement("li");
166            li.appendChild(input);
167            ul.appendChild(li);
168        }
169        createFilterTagsFromInputs();
170        form.submit();
171    }
172    function removeFilter(filterDiv) {
173        var _a;
174        // Get JSON from data attribute
175        const filterJson = (_a = filterDiv.getAttribute(DATA_ATTRIBUTE_FILTER)) !== null && _a !== void 0 ? _a : (() => { throw new Error(`data-filter is null on filter element'`); })();
176        const filterItem = FilterItem.fromJson(filterJson);
177        // Remove matching attribute from inputs
178        const form = getFilterForm();
179        const ul = getFormChildUlById(form, ID_FORM_FILTERS_INPUTS);
180        let input = findFilterFormListItem(ul, filterItem);
181        if (input !== null) {
182            input.remove();
183        }
184        //createFilterTagsFromInputs();
185        form.submit();
186    }
187    function removeAlphaFilters() {
188        // Remove matching attribute from inputs
189        const form = getFilterForm();
190        const ul = getFormChildUlById(form, ID_FORM_FILTERS_INPUTS);
191        let inputs = ul.querySelectorAll("li input");
192        let hasRemovedInput = false;
193        inputs.forEach(input => {
194            var _a;
195            const filterJson = (_a = input.getAttribute(DATA_ATTRIBUTE_FILTER)) !== null && _a !== void 0 ? _a : "";
196            if (filterJson !== "") {
197                const filterItem = FilterItem.fromJson(filterJson);
198                if (filterItem.Type.toString() == ExhibitorFilterType[ExhibitorFilterType.Alpha]) {
199                    input.remove();
200                    hasRemovedInput = true;
201                }
202            }
203        });
204        if (hasRemovedInput)
205            form.submit();
206    }
207    function getExhibFilterValuesForPost() {
208        var _a;
209        let filterString = "";
210        const form = getFilterForm();
211        const ul = getFormChildUlById(form, ID_FORM_FILTERS_INPUTS);
212        const liCollection = ul.getElementsByTagName("li");
213        if (!(liCollection === null || liCollection.length === 0)) {
214            let li;
215            filterString += "[";
216            let index = 1;
217            for (li of liCollection) {
218                let firstChild = li.firstChild;
219                if (firstChild !== null) {
220                    let firstChildElement = firstChild;
221                    const elAttr = (_a = firstChildElement.getAttribute(DATA_ATTRIBUTE_FILTER)) !== null && _a !== void 0 ? _a : "";
222                    if (elAttr.length > 0) {
223                        filterString += elAttr.replace("[", "").replace("]", "");
224                    }
225                }
226                if (index !== liCollection.length) {
227                    filterString += ",";
228                }
229                index++;
230            }
231            filterString += "]";
232        }
233        ;
234        return filterString;
235    }
236    hpmkt.getExhibFilterValuesForPost = getExhibFilterValuesForPost;
237    let PAGINATION_URL_APPEND;
238    /**
239     * Set PAGINATION_URL_APPEND variable for Exhibitor page filters
240     */
241    function setPaginationAppend() {
242        let filterString = "";
243        var params = location.search.substr(1).split('&');
244        for (var i = 0; i < params.length; i++) {
245            var temp = params[i].split('='), key = temp[0], val = temp[1];
246            if (key === "filters")
247                filterString += "&filters=" + val;
248        }
249        PAGINATION_URL_APPEND = filterString;
250    }
251    /**
252     * Get URL for Exhibitor page
253     * @param pageIndex Current page
254     * @returns URL string
255     */
256    function getExhibitorDirectoryUrl(pageIndex) {
257        return '/exhibitordirectory?pageindex=' + pageIndex.toString() + PAGINATION_URL_APPEND;
258    }
259    /**
260     * Executes all methods for populating pagination controls
261     */
262    function populateExhibitorsPaginationControls() {
263        return __awaiter(this, void 0, void 0, function* () {
264            setPaginationAppend();
265            const pagingDiv = document.querySelector('#Exhibitors .pagination');
266            const onClickCallback = (pageIndex) => {
267                return getExhibitorDirectoryUrl(pageIndex);
268            };
269            hpmkt.renderPagingByValues(pagingDiv, PAGINATION_CURRENT_INDEX, PAGINATION_TOTAL, onClickCallback);
270        });
271    }
272    //#endregion
273    function initExhibitors() {
274        const availableFilters = document.getElementById(ID_DIV_AVAILABLE_FILTERS);
275        if (availableFilters === null)
276            throw new Error(`Filters container #${ID_DIV_AVAILABLE_FILTERS} not found`);
277        let nodes = Array.prototype.slice.call(availableFilters.querySelectorAll('a[data-filter]'));
278        const alphaFilters = document.getElementById(ID_DIV_ALPHA_FILTER_CONTAINER);
279        if (alphaFilters === null)
280            throw new Error(`Filters container #${ID_DIV_ALPHA_FILTER_CONTAINER} not found`);
281        nodes = nodes.concat(Array.prototype.slice.call(alphaFilters.querySelectorAll('a:not(#' + ID_DIV_REMOVE_ALPHA_FILTER + ')')));
282        if (nodes.length === 0)
283            console.debug("No filters found");
284        // Wire up click event and prevent navigation
285        nodes.forEach(element => {
286            let anchor = element;
287            anchor.addEventListener("click", function (event) {
288                event.preventDefault();
289                addFilter(event.target);
290            });
291        });
292        createFilterTagsFromInputs();
293        const currentFilters = document.getElementById(ID_FORM_FILTERS_TAGS);
294        if (currentFilters === null)
295            throw new Error(`Filters container #${ID_FORM_FILTERS_TAGS} not found`);
296        const removeNodes = currentFilters.querySelectorAll('li a');
297        removeNodes.forEach(element => {
298            let el = element;
299            el.addEventListener("click", function (event) {
300                removeFilter(event.target);
301                event.preventDefault();
302            });
303        });
304        const removeAlpha = document.getElementById(ID_DIV_REMOVE_ALPHA_FILTER);
305        if (removeAlpha === null)
306            throw new Error(`Remove All Alpha Filter button not found`);
307        removeAlpha.addEventListener("click", removeAlphaFilters);
308        populateExhibitorsPaginationControls();
309    }
310    initExhibitors();
311})(hpmkt || (hpmkt = {}));
312//# sourceMappingURL=exhibitor.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.