` ); } }); }; const updateInterests = (root, interests = []) => { root.find('#filters-form .interests-group .interests input').toArray().forEach(e => { const jQe = $(e); jQe.prop('checked', interests.indexOf(jQe.val()) !== -1); }); }; const updateSortOrder = (root, sortOrder = 'none') => { root.find('.current-sort-order').html(sortOrder); }; const updateDealCount = (root, count = 0) => { root.find('.deal-count').html(count); }; const renderFreeText = (root, freeText) => { const freeTextPlh = root.find('#list-header-root .free-text'); freeTextPlh.empty(); let tpl = freeText !== '' ? `Trips to ${freeText} ` : 'All Packages'; freeTextPlh.html(tpl); }; const getDeals = (root, form, extraParams = {}) => { const placeholders = root.find('#placeholders-root'); const deals = root.find('#deals-root'); const listHeader = root.find('#list-header-root'); deals.hide(); placeholders.show(); // Prepare parameters for ajax call. const formParams = stringToParams(form.serialize()); formParams['ref'] = 'Deals Search Results'; const mergedParams = $.extend({}, formParams, extraParams); let updatedParams = paramsToString(mergedParams); // Update url parameters. history.replaceState(null, null, `?${updatedParams}`); $.ajax({ url: '/en-us/ajax/fetchdeals', data: updatedParams, method: 'get', dataType: 'html' }).done((response) => { placeholders.hide(); deals.show() .html(response) .find('.lazy-load').unveil(200); deals.find('.owl-carousel', '.load-carousel').each((_, elm) => { const jqElm = $(elm); var owlCarousel = jqElm.owlCarousel({ items: 1, lazyLoad: true, dots: true }); }); initializeDealSave("en-us"); initializeDealLike("en-us"); initializeSMShare(); initShowDealFinePrint(); if(typeof gtmDataLayer !== "undefined"){ setDataLayerEvents(); } }); }; const getAirportSuggestions = term => { const { from } = rxjs; var promise = $.ajax({ url: '/en-us/ajax/getavailableairports', dataType: 'json', data: {query: term} }).promise(); return from(promise); }; const renderAirportSuggestions = suggestions => { if(suggestions.length) { return suggestions.reduce((acc, sug) => { const airportCode = Object.keys(sug)[0]; const airportName = sug[airportCode]; acc = acc.concat( `