PageSourceSearch

https://www.louisehay.com/wp-content/themes/louisehay/js/main.js?ver=7.1.2

js louisehay.com collected 2026-10-02 11:55:39 UTC 29,825 bytes, 1,017 lines download raw bytes

1var main = {
2    windowWidth: $(window).width(),
3    searchBarFocusWidth: function () {
4
5        if (this.windowWidth < 1200) {
6            return 90;
7        } else if (this.windowWidth < 1600) {
8            return 125;
9        } else {
10            return 180;
11        }
12    },
13    searchBarBlurWidth: function () {
14        if (this.windowWidth < 1600) {
15            return 60;
16        } else {
17            return 80;
18        }
19    },
20    searchBarInit: function () {
21        var focusWidth = this.searchBarFocusWidth();
22        var blurWidth = this.searchBarBlurWidth();
23
24        $(this).clearQueue();
25
26        if (this.windowWidth > 1200) {
27            $('.search-bar').focus(function () {
28                $(this).animate({'width': focusWidth + 'px'}, 100);
29            })
30
31            $('.search-bar').blur(function () {
32                $(this).animate({'width': blurWidth + 'px'}, 100);
33            })
34        }
35
36    }
37}
38var countries = {
39    "US": "United States",
40    "AF": "Afghanistan",
41    "AX": "Åland Islands",
42    "AL": "Albania",
43    "DZ": "Algeria",
44    "AS": "American Samoa",
45    "AD": "Andorra",
46    "AO": "Angola",
47    "AI": "Anguilla",
48    "AQ": "Antarctica",
49    "AG": "Antigua and Barbuda",
50    "AR": "Argentina",
51    "AM": "Armenia",
52    "AW": "Aruba",
53    "AU": "Australia",
54    "AT": "Austria",
55    "AZ": "Azerbaijan",
56    "BS": "Bahamas",
57    "BH": "Bahrain",
58    "BD": "Bangladesh",
59    "BB": "Barbados",
60    "BY": "Belarus",
61    "BE": "Belgium",
62    "BZ": "Belize",
63    "BJ": "Benin",
64    "BM": "Bermuda",
65    "BT": "Bhutan",
66    "BO": "Bolivia",
67    "BA": "Bosnia and Herzegovina",
68    "BW": "Botswana",
69    "BV": "Bouvet Island",
70    "BR": "Brazil",
71    "IO": "British Indian Ocean Territory",
72    "BN": "Brunei Darussalam",
73    "BG": "Bulgaria",
74    "BF": "Burkina Faso",
75    "BI": "Burundi",
76    "KH": "Cambodia",
77    "CM": "Cameroon",
78    "CA": "Canada",
79    "CV": "Cape Verde",
80    "KY": "Cayman Islands",
81    "CF": "Central African Republic",
82    "TD": "Chad",
83    "CL": "Chile",
84    "CN": "China",
85    "CX": "Christmas Island",
86    "CC": "Cocos (Keeling) Islands",
87    "CO": "Colombia",
88    "KM": "Comoros",
89    "CG": "Congo",
90    "CD": "Congo, Democratic Republic",
91    "CK": "Cook Islands",
92    "CR": "Costa Rica",
93    "CI": "Cote D\"Ivoire",
94    "HR": "Croatia",
95    "CU": "Cuba",
96    "CY": "Cyprus",
97    "CZ": "Czech Republic",
98    "DK": "Denmark",
99    "DJ": "Djibouti",
100    "DM": "Dominica",
101    "DO": "Dominican Republic",
102    "EC": "Ecuador",
103    "EG": "Egypt",
104    "SV": "El Salvador",
105    "GQ": "Equatorial Guinea",
106    "ER": "Eritrea",
107    "EE": "Estonia",
108    "ET": "Ethiopia",
109    "FK": "Falkland Islands (Malvinas)",
110    "FO": "Faroe Islands",
111    "FJ": "Fiji",
112    "FI": "Finland",
113    "FR": "France",
114    "GF": "French Guiana",
115    "PF": "French Polynesia",
116    "TF": "French Southern Territories",
117    "GA": "Gabon",
118    "GM": "Gambia",
119    "GE": "Georgia",
120    "DE": "Germany",
121    "GH": "Ghana",
122    "GI": "Gibraltar",
123    "GR": "Greece",
124    "GL": "Greenland",
125    "GD": "Grenada",
126    "GP": "Guadeloupe",
127    "GU": "Guam",
128    "GT": "Guatemala",
129    "GG": "Guernsey",
130    "GN": "Guinea",
131    "GW": "Guinea-Bissau",
132    "GY": "Guyana",
133    "HT": "Haiti",
134    "HM": "Heard Island and Mcdonald Islands",
135    "VA": "Holy See (Vatican City State)",
136    "HN": "Honduras",
137    "HK": "Hong Kong",
138    "HU": "Hungary",
139    "IS": "Iceland",
140    "IN": "India",
141    "ID": "Indonesia",
142    "IR": "Iran",
143    "IQ": "Iraq",
144    "IE": "Ireland",
145    "IM": "Isle of Man",
146    "IL": "Israel",
147    "IT": "Italy",
148    "JM": "Jamaica",
149    "JP": "Japan",
150    "JE": "Jersey",
151    "JO": "Jordan",
152    "KZ": "Kazakhstan",
153    "KE": "Kenya",
154    "KI": "Kiribati",
155    "KP": "Korea (North)",
156    "KR": "Korea (South)",
157    "XK": "Kosovo",
158    "KW": "Kuwait",
159    "KG": "Kyrgyzstan",
160    "LA": "Laos",
161    "LV": "Latvia",
162    "LB": "Lebanon",
163    "LS": "Lesotho",
164    "LR": "Liberia",
165    "LY": "Libyan Arab Jamahiriya",
166    "LI": "Liechtenstein",
167    "LT": "Lithuania",
168    "LU": "Luxembourg",
169    "MO": "Macao",
170    "MK": "Macedonia",
171    "MG": "Madagascar",
172    "MW": "Malawi",
173    "MY": "Malaysia",
174    "MV": "Maldives",
175    "ML": "Mali",
176    "MT": "Malta",
177    "MH": "Marshall Islands",
178    "MQ": "Martinique",
179    "MR": "Mauritania",
180    "MU": "Mauritius",
181    "YT": "Mayotte",
182    "MX": "Mexico",
183    "FM": "Micronesia",
184    "MD": "Moldova",
185    "MC": "Monaco",
186    "MN": "Mongolia",
187    "MS": "Montserrat",
188    "MA": "Morocco",
189    "MZ": "Mozambique",
190    "MM": "Myanmar",
191    "NA": "Namibia",
192    "NR": "Nauru",
193    "NP": "Nepal",
194    "NL": "Netherlands",
195    "AN": "Netherlands Antilles",
196    "NC": "New Caledonia",
197    "NZ": "New Zealand",
198    "NI": "Nicaragua",
199    "NE": "Niger",
200    "NG": "Nigeria",
201    "NU": "Niue",
202    "NF": "Norfolk Island",
203    "MP": "Northern Mariana Islands",
204    "NO": "Norway",
205    "OM": "Oman",
206    "PK": "Pakistan",
207    "PW": "Palau",
208    "PS": "Palestinian Territory, Occupied",
209    "PA": "Panama",
210    "PG": "Papua New Guinea",
211    "PY": "Paraguay",
212    "PE": "Peru",
213    "PH": "Philippines",
214    "PN": "Pitcairn",
215    "PL": "Poland",
216    "PT": "Portugal",
217    "PR": "Puerto Rico",
218    "QA": "Qatar",
219    "RE": "Reunion",
220    "RO": "Romania",
221    "RU": "Russian Federation",
222    "RW": "Rwanda",
223    "SH": "Saint Helena",
224    "KN": "Saint Kitts and Nevis",
225    "LC": "Saint Lucia",
226    "PM": "Saint Pierre and Miquelon",
227    "VC": "Saint Vincent and the Grenadines",
228    "WS": "Samoa",
229    "SM": "San Marino",
230    "ST": "Sao Tome and Principe",
231    "SA": "Saudi Arabia",
232    "SN": "Senegal",
233    "RS": "Serbia",
234    "ME": "Montenegro",
235    "SC": "Seychelles",
236    "SL": "Sierra Leone",
237    "SG": "Singapore",
238    "SK": "Slovakia",
239    "SI": "Slovenia",
240    "SB": "Solomon Islands",
241    "SO": "Somalia",
242    "ZA": "South Africa",
243    "GS": "South Georgia and the South Sandwich Islands",
244    "ES": "Spain",
245    "LK": "Sri Lanka",
246    "SD": "Sudan",
247    "SR": "Suriname",
248    "SJ": "Svalbard and Jan Mayen",
249    "SZ": "Swaziland",
250    "SE": "Sweden",
251    "CH": "Switzerland",
252    "SY": "Syrian Arab Republic",
253    "TW": "Taiwan, Province of China",
254    "TJ": "Tajikistan",
255    "TZ": "Tanzania",
256    "TH": "Thailand",
257    "TL": "Timor-Leste",
258    "TG": "Togo",
259    "TK": "Tokelau",
260    "TO": "Tonga",
261    "TT": "Trinidad and Tobago",
262    "TN": "Tunisia",
263    "TR": "Turkey",
264    "TM": "Turkmenistan",
265    "TC": "Turks and Caicos Islands",
266    "TV": "Tuvalu",
267    "UG": "Uganda",
268    "UA": "Ukraine",
269    "AE": "United Arab Emirates",
270    "GB": "United Kingdom",
271    "UM": "United States Minor Outlying Islands",
272    "UY": "Uruguay",
273    "UZ": "Uzbekistan",
274    "VU": "Vanuatu",
275    "VE": "Venezuela",
276    "VN": "Viet Nam",
277    "VG": "Virgin Islands, British",
278    "VI": "Virgin Islands, U.S.",
279    "WF": "Wallis and Futuna",
280    "EH": "Western Sahara",
281    "YE": "Yemen",
282    "ZM": "Zambia",
283    "ZW": "Zimbabwe"
284};
285
286var states = [
287    "AL",
288    "AK",
289    "AS",
290    "AZ",
291    "AR",
292    "CA",
293    "CO",
294    "CT",
295    "DE",
296    "DC",
297    "FM",
298    "FL",
299    "GA",
300    "GU",
301    "HI",
302    "ID",
303    "IL",
304    "IN",
305    "IA",
306    "KS",
307    "KY",
308    "LA",
309    "ME",
310    "MH",
311    "MD",
312    "MA",
313    "MI",
314    "MN",
315    "MS",
316    "MO",
317    "MT",
318    "NE",
319    "NV",
320    "NH",
321    "NJ",
322    "NM",
323    "NY",
324    "NC",
325    "ND",
326    "MP",
327    "OH",
328    "OK",
329    "OR",
330    "PW",
331    "PA",
332    "PR",
333    "RI",
334    "SC",
335    "SD",
336    "TN",
337    "TX",
338    "UT",
339    "VT",
340    "VI",
341    "VA",
342    "WA",
343    "WV",
344    "WI",
345    "WY"
346];
347
348$(window).load(function () {
349
350    initMasonary();
351
352});
353
354
355var waitForFinalEvent = (function () {
356    var timers = {};
357    return function (callback, ms, uniqueId) {
358        if (!uniqueId) {
359            uniqueId = "Don't call this twice without a uniqueId";
360        }
361        if (timers[uniqueId]) {
362            clearTimeout(timers[uniqueId]);
363        }
364        timers[uniqueId] = setTimeout(callback, ms);
365    };
366})();
367
368var slidespeed = 10000;
369var slidetimer = null;
370
371function nextSlide() {
372    jQuery('.slide.current').each(function () {
373        var next = jQuery(this).next('.slide');
374        if (!next.size()) next = jQuery(this).siblings('.slide').eq(0);
375        jQuery(this).fadeOut(2000).removeClass('current');
376        next.fadeIn(2000).addClass('current');
377    });
378    slidetimer = setTimeout('nextSlide()', slidespeed);
379}
380
381/** Masonary **/
382
383
384var initMasonary = function () {
385    var $container = $('.items-container')
386    // init Isotope
387    $container.isotope({
388        itemSelector: '.item-container',
389        layoutMode: 'masonry',
390        animationEngine: 'best-avaliable'
391    });
392
393    $(window).bind("throttledresize", function () {
394        $container.isotope({
395            itemSelector: '.item-container',
396            layoutMode: 'masonry',
397            animationEngine: 'best-avaliable'
398        });
399    });
400
401
402    // filter functions
403    var filterFns = {
404        // show if number is greater than 50
405        numberGreaterThan50: function () {
406            var number = $(this).find('.number').text();
407            return parseInt(number, 10) > 50;
408        },
409        // show if name ends with -ium
410        ium: function () {
411            var name = $(this).find('.name').text();
412            return name.match(/ium$/);
413        }
414    };
415
416    var filters = {};
417
418    $('.filter').on('click', 'a', function () {
419        var $this = $(this);
420
421        var $filterGroup = $this.closest('.filter-group');
422        var filterGroup = $filterGroup.attr('data-filter-group');
423
424        filters[filterGroup] = $this.attr('data-filter');
425
426        var filterValue = '';
427
428        for (var prop in filters) {
429            filterValue += filters[prop];
430        }
431
432        $container.isotope({filter: filterValue});
433
434        noItemToShow();
435
436    });
437
438    $('.filter-show-all').on('click', function () {
439        filters = {};
440        filterValue = '';
441
442        $container.isotope({filter: filterValue});
443    });
444    // change active class on buttons
445    $('.item-filter-controls > div').each(function (i, buttonGroup) {
446        var $buttonGroup = $(buttonGroup);
447        $buttonGroup.on('click', 'a', function () {
448            $buttonGroup.find('.active').removeClass('active');
449            $(this).addClass('active');
450
451            $(".item-filter-dropdown").val($(this).text());
452        });
453    });
454
455    $('.multimedia-filter-controls ul').each(function (i, buttonGroup) {
456        var $buttonGroup = $(buttonGroup);
457        $buttonGroup.on('click', 'a', function () {
458            $buttonGroup.find('.active').removeClass('active');
459            $(this).parent('li').addClass('active');
460            $(".multimedia-filter-dropdown").val($(this).text());
461        });
462    });
463
464    $('.filter-dropdown').change(function () {
465
466        var filterGroup = $(this).data('filter-group');
467        var filterValue = '';
468
469        filters[filterGroup] = $(this).find(':selected').data('filter');
470
471        for (var prop in filters) {
472            filterValue += filters[prop];
473        }
474
475        $container.isotope({filter: filterValue});
476
477        noItemToShow();
478
479    });
480
481    $('.item-filter-dropdown').change(function () {
482        $('.category-name.active').removeClass('active');
483
484        $('.category-name:contains("' + $(this).val() + '")').addClass('active');
485    });
486    $('.multimedia-filter-dropdown').change(function () {
487        $('.media-name').closest('.active').removeClass('active');
488
489        $('.media-name:contains("' + $(this).val() + '")').closest('li').addClass('active');
490    });
491};
492
493var noItemToShow = function () {
494    setTimeout(function (data) {
495        var visibleItems = $('.media-container .trigger-modal:visible');
496        if (visibleItems.length == 0) {
497            $('.media-container').addClass('notice');
498            $('#media-container-status').html('<p>No items to show for this topic.</p>').show();
499        }
500        else {
501            $('#media-container-status').html('').hide();
502            $('.media-container').removeClass('notice');
503        }
504    }, 500);
505}
506
507var subscribeNewsletter = (function (target, name, email, captcha, widgetId) {
508    $('.waiting').html('<p>Please wait...</p>').show();
509    $.post('/subscribe_newsletter.php', {
510        name: name,
511        email: email,
512        captcha: captcha
513    }, function (data) {
514
515        if (data.success == 0) {
516            var html = "";
517
518            data.errors.forEach(function (x) {
519                html += x + "<br>";
520            });
521
522            $('.waiting').html('').hide();
523            $('.' + target + '.form-errors').html(html);
524            grecaptcha.reset(widgetId);
525        }
526        else if (data.success == 1) {
527            $('.waiting').html('').hide();
528            $('.' + target).html('<b>Thank you! You are now subscribed. You will be automatically redirected to receive your free download, or <a href="/newsletter-confirmation">click here</a>.</b>');
529            window.location = "/newsletter-confirmation";
530        }
531
532    }, 'json');
533});
534
535$(document).ajaxSuccess(function (event, xhr, settings) {
536    initModal();
537});
538
539
540if (window.location.hash) {
541
542    var hash = window.location.hash.substring(1);
543    var className = '.' + hash;
544    var textName = capitaliseFirstLetter(hash);
545
546
547    $('.items-container').isotope({filter: className});
548    $('.media-name:contains("' + textName + '")').closest('li').addClass('active');
549    $(".multimedia-filter-dropdown").val(textName);
550
551
552} else {
553    // console.log("no hash");
554}
555
556
557function capitaliseFirstLetter(string) {
558    return string.charAt(0).toUpperCase() + string.slice(1);
559}
560
561initModal = function () {
562    // modals
563    $('.trigger-modal').click(function () {
564
565        // load modals dynamically
566        var type = $(this).data('type');
567        var src = $(this).data('src');
568
569        if (type == 'video') {
570            $('#videoModal iframe').attr({
571                'src': src
572            });
573        }
574        else if (type == 'image') {
575
576            var text = $(this).data('text');
577            var image = src;
578            var permalink = $(this).data('permalink');
579            var twitter_text = text;
580            var hash = $(this).data('hash');
581            var twitter_share_url = 'http://twitter.com/intent/tweet?text=' + twitter_text + '&url=' + encodeURIComponent(permalink) + '&hashtags=LouiseHay';
582            var pinterest_share_url = '//www.pinterest.com/pin/create/button/?url=' + permalink + '&media=' + image + '&description=' + text + encodeURIComponent(' #LouiseHay') + '&id=' + hash;
583            var google_share_url = 'https://plus.google.com/share?url=' + permalink;
584
585            // facebook
586            $('.image-modal .facebook-share').data('url', permalink);
587            $('.image-modal .facebook-image').data('image', permalink);
588            $('.image-modal .facebook-description').data('text', permalink);
589
590            // twitter
591            $('.image-modal .twitter-share').attr('href', twitter_share_url);
592
593
594            // pinterest
595            $('.image-modal .pinterest-share').attr('href', pinterest_share_url);
596
597            $('.image-modal .google-share').attr('href', google_share_url);
598
599            // affirmation img container
600            $('.image-image-container').html('<img class="item-thumb" src="' + image 
600+ '">');
601        }
602        else if (type == 'audio') {
603            var embed_url = 'https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/' + src + '&amp;color=ff5500&amp;auto_play=true&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false&amp;visual=true';
604
605            $('#audioModal iframe').attr({
606                'src': embed_url
607            });
608        }
609        else if (type == 'affirmation') {
610            var text = $(this).data('text');
611            var image = $(this).data('image');
612            var permalink = $(this).data('permalink');
613            var twitter_text = text;
614            var hash = $(this).data('hash');
615            var twitter_share_url = 'http://twitter.com/intent/tweet?text=' + encodeURIComponent(twitter_text) + '&url=' + encodeURIComponent(permalink) + '&hashtags=LouiseHay';
616            var pinterest_share_url = '//www.pinterest.com/pin/create/button/?url=' + permalink + '&media=' + image + '&id=' + hash + '&description=' + encodeURIComponent(text);
617            var google_share_url = 'https://plus.google.com/share?url=' + permalink;
618
619            // facebook
620            $('.affirmation-modal .facebook-share').data('url', permalink);
621            $('.affirmation-modal .facebook-image').data('image', permalink);
622            $('.affirmation-modal .facebook-description').data('text', permalink);
623
624            // twitter
625            $('.affirmation-modal .twitter-share').attr('href', twitter_share_url);
626
627            // pinterest
628            $('.affirmation-modal .pinterest-share').attr('href', pinterest_share_url);
629
630            $('.affirmation-modal .google-share').attr('href', google_share_url);
631
632            // affirmation img container
633            $('.affirmation-image-container').html('<img class="item-thumb" src="' + image 
633+ '">');
634        }
635    });
636
637    $('#videoModal,#audioModal').on('hidden.bs.modal', function () {
638        $('#videoModal iframe').attr('src', '');
639        $('#audioModal iframe').attr('src', '');
640
641        // affirmation reset
642
643        // facebook
644        $('.affirmation-modal .facebook-share').data('url', '');
645        $('.affirmation-modal .facebook-image').data('image', '');
646        $('.affirmation-modal .facebook-description').data('text', '');
647
648        // twitter
649        $('.affirmation-modal .twitter-share').attr('href', '');
650
651
652        // pinterest
653        $('.affirmation-modal .pinterest-share').attr('href', '');
654
655        // affirmation img container
656        $('.affirmation-image-container').html('');
657
658        // image reset
659
660        // facebook
661        $('.image-modal .facebook-share').data('url', '');
662        $('.image-modal .facebook-image').data('image', '');
663        $('.image-modal .facebook-description').data('text', '');
664
665        // twitter
666        $('.image-modal .twitter-share').attr('href', '');
667
668
669        // pinterest
670        $('.image-modal .pinterest-share').attr('href', '');
671
672        // affirmation img container
673        $('.image-image-container').html('');
674    });
675}
676
677$(document).ready(function () {
678
679
680    $.each(countries, function (i, item) {
681        $('#country').append($('<option>', {
682            value: item,
683            text: item
684        }));
685    });
686
687    main.searchBarInit();
688
689    $(window).resize(function () {
690        main.windowWidth = $(window).width();
691
692        waitForFinalEvent(function () {
693            //...
694            main.searchBarInit();
695        }, 500, "some unique string");
696    });
697
698    setTimeout(function () {
699        nextSlide();
700    }, 5000);
701
702    $('.products').slick({
703        dots: true,
704        infinite: false,
705        speed: 300,
706        slidesToShow: 5,
707        slidesToScroll: 5,
708        responsive: [
709            {
710                breakpoint: 1024,
711                settings: {
712                    slidesToShow: 3,
713                    slidesToScroll: 3,
714                    infinite: true,
715                    dots: true
716                }
717            },
718            {
719                breakpoint: 600,
720                settings: {
721                    slidesToShow: 2,
722                    slidesToScroll: 2
723                }
724            },
725            {
726                breakpoint: 480,
727                settings: {
728                    slidesToShow: 1,
729                    slidesToScroll: 1
730                }
731            }
732        ]
733    });
734
735    $('.topics-link').bigtext();
736
737    $('.facebook-share').click(function () {
738        var name = $(this).data('name');
739        var url = $(this).data('url');
740        var image = $(this).data('image');
741        var description = $(this).data('description');
742
743        FB.ui({
744            method: 'share',
745            href: url,
746            name: name,
747            picture: image,
748            description: description
749        });
750
751        return false;
752    });
753
754    $('#sidebar-form').submit(function (e) {
755        e.preventDefault();
756        var x = document.getElementById("agreement-sidebar");
757        if (x !== null && x.checked === true) {
758            create_recaptcha($(this));
759        } else {
760            document.getElementById('agreement-error-sidebar').innerHTML="THIS IS A REQUIRED FIELD.";
761        }
762    });
763
764    $('#footer-form').submit(function (e) {
765        e.preventDefault();
766        var x = document.getElementById("agreement-footer");
767        if (x.checked === true) {
768            create_recaptcha($(this));
769        } else {
770            document.getElementById('agreement-error-footer').innerHTML="THIS IS A REQUIRED FIELD.";
771        }
772    });
773
774    $('#homepage-form').submit(function (e) {
775        e.preventDefault();
776        var x = document.getElementById("agreement-homepage");
777        if (x.checked === true) {
778            create_recaptcha($(this));
779        } else {
780            document.getElementById('agreement-error-homepage').innerHTML="THIS IS A REQUIRED FIELD.";
781        }
782    });
783
784    $('#mobile-homepage-form').submit(function (e) {
785        e.preventDefault();
786        var x = document.getElementById("agreement-homepage-mobile");
787        if (x.checked === true) {
788            create_recaptcha($(this));
789        } else {
790            document.getElementById('agreement-error-homepage-mobile').innerHTML="THIS IS A REQUIRED FIELD.";
791        }
792    });
793    //doesn't work for the new modal popup.
794    $(document).on('submit', 'form', function (e) {
795        if ($(this).find('input[name=sp_exp]').length) {
796            create_recaptcha($(this), true, e);
797        }
798    });
799
800    //for new modal popup
801    $(document).on('click', 'button', function (e) {
802        if ($(this).closest('form').find('input[name=sp_exp]').length) {
803            create_recaptcha($(this).closest('form'), true, e);
804        }
805    });
806
807    initModal();
808
809    if ($('#trees-page').length > 0) {
810        $.each(countries, function (i, item) {
811            $('#country').append($('<option>', {
812                value: item,
813                text: item
814            }));
815        });
816        $.each(states, function (i, item) {
817            $('#state').append($('<option>', {
818                value: item,
819                text: item
820            }));
821        });
822    }
823
824    $('#country').change(function (e) {
825        if ($(this).val() !== countries.US) {
826            $('#state').val(0);
827            $('#zip').val('');
828            $('#state').prop('disabled', 'disabled');
829        } else {
830            $('#state').prop('disabled', false);
831        }
832    });
833
834    $("#uploadBtn").change(function (e) {
835        $('#image-name').html('../' + $('#uploadBtn')[0].files[0].name);
836    });
837
838    $('#treeForm').submit(function (e) {
839        e.preventDefault();
840        if (!$('#tou').prop('checked')) {
841            $('#trees-page .alert').addClass('alert-danger').html('Please read and agree to the Terms of Use.');
842            return false;
843        }
844
845        var name = $('#name').val(),
846            email = $('#email').val(),
847            street = $('#street').val(),
848            country = $('#country').val(),
849            city = $('#city').val(),
850            state = $('#state').val(),
851            zip = $('#zip').val(),
852            image = $('#uploadBtn')[0].files[0],
853            lng, lat, check = true, address = '';
854        if (!country || !city) {
855            $('#trees-page .alert').addClass('alert-danger').html('Please provide country and city where tree was planted.');
856            return false;
857        }
858        if (!name) {
859            $('#trees-page .alert').addClass('alert-danger').html('Please provide a name.');
860            return false;
861        }
862        if (!email) {
863            $('#trees-page .alert').addClass('alert-danger').html('Please provide an email.');
864            return false;
865        }
866        if (image && (image.type !== "image/jpeg" && image.type !== "image/jpg" && image.type !== 'image/png')) {
867            $('#trees-page .alert').addClass('alert-danger').html('Please provide a png or jpeg for the image.');
868            return false;
869        }
870
871        if (street) {
872            address += street + ', ';
873        }
874        address += country + ', ' + city;
875        if (state && state != 0) {
876            address += ', ' + state;
877        }
878        if (zip) {
879            address += ', ' + zip;
880        }
881        var url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' + address + '&key=AIzaSyCvokl8CztyYt5xYX3vDsPyP4XgEwF-eTw';
882        $.ajax({
883            type: 'get',
884            url: url,
885            async: false,
886            success: function (data) {
887                if (data.status !== 'ZERO_RESULTS') {
888                    lat = data.results[0].geometry.location.lat;
889                    lng = data.results[0].geometry.location.lng;
890                } else {
891                    $('#trees-page .alert').addClass('alert-danger').html("We couldn't find this location. Please try again.");
892                    check = false;
893                }
894            },
895            error: function (MLHttpRequest, textStatus, errorThrown) {
896                console.log(errorThrown);
897            }
898        });
899        if (!check) {
900            return false;
901        }
902        if(!$('#treeForm').attr('data-recaptcha-widget')) {
903            var widgetId = grecaptcha.render('gRecaptcha', {
904                'sitekey': '6Ld39SIUAAAAALld6yZd0aRHpKU9W1I2Zcs6zfis',
905                'size': 'invisible',
906                'badge': 'inline',
907                'callback': function (token) {
908                    insertTree(token, address, lat, lng, street, city, state, country, zip);
909                }
910            });
911            $('#gRecaptcha').css('display', 'none');
912            $('#treeForm').attr('data-recaptcha-widget', widgetId);
913            grecaptcha.execute(widgetId);
914        } else {
915            grecaptcha.reset();
916            grecaptcha.execute();
917        }
918
919    });
920    $('#tree-search').click(function () {
921        var input = document.getElementById('tree-search-input');
922
923        google.maps.event.trigger(input, 'focus');
924        google.maps.event.trigger(input, 'keydown', {keyCode: 13});
925    });
926
927    $('#navbaropen').on('click',function(e){
928        $(this).hide();
929        $('#navbarcollapse').show();
930    });
931    $('#navbarcollapse').on('click',function() {
932        $('.collapse').collapse('hide');
933        $(this).hide();
934        $('#navbaropen').show().addClass('collapsed');
935    });
936
937});
938
939function create_recaptcha(formElement, specialForm, e) {
940    if (!formElement.find('#gRecaptcha').length) {
941        formElement.find('input').each(function () {
942            var placeholder = $(this).attr('placeholder');
943            if (placeholder && placeholder.toLowerCase().indexOf('email') > -1) {
944                formElement.append('<div id="captcha-message"></div><div id="gRecaptcha"></div>');
945                var widgetId = grecaptcha.render('gRecaptcha', {
946                    'sitekey': '6Ld39SIUAAAAALld6yZd0aRHpKU9W1I2Zcs6zfis',
947                    'size': 'invisible',
948                    'badge': 'inline',
949                    'callback': function (token) {
950                        if (specialForm) {
951                            formElement.find('button[type=submit]').trigger('click');
952                        } else {
953                            var split = formElement.attr('id').split('-');
954                            var form_id = split.slice(0, split.length - 1).join('-');
955                            var name = formElement.find('input[name=name]').val();
956                            var email = formElement.find('input[name=email]').val();
957                            var widgetId = formElement.data('recaptcha-widget');
958                            subscribeNewsletter(form_id, name, email, token, widgetId);
959                        }
960                    }
961                });
962                $(formElement).find('.grecaptcha-badge').parent().css('display', 'none');
963                grecaptcha.execute(widgetId);
964                $(formElement).data('recaptcha-widget', widgetId);
965                if (specialForm) {
966                    e.preventDefault();
967                }
968            }
969        });
970    } else {
971        var widgetId = $(this).data('recaptcha-widget');
972        if (!grecaptcha.getResponse(widgetId)) {
973            grecaptcha.execute(widgetId);
974        }
975    }
976}
977
978function insertTree(token, address, lat, lng, street, city, state, country, zipcode) {
979    var fd = new FormData(),
980        reason = $('#reason').val(),
981        values = $('#treeForm').serialize();
982    fd.append("main_image", $('#uploadBtn')[0].files[0]);
983    fd.append("action", 'treeInsert');
984    fd.append("reason", reason);
985    fd.append("values", values);
986    fd.append("address", address);
987    fd.append("latlng", lat + ',' + lng);
988    fd.append("captcha", token);
989    fd.append("street", street);
990    fd.append("city", city);
991    fd.append("state", state);
992    fd.append("country", country);
993    fd.append("zipcode", zipcode);
994    $.ajax({
995        data: fd,
996        type: 'post',
997        url: ajaxurl,
998        processData: false,
999        contentType: false,
1000        success: function (data) {
1001            console.log(data);
1002            if (data) {
1003                $('#treeForm')[0].reset();
1004                $('#image-name').innerHTML = '';
1005                $('#trees-page .alert').removeClass('alert-danger').html('');
1006                $("#trees-page .success").removeClass('hidden');
1007            } else {
1008                $('#trees-page .alert').addClass('alert-danger').html('Something went wrong. Please try again');
1009                return false;
1010            }
1011        },
1012        error: function (MLHttpRequest, textStatus, errorThrown) {
1013            $('#trees-page .alert').addClass('alert-danger').html('Sorry there was a problem. Please try again.');
1014
1015        }
1016    });
1017}

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.