PageSourceSearch

https://www.amcny.org/wp-content/themes/amc/js/ajaxfilter.js?ver=2026-10-02

js amcny.org collected 2026-10-02 06:26:38 UTC 18,565 bytes, 670 lines download raw bytes

1function Ajaxfunction(data, datatype) {
2  // @joe data = jQuery("#finddoctor, #event") , datatype = html
3
4  console.log("function Ajaxfunction");
5
6  var form = data; // @joe = jQuery("#finddoctor, #event")
7
8  jQuery.ajax({
9    type: "post",
10
11    url: sbiajaxurl,
12
13    dataType: datatype,
14
15    data: form.serialize(),
16
17    beforeSend: function () {
18      console.log("sbiajaxurl = " + sbiajaxurl);
19      console.log("datatype = " + datatype);
20      console.log("ajax beforeSend");
21
22      if (datatype !== "html") console.log("datatype = " + datatype);
23
24      console.log("    data (form.serialize()) = ");
25      console.log(data);
26
27      shorturl = jQuery(".hiddenfield", form).serialize();
28
29      console.log("    shorturl = " + shorturl);
30
31      location.hash = shorturl;
32
33      // console.log('ajax beforeSend location.hash = ' + location.hash);
34
35      jQuery(".alphafilter li").removeClass("active");
36
37      // Hide the .pre_response content and .post_responses content.
38      // .pre_response is the content that exists before Ajax adds new content.
39      // .post_responses is the content that Ajax adds.
40      // In theory, no .post_responses content exists when you first load the page.
41      // But it can exist after you first use ajax to update the content on the page.
42      jQuery(".pre_response, .post_responses").hide();
43
44      jQuery(".list-bar, .blog_index, .responefilter, .pet-bar").addClass(
45        "loader"
46      );
47
48      var headerHeight = jQuery("header#masthead").innerHeight();
49      var offset = headerHeight + 100;
50
51      jQuery("html, body").animate(
52        {
53          scrollTop: jQuery(".common_cls").offset().top - offset,
54        },
55        500
56      );
57    },
58
59    success: function (e) {
60      console.log("ajax success");
61
62      setTimeout(function () {
63        console.log("    ajax setTimeout");
64
65        jQuery(".list-bar, .blog_index, .responefilter, .pet-bar").removeClass(
66          "loader"
67        );
68
69        if (e.html_content) {
70          jQuery(".response").html(e.html_content);
71
72          if (parseInt(e.next_page) > 1) {
73            jQuery(".alm-btn-wrap").show();
74          } else {
75            jQuery(".alm-btn-wrap").hide();
76          }
77        } else {
78          console.log("    jQuery insert .html(e)");
79
80          // Insert the prepared HTML response -- (e) -- into .response
81          // console.log(e);
82          jQuery(".response").html(e);
83        }
84
85        //jQuery(".alphafilter Li:first a").trigger('click');
86
87        jQuery(".category ul.tribe-event-categories li").each(function () {
88          var ju = jQuery(this).find("a").text();
89
90          jQuery(this).addClass(ju);
91        });
92      }, 1000);
93
94      if (parseInt(e.next_page) > 1) {
95        if (!(typeof sessionStorage == "undefined")) {
96          if (!(sessionStorage.getItem("cs_postID") == null)) {
97            var i = 1;
98
99            jQuery(".list-bar li a.btn").each(function (index, element) {
100              if (
101                jQuery(this).attr("id") == sessionStorage.getItem("cs_postID")
102              ) {
103                i++;
104              }
105            });
106
107            if (i == 1) {
108              jQuery(".resource-bar .btn-row .btn1").trigger("click");
109            }
110          }
111        }
112      }
113
114      sessionStorage.clear();
115    },
116
117    complete: function (e) {
118      console.log("ajax complete");
119    },
120
121    error: function () {
122      console.log("Error");
123    },
124  });
125}
126
127function Ajaxfilter(datatype) {
128  // @joe this runs for pet food recall, datatype = html
129
130  var data = jQuery("#finddoctor, #event");
131
132  console.log("function Ajaxfilter");
133
134  Ajaxfunction(data, datatype);
135}
136
137function AdvanceAjaxfilter(data, datatype) {
138  Ajaxfunction(data, datatype);
139}
140
141function LoadMore(s, p, e, d, f) {
142  jQuery.ajax({
143    url: sbiajaxurl,
144
145    type: "post",
146
147    dataType: "JSON",
148
149    data: {
150      action: "events",
151
152      showposts: s,
153
154      page: p,
155
156      event: e,
157
158      eventdisplay: d,
159
160      orderpost: f,
161    },
162
163    beforeSend: function () {
164      jQuery(".alm-load-more-btn").addClass("loadmore");
165    },
166
167    success: function (e) {
168      jQuery(".alm-load-more-btn").removeClass("loadmore");
169
170      jQuery(".response").append(e.html_content);
171
172      if (parseInt(e.next_page) > 1) {
173        jQuery(".alm-load-more-btn").attr("data-page", e.next_page);
174
175        jQuery(".alm-btn-wrap").show();
176      } else {
177        jQuery(".alm-btn-wrap").hide();
178      }
179
180      jQuery(".category ul.tribe-event-categories li").each(function () {
181        var ju = jQuery(this).find("a").text();
182
183        jQuery(this).addClass(ju);
184      });
185
186      sessionStorage.clear();
187    },
188
189    error: function () {
190      console.log("Error");
191    },
192  });
193}
194
195function AjaxPagepaging() {
196  // console.log('>>> AjaxPagepaging');
197
198  // When someone clicks on a page navigation link, prevent the default behavior and instead call Ajaxfilter to update the page content.
199  jQuery(".wp-pagenavi a").on("click", function (e) {
200    // console.log('*** click .wp-pagenavi a');
201
202    e.preventDefault();
203
204    //var url = jQuery(this).attr("href");
205    //var arr = url.split("=");
206    //paged = arr[1];
207
208    let paged = jQuery(this).text();
209    if (paged == "»") {
210      let current = jQuery(".response .wp-pagenavi .current").text();
211      console.log("current", current);
212      paged = parseInt(current) + 1;
213    } else if (paged == "«") {
214      let current = jQuery(".response .wp-pagenavi .current").text();
215      paged = parseInt(current) - 1;
216    }
217    jQuery(".paging_id").val(paged);
218    // console.log('... about to run Ajaxfilter');
219
220    Ajaxfilter("html");
221
222    return false;
223  });
224} // end function AjaxPagepaging
225
226function Alphafilter() {
227  console.log("function Alphafilter");
228
229  //jQuery('.titlelist').hide();
230
231  jQuery(".alphafilter a").on("click", function (e) {
232    console.log("*** click .alphafilter a");
233
234    e.preventDefault();
235
236    letter = jQuery(this).attr("data-alpha");
237    console.log(letter);
238
239    jQuery("li.letter-label").css("display", "none");
240    jQuery(
241      "ul.letter-subsection:not(.section-" + letter.toUpperCase() + ")"
242    ).css("display", "none");
243
244    jQuery("ul.letter-subsection.section-" + letter.toUpperCase()).css(
245      "display",
246      "block"
247    );
248
249    jQuery(".alphafilter li").removeClass("active");
250
251    jQuery(this).parent().addClass("active");
252
253    jQuery(".post_dfr ul li.titlelist").hide();
254
255    jQuery(".post_dfr ul li." + letter).show();
256
257    var vislist = jQuery(".titlelist:visible").length;
258
259    if (vislist == 0) {
260      jQuery(".post_dfr .nf").show().html("<h4>More content coming soon!</h4>");
261    } else {
262      jQuery(".post_dfr .nf").hide();
263    }
264  });
265} // end function Alphafilter
266
267// This function pulls data from ajaxfilter.php, and inserts it onto the page.
268// Called on page load.
269// Note: On page load, custom.js triggers the click event function for "#finddoctor .scrollableList ul li".
270jQuery(function () {
271  Alphafilter();
272
273  //jQuery(".alphafilter Li:first a").trigger('click');
274
275  // By default, make the first <select><option> selected.
276  //jQuery("select option:first").attr("selected", "selected");
277
278  jQuery("#finddoctor .scrollableList ul li").on("click", function (e) {
279    // jQuery("#event select").on("change", function(e) {
280
281    e.preventDefault(), jQuery("#event .paging_id").val(1);
282
283    // console.log('Click #finddoctor .scrollableList ul li');
284
285    var selectedLI = jQuery(this).text();
286
287    var selectedVal = jQuery(this).attr("data-val");
288
289    console.log(
290      "onclick '#finddoctor .scrollableList ul li' selectedVal = " + selectedVal
291    ); // @joe Display selected form value in the console.
292
293    jQuery(this).parents("ul.scroll1").prev(".selectedOption").text(selectedLI);
294    jQuery(this)
295      .parents("ul.scroll1")
296      .prev(".selectedOption")
297      .attr("data-val", selectedVal);
298
299    jQuery(this).parents("ul.scroll1").next().val(selectedVal);
300
301    jQuery(this).parents("ul.scroll1").hide();
302
303    jQuery(this).parents("ul.scroll1").prev().removeClass("show");
304
305    //  jQuery("#finddoctor select").on("change", function(e) {
306
307    //  e.preventDefault(),
308
309    jQuery(".paging_id").val(1);
310
311    Ajaxfilter("html");
312  });
313
314  jQuery("#finddoctor").on("submit", function (e) {
315    e.preventDefault();
316
317    jQuery(".paging_id").val(1);
318
319    //alert(1);
320
321    Ajaxfilter("html");
322  });
323
324  /*jQuery("#finddoctor.findsearch ul li input.search").on("keyup", function (e) {
325    	
326        if (e.which <= 90 && e.which >= 48) {
327        	
328            e.preventDefault();
329
330            jQuery('.paging_id').val(1);
331
332            //alert(1);
333
334            Ajaxfilter('html');
335        	
336        }
337
338    });*/
339
340  jQuery(".close").on("click", function (e) {
341    e.preventDefault();
342    jQuery("#event .scrollableList li:first-child").trigger("click");
343    datatype = jQuery(this).attr("data-type");
344
345    jQuery(".paging_id").val(1);
346
347    jQuery(".hiddenfield, .search").val("");
348
349    jQuery(".alm-load-more-btn").attr("data-event", "");
350
351    jQuery("select").each(function (index, element) {
352      _firstOption = jQuery(this).find("option").first().text();
353
354      //_firstOption = jQuery("select option:first").text();
355
356      jQuery(this).next().children("div.selectedOption").text(_firstOption);
357      //children('div.selectedOption').text(_firstOption);
358    });
359
360    Ajaxfilter(datatype);
361  });
362
363  jQuery(".wp-pagenavi a").on("click", function (e) {
364    e.preventDefault();
365
366    //var url = jQuery(this).attr("href");
367    //(parts = url.split("/")), (last_part = parts[parts.length - 2]);
368    //jQuery(".paging_id").val(last_part);
369
370    let paged = jQuery(this).text();
371    if (paged == "»") {
372      let current = jQuery(".wp-pagenavi .current").text();
373      paged = parseInt(current) + 1;
374    } else if (paged == "«") {
375      let current = jQuery(".wp-pagenavi .current").text();
376      paged = parseInt(current) - 1;
377    }
378    jQuery(".paging_id").val(paged);
379
380    Ajaxfilter("html");
381
382    return false;
383  });
384
385  jQuery("#event .scrollableList ul li").on("click", function (e) {
386    e.preventDefault(), jQuery("#event .paging_id").val(1);
387
388    var selectedLI = jQuery(this).text();
389
390    var selectedVal = jQuery(this).attr("data-val");
391
392    jQuery(this).parents("ul.scroll1").prev(".selectedOption").text(selectedLI);
393
394    jQuery(this).parents("ul.scroll1").next().val(selectedVal);
395
396    jQuery(this).parents("ul.scroll1").hide();
397
398    jQuery(this).parents("ul.scroll1").prev().removeClass("show");
399
400    jQuery(".alm-load-more-btn").attr(
401      "data-event",
402      jQuery(this).attr("data-val")
403    );
404
405    //alert(1);
406
407    jQuery(".alm-load-more-btn").attr("data-page", 2);
408
409    Ajaxfilter("json");
410  });
411
412  jQuery(".alm-load-more-btn").click(function (e) {
413    e.preventDefault();
414
415    var s = jQuery(".alm-load-more-btn").attr("data-showposts");
416
417    var p = jQuery(".alm-load-more-btn").attr("data-page");
418
419    var ev = jQuery(".alm-load-more-btn").attr("data-event");
420
421    var d = jQuery(".alm-load-more-btn").attr("data-eventdisplay");
422
423    var f = jQuery(".alm-load-more-btn").attr("data-orderpost");
424
425    LoadMore(s, p, ev, d, f);
426  });
427
428  /*********************/
429
430  jQuery("#advancefilter").submit(function (e) {
431    console.log("#advancefilter");
432
433    e.preventDefault();
434
435    jQuery(".pops").hide();
436
437    var data = jQuery(this);
438
439    AdvanceAjaxfilter(data, "html");
440  });
441
442  /**************/
443
444  jQuery(".filtepopup .btn").click(function ($) {
445    jQuery(".filtepopup").hide();
446
447    if (jQuery(this).hasClass("next")) {
448      jQuery(this).closest(".filtepopup").next(".filtepopup").show();
449    }
450
451    if (jQuery(this).hasClass("back")) {
452      jQuery(this).closest(".filtepopup").prev(".filtepopup").show();
453    }
454  });
455
456  jQuery(".pop_up .close_df").click(function () {
457    jQuery(".filtepopup").hide();
458  });
459
460  // Run this if the URL includes a hash '#' value
461  if (window.location.hash !== "") {
462    // console.log('window.location.hash = ' +  window.location.hash);
463
464    // console.log('getting parameters');
465
466    // get parameter from the URL, e.g. /#videos=dentistry will return 'videos' as parameter
467    dept = getParameterByName("department");
468
469    cond = getParameterByName("condition");
470
471    events = getParameterByName("event");
472
473    blog = getParameterByName("blog");
474
475    career = getParameterByName("career");
476
477    role = getParameterByName("role");
478
479    recalls = getParameterByName("recalls");
480
481    resources = getParameterByName("resources");
482
483    videos = getParameterByName("videos");
484
485    // console.log(events);
486
487    if (events == "usdan-events") {
488      jQuery("body").addClass("usdan-events-cls");
489    }
490
491    if (recalls == null) {
492      console.log("recalls = null");
493    } else {
494      console.log("recalls = yes!");
495    }
496
497    // if( jQuery(this).attr('data-val') ) console.log('data-val is also \'re
497call\'');
498
499    /* jQuery("#finddoctor .scrollableList ul").find("li").each(function () {
500
501            // console.log("jQuery(this).attr('data-val')");
502            // console.log(jQuery(this).attr('data-val'));
503
504            if ( (
505                    jQuery(this).attr('data-val') == career ||
506                    jQuery(this).attr('data-val') == blog ||
507                    jQuery(this).attr('data-val') == recalls ||
508                    jQuery(this).attr('data-val') == resources ||
509                    jQuery(this).attr('data-val') == videos ||
510                    (jQuery(this).attr('data-val') == dept) || 
511                    (jQuery(this).attr('data-val') == cond)
512                )
513            ) {
514
515                // console.log('trigger fake click')
516                // jQuery(this).trigger('click');
517
518            }
519        }); */
520
521    // If this page contains #events, check each list item
522    jQuery("#events .scrollableList ul")
523      .find("li")
524      .each(function () {
525        if (jQuery(this).attr("data-val") == events) {
526          jQuery(this).trigger("click");
527        }
528      });
529  }
530});
531
532// Return value from browser URL.
533// e.g. if name = 'foo' and url ends in '/#foo=bar', function will return 'foo'
534function getParameterByName(name, url) {
535  // If URL parameter is not set, get the value from the browser window URL
536  if (!url) url = window.location.href;
537
538  // console.log('window.location.href = ' + window.location.href);
539
540  name = name.replace(/[\[\]]/g, "\\$&");
541
542  var regex = new RegExp("[#&]" + name + "(=([^&#]*)|&|#|$)"),
543    results = regex.exec(url);
544
545  if (!results) return null;
546
547  console.log("name: " + name + ", results[2]: " + results[2]);
548
549  if (!results[2]) return "";
550
551  return decodeURIComponent(results[2].replace(/\+/g, " "));
552}
553
554jQuery(function ($) {
555  // This function handles events.
556  // If #events does not exist on the page, nothing happens.
557
558  // Check whether #event exists
559  if (jQuery("#event").length) {
560    // Determine the URL
561    var url = jQuery(location).attr("href"),
562      parts = url.split("/"),
563      last_part = parts[parts.length - 1];
564    last_part_nohash = parts[parts.length - 2];
565
566    // If this is an event then trigger a click on the event list.
567    // Ideally, this would call a function.
568    if (last_part == "#event=" || last_part == "") {
569      jQuery("#event .scrollableList li:first-child").trigger("click");
570    }
571  }
572
573  /**
574   * Load More Careers/Jobs
575   */
576  function load_more_jobs(paged, cat, role) {
577    console.log("loadMoreJobs");
578    $.ajax({
579      url: sbiajaxurl,
580      type: "post",
581      data: {
582        action: "careers",
583        paged: paged,
584        cat: cat,
585        role: role,
586      },
587
588      beforeSend: function () {
589        jQuery(".responefilter").addClass("loader");
590      },
591
592      success: function (data) {
593        jQuery(".responefilter").removeClass("loader");
594
595        if (paged == 1) {
596          jQuery(".response").html(data);
597        } else {
598          jQuery(".response").append(data);
599        }
600      },
601
602      error: function () {
603        console.log("Error");
604      },
605    });
606  }
607
608  const params = new Proxy(new URLSearchParams(window.location.search), {
609    get: (searchParams, prop) => searchParams.get(prop),
610  });
611  let careerInit = params.career;
612  let rolesInit = params.role;
613  //Only init on careers page. Jobs were being loaded into the pet health library page.
614  if (window.location["pathname"] == "/careers/") {
615    load_more_jobs(1, careerInit, rolesInit);
616  }
617
618  $(document).on("click", ".load-more-careers", function (e) {
619    e.preventDefault();
620
621    var $this = $(this);
622    const paged = $this.data("paged") + 1;
623    const queryString = window.location.search;
624    const urlParams = new URLSearchParams(queryString);
625    const role = urlParams.get("role");
626    const career = urlParams.get("career");
627
628    /*
629      career =
630        location.hash && location.hash.replace("#career=", "")
631          ? location.hash.replace("#career=", "")
632          : "",
633      role =
634        location.hash && location.hash.replace("#role=", "")
635          ? location.hash.replace("#role=", "")
636          : ""; */
637
638    load_more_jobs(paged, career, role);
639
640    $this.parent().remove();
641  });
642
643  /*$("#findjob .scrollableList ul li").on("click", function (e) {
644    e.preventDefault();
645
646    var selectedLI = $(this).text();
647    var selectedVal = $(this).attr("data-val");
648    var type = $(this).parents(".select-wrapper").attr("data-name");
649
650    $(this).parents("ul.scroll1").prev(".selectedOption").text(selectedLI);
651    $(this)
652      .parents("ul.scroll1")
653      .prev(".selectedOption")
654      .attr("data-val", selectedVal);
655
656    $(this).parents("ul.scroll1").next().val(selectedVal);
657    $(this).parents("ul.scroll1").hide();
658
659    $(this).parents("ul.scroll1").prev().removeClass("show");
660
661    var career = $(".career-select .selectedOption").attr("data-val");
662    var role = $(".role-select .selectedOption").attr("data-val");
663
664    load_more_jobs(1, career, role);
665
666    var url = new URL(window.location.href);
667    url.searchParams.set(type, selectedVal);
668    window.history.replaceState(null, null, url);
669  });*/
670});

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.