PageSourceSearch

https://www.letsengage.com/js/searchPage.js

js letsengage.com collected 2026-09-25 04:31:20 UTC 18,429 bytes, 564 lines download raw bytes

1const virtualPricing  = ['$3k - $7.5k','$7.5k - $15k','$15k - $25k','$25k - $50k','$50k'];
2const inpersonPricing = ['$5k - $10k','$10k - $20k','$20k - $35k','$35k - $50k','$50k'];
3// Determine which is active on load
4let activeOption = $('.in-person-btn li.active').attr('data-name') || 'virtual';
5
6// Populate pricing dropdown based on active option
7function populatePricingOptions() {
8    console.log(activeOption)
9    const pricingArray = (activeOption === 'inperson') ? inpersonPricing : virtualPricing;
10    const $select = $('#speaking_fee');
11    $select.empty(); // Clear previous options
12    pricingArray.forEach(function(item,index) {
13        $select.append(`<option value="${index +1 }">${item}</option>`);
14    });
15
16    $select.multiselect('rebuild'); // Rebuild multiselect options
17}
18
19populatePricingOptions(); // Initial population
20
21// Initialize multiselects
22$('#categories,#categories_sub').multiselect({
23    nonSelectedText: 'Select Category',
24    enableFiltering: true,
25    enableCaseInsensitiveFiltering: true,
26    onDropdownShown: function(event) {
27        // Focus the search box when dropdown is opened
28        $(event.target).closest('.btn-group').find('.multiselect-search').focus();
29    }
30});
31$('#speaking_fee,#pricing_fee').multiselect({
32    nonSelectedText: 'Select Pricing'
33});
34
35var selectedPricing = $("#hidden-price-filter").val();
36console.log(selectedPricing);
37try {
38    selectedPricing = JSON.parse(selectedPricing); // Parse the string to array
39} catch (e) {
40    selectedPricing = []; // fallback in case of parse error
41}
42
43if (selectedPricing && Array.isArray(selectedPricing)) {
44    selectedPricing.forEach(function (val) {
45        $('#speaking_fee option[value="' + val + '"], #pricing_fee option[value="' + val + '"]').prop('selected', true);
46    });
47
48    $('#speaking_fee, #pricing_fee').multiselect('refresh');
49}
50
51// Handle click on virtual/in-person toggle
52$(document).on('click', '.in-person-btn li', function () {
53    $('.in-person-btn li').removeClass('active');
54    $(this).addClass('active');
55    activeOption = $(this).attr('data-name');
56    populatePricingOptions(); // Refresh options based on selection
57    handleEventTypeChange(activeOption);
58});
59
60$(document).on('click', '.category-input-field', function (e) {
61    e.preventDefault();
62    var classList = $(this).attr('class');
63    console.log(classList);
64
65    // Determine the target
66    var $target = classList.includes('bottom-advanced-search-section') ?
67        $('.bottom-advnaced-search-category-section') :
68        $('.talent-page-category-section');
69
70    // Toggle visibility
71    if ($target.hasClass("active")) {
72        $target.removeClass("active").hide();
73    } else {
74        $target.addClass("active").show();
75    }
76
77    // Stop propagation so this click doesn't trigger the document click
78    e.stopPropagation();
79});
80
81// Hide when clicking outside
82$(document).on('click', function (e) {
83    // Check if click is outside the input and target section
84    if (!$(e.target).closest('.category-input-field, .bottom-advnaced-search-category-section, .talent-page-category-section').length) {
85        $('.bottom-advnaced-search-category-section, .talent-page-category-section').removeClass("active").hide();
86    }
87});
88
89// Click handler for Speaking Fee multiselect button
90$(document).on('click', '#speaking_fee + .btn-group .multiselect', function () {
91    console.log('speaking_fee clicked');
92    var $target = $(".talent-page-category-section");
93    if ($target.hasClass("active")) {
94        $target.removeClass("active").hide();
95    } 
96});
97
98// Click handler for Pricing Fee multiselect button
99$(document).on('click', '#pricing_fee + .btn-group .multiselect', function () {
100    console.log('pricing_fee clicked');
101    var $target = $(".bottom-advnaced-search-category-section");
102    if ($target.hasClass("active")) {
103        $target.removeClass("active").hide();
104    }
105});
106$(document).on('change', '#categories, #categories_sub, #pricing_fee, #speaking_fee', function () {
107    const $this = $(this);
108    const selectedOptions = $this.find('option:selected');
109    const selectedValues = {};
110    const source = $this.attr('id');
111
112    // Collect selected option values and names
113    selectedOptions.each(function () {
114        let id = $(this).val();
115        const name = $(this).text();
116        console.log(id);
117        // Increment value only for pricing fields
118        if (source === 'pricing_fee' || source === 'speaking_fee' || source === 'pricing' ) {
119            id = parseInt(id);
120        }
121
122        selectedValues[id.toString()] = name;
123    });
124
125    // Determine input name based on source
126    let inputName = 'cat_id[]';
127    if (source === 'pricing_fee' || source === 'speaking_fee') {
128        inputName = 'pricing[]';
129    }
130
131    // Append newly selected items
132    $.each(selectedValues, function (id, name) {
133        if ($(`ul.sort-list input.pric-hero[value="${id}"][data-source="${source}"]`).length === 0) {
134            $('ul.sort-list').append(`
135                <li class="selected-hero-pricing" data-id="${id}" data-source="${source}">
136                    <a href="javascript:void(0)">${name}</a>
137                    <span class="remove-cat">X</span>
138                    <input type="hidden" name="${inputName}" class="pric-hero" value="${id}" data-source="${source}">
139                </li>
140            `);
141        }
142    });
143    
144    // Remove items no longer selected
145    $(`ul.sort-list input.pric-hero[data-source="${source}"]`).each(function () {
146        console.log(selectedValues)
147        const id = $(this).val();
148        console.log("id", id);
149        if (!(id in selectedValues)) {
150            $(this).closest('li').remove();
151        }
152    });
153});
154
155$(document).on('click', '.clickable-sub-cat', function () {
156    const $this = $(this);
157    const id = $this.attr('data-id');
158    const name = $this.attr('data-name');
159    const source = $this.attr('data-source');
160
161    // Determine input name
162    let inputName = 'cat_id[]';
163    if (source === 'subcategory') {
164        inputName = 'subcat_id[]';
165    }
166
167    const selector = `ul.sort-list input.pric-hero[value="${id}"][data-source="${source}"]`;
168    console.log('selected');
169	$("#filters-shorting").show();
170
171    if ($(selector).length === 0) {
172        // Not selected yet, append it
173        $('ul.sort-list').append(`
174            <li class="selected-hero-pricing" data-id="${id}" data-source="${source}">
175                <a href="javascript:void(0)">${name}</a>
176                <span class="remove-cat">X</span>
177                <input type="hidden" name="${inputName}" class="pric-hero" value="${id}" data-source="${source}">
178            </li>
179        `);
180        $(`#top_herder_cat${id}`).addClass('active');
181        $this.addClass('active');
182    } else {
183        // Already selected, remove it
184        $(selector).closest('li').remove();
185        $this.removeClass('active');
186    }
187});
188
189// Handle the remove button click
190$(document).on('click', '.remove-cat', function (e) {
191    e.stopPropagation();
192
193    const id = $(this).siblings('input.pric-hero').val();
194    const source = $(this).siblings('input.pric-hero').attr('data-source');
195    removeHeaderAddedCategory(id);
196    // Remove matching selected filter item
197    $('li.selected-hero-pricing').each(function () {
198        const $li = $(this);
199        const currentId = $li.find('input.pric-hero').val();
200        const currentSource = $li.find('input.pric-hero').attr('data-source');
201
202        if (currentId === id && currentSource === source) {
203            $li.remove();
204        }
205    });
206    
207    console.log('ddsadfcdsc');
208    // Deselect in dropdown
209    if (source && source !== 'undefined') {
210        $('#' + source + ' option[value="' + id + '"]').prop('selected', false);
211        $('#' + source).multiselect('refresh');
212    }
213
214    // 🔴 Only remove active class (don’t remove elements)
215    $('li.single-category-selection[data-id="' + id + '"]').removeClass('active');
216    $('li.clickable-sub-cat[data-id="' + id + '"]').removeClass('active');
217    $('a.select-sub-cat-wrapper[data-catsub="' + id + '"]').removeClass('active');
218});
219
220// Handle the Remove of the HEader Added Categories
221function removeHeaderAddedCategory(id){
222	$('#top_'+id).remove();
223	$('#top_herder_cat'+id).removeClass('active');
224	$('#top_herder_cat'+id).find('.select-sub-cat-wrapper').removeClass('active');
225	
226	$(this).parent().remove();
227	$('.bottom-selected-value ul li[data-id="' + id + '"]').remove();
228
229	if($('.bottom-selected-value.budget_section_top ul li').length == 0){
230		$('.bottom-selected-value.budget_section_top').hide();
231	}
232	if ($('.bottom-selected-value ul li').length > 0 || $('.budget_section_top ul li').length > 0) {
233		// There are li elements in the ul
234		$('.top_bottom_search_btn').show();
235		$('.bugt_btn').show();
236	} else {
237		$('.top_bottom_search_btn').hide();
238		$('.bugt_btn').hide();
239		// There are no li elements in the ul
240	}
241}
242
243
244
245
246// Attach autocomplete to all matching inputs
247$('.location-autocomplete').each(function () {
248    attachLocationAutocomplete(this);
249});
250$(".location-autocomplete").val($('.hiddencity').val());
251// Handle dropdown change
252$(document).on('change', '.cat-slect.miles', function () {
253    const selectedLocation = $('.location-autocomplete').val() !== ''
254    ? $('.location-autocomplete').val()
255    : $('.hiddencity').val();
256    // console.log(selectedLocation);
257    if (selectedLocation) {
258        const selectedRange = $(this).val();
259        appendOrUpdateLocationFilter(selectedLocation, selectedRange);
260    }
261});
262
263// Handle removal of location filter
264$(document).on('click', '.location-filter .remove-cat', function () {
265    $(this).closest('li').remove();
266    $('.location-autocomplete').val('');
267    $('.cat-slect.miles').val('250'); // Optional: reset to default
268});
269$(document).on('mouseover', '.under-advanced-section', function () {
270    var parentId = $(this).data('id'); // same as attr("data-id")
271
272    // Hide all subcategory items first
273    $('.sub-category-mega-menu ul li').hide();
274
275    // Show only those that belong to the hovered category
276    $('.sub-category-mega-menu ul li').each(function () {
277        if ($(this).data('parentcat') == parentId) {
278            $(this).show();
279            $(this).addClass("clickable-sub-cat");
280        }
281    });
282});
283
284$(document).on('click', '.under-advanced-section', function () {
285    // var parentId = $(this).data('id'); // same as attr("data-id")
286    const $this = $(this);
287    const id = $this.attr('data-id');
288    const name = $this.attr('data-name');
289    const source = 'category';
290
291    // Determine input name
292    let inputName = 'cat_id[]';
293
294    const selector = `ul.sort-list input.pric-hero[value="${id}"][data-source="${source}"]`;
295
296    if ($(selector).length === 0) {
297        // Not selected yet, append it
298        $('ul.sort-list').append(`
299            <li class="selected-hero-pricing" data-id="${id}" data-source="${source}">
300                <a href="javascript:void(0)">${name}</a>
301                <span class="remove-cat">X</span>
302                <input type="hidden" name="${inputName}" class="pric-hero" value="${id}" data-source="${source}">
303            </li>
304        `);
305        $(`#top_herder_cat${id}`).addClass('active');
306        $this.addClass('active');
307    } else {
308        // Already selected, remove it
309        $(selector).closest('li').remove();
310        $this.removeClass('active');
311    }
312});
313
314// Show the popup for the get curated list of the talents
315$(document).on('click','#gethelp-from-engage',function(){
316    $("#exampleModalCenter").modal('show');
317});
318
319// Location autocomplete feature
320function attachLocationAutocomplete(selector) {
321const $input = $(selector);
322const url = $input.data('url');
323
324$input.autocomplete({
325    source: function (request, response) {
326        $.ajax({
327            url: url,
328            data: {
329                term: request.term
330            },
331            success: function (data) {
332                response(data);
333            }
334        });
335    },
336    select: function (e, ui) {
337        console.log('Selected:', ui.item);
338        const selectedLocation = ui.item.value;
339        console.log(selectedLocation);
340        const selectedRange = $('.cat-slect.miles').val();
341        appendOrUpdateLocationFilter(selectedLocation, selectedRange)
342    }
343});
344}
345
346// Append or update the location filter <li>
347function appendOrUpdateLocationFilter(location, miles) {
348console.log(location, miles);
349const $existing = $('ul.sort-list li.location-filter');
350console.log($existing);
351const text = `${location} (${miles} miles)`;
352
353if ($existing.length > 0) {
354    $existing.find('a').text(text);
355    $existing.find('input.location-val').val(location);
356    $existing.find('input.miles-val').val(miles);
357    $existing.find('input.maxrange').val(miles);
358    $existing.find('#range_tag').remove();
359    $existing.find('.hiddencity').val(location);
360    $existing.find('maxrange').val(miles);
361
362} else {
363    $('ul.sort-list').append(`
364        <li class="location-filter selected-hero-pricing">
365            <a href="javascript:void(0)">${text}</a>
366            <span class="remove-cat">X</span>
367            <input type="hidden" class="location-val" name="city" value="${location}">
368            <input type="hidden" class="miles-val" name="maxRange" value="${miles}">
369        </li>
370    `);
371}
372}   
373
374
375$(document).on('click', '.remove-pricing', function () {
376var pri = $(this).attr('data-pri');
377
378// Get current URL search params
379const params = new URLSearchParams(window.location.search);
380
381// Get all pricing[] values and remove the selected one
382let updatedPricing = params.getAll('pricing[]').filter(val => val !== pri);
383
384// Delete all existing pricing[] from params
385params.delete('pricing[]');
386
387// Re-add unique pricing values
388updatedPricing.forEach(val => params.append('pricing[]', val));
389
390// Build new URL
391const newUrl = window.location.pathname + '?' + params.toString();
392
393// Update browser URL and reload
394$.LoadingOverlay("show");
395window.history.pushState({ path: newUrl }, '', newUrl);
396location.reload();
397
398// Remove UI elements
399$('#upper_pri' + pri).remove();
400$('#inner_upper' + pri).removeClass('active');
401$('#advance_wrap' + pri).remove();
402
403if ($('.selected-hero-pricing').length == 0) {
404    $('.wrapper-parent-search_selection').hide();
405}
406});
407
408$('.remove-cat').on('click', function () {
409    var cate_number = $(this).attr('data-cat');
410    var url = decodeURIComponent(window.location.search);
411
412    console.log("Category to remove:", cate_number);
413
414    // Use URLSearchParams to manage query string
415    const params = new URLSearchParams(url);
416
417    // Filter out all matching cat_id[]=cate_number
418    let catIds = params.getAll('cat_id[]');
419    catIds = catIds.filter(id => id !== cate_number);
420
421    // Clear all cat_id[] entries
422    params.delete('cat_id[]');
423
424    // Re-add only the ones we want to keep
425    catIds.forEach(id => {
426        params.append('cat_id[]', id);
427    });
428
429    //** For Sub Categores */
430    // Filter out all matching subcat_id[]=cate_number
431    let subcatIds = params.getAll('subcat_id[]');
432    subcatIds = subcatIds.filter(id=>id !== cate_number);
433
434    //Clear all subcat_id[] entries
435    params.delete('subcat_id[]');
436
437    //Re-add only the onces we want to keep
438    subcatIds.forEach(id=>{
439        params.append('subcat_id[]',id);
440    });
441    // **
442 
443
444    // Same for ids[]
445    let ids = params.getAll('ids[]');
446    ids = ids.filter(id => id !== cate_number);
447    params.delete('ids[]');
448    ids.forEach(id => {
449        params.append('ids[]', id);
450    });
451
452    // Build final URL and reload
453    const newUrl = window.location.pathname + '?' + params.toString();
454    window.history.pushState({ path: newUrl }, '', newUrl);
455    $.LoadingOverlay("show");
456    location.reload();
457
458    // Remove active class only
459    $('#top_herder_cat' + cate_number).removeClass('active');
460    $('#top_' + cate_number).removeClass('active');
461});
462
463
464$(".remove-event-type").on('click',function(){
465$(this).closest('li').remove();
466$("#one-search").append(`<input type="hidden" name="price_type" value="">`);
467location.reload();
468});
469
470// Reset the Filter on change of the Event type
471function handleEventTypeChange(activeOption) {
472$.LoadingOverlay('show');
473
474// Remove existing hidden input
475$(".price_type").remove();
476
477// Create the new hidden input element
478const input = `<input type="hidden" class="price_type" name="price_type" value="${activeOption === 'virtual' ? 'virtual' : 'inperson'}">`;
479
480// Append it to the form or a specific container
481$("#one-search").append(input);
482
483$("#one-search").submit();
484}
485$('.tal_hash_search').on('click',function(){
486$.LoadingOverlay("show");
487var variableNameToRemove = ['search','searchdropdownoption'];
488removeQueryStringVariables(variableNameToRemove);
489location.reload();
490});
491$('.city_range').on('click',function(){
492$.LoadingOverlay("show");
493var variableNameToRemove = ['city','minRange','maxRange'];
494removeQueryStringVariables(variableNameToRemove);
495     location.reload(); 
496
497});
498function removeQueryStringVariables(variableNames) {
499var url = window.location.href;
500var urlParts = url.split('?');
501
502if (urlParts.length >= 2) {
503  var baseUrl = urlParts[0];
504  var queryString = urlParts[1];
505  var params = queryString.split('&');
506  var newParams = [];
507
508  for (var i = 0; i < params.length; i++) {
509    var paramKeyValue = params[i].split('=');
510    var paramName = paramKeyValue[0];
511
512    // Check if paramName is in the variableNames array
513    if (!variableNames.includes(paramName)) {
514      // If it's not, add it to newParams
515      newParams.push(params[i]);
516    }
517  }
518
519  if (newParams.length > 0) {
520    var newQueryString = newParams.join('&');
521    var newUrl = baseUrl + '?' + newQueryString;
522
523    // Update the URL without reloading the page
524    history.replaceState({}, document.title, newUrl);
525  } else {
526    // Remove the entire query string if no parameters are left
527    var newUrl = baseUrl;
528
529    // Update the URL without reloading the page
530    history.replaceState({}, document.title, newUrl);
531  }
532}
533}
534
535$("#landing-page-popup-form").validate({
536rules: {
537    name: {
538        required: true
539    },
540    last_name: {
541        required: true
542    },
543    email: {
544        required: true,
545        email: true
546    },
547    submit_type: {
548        required: true
549    },
550    message: {
551        required: true
552    }
553},
554errorPlacement: function(error, element) {
555    // Do nothing — suppress error display
556},
557highlight: function(element) {
558    $(element).addClass("error");
559},
560unhighlight: function(element) {
561    $(element).removeClass("error");
562}
563});
564

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.