PageSourceSearch

https://www.johnsondodge.net/wp-content/plugins/pm-motors-plugin/m…/js/sms-friend-form.js?ver=1.1

js johnsondodge.net collected 2026-09-29 22:15:10 UTC 5,594 bytes, 153 lines download raw bytes

1var SMSFriendForm = {};
2
3(function ($) {
4    var SMSFriendForm = {
5        vehicles: [],
6        trimAcodes: {},
7
8        vehicleFields: {
9            make: null,
10            model: null,
11            year: null,
12            trim: null
13        },
14
15        init: function () {
16            SMSFriendForm.populateHiddenFields();
17            SMSFriendForm.eventHandlers();
18        },
19
20        populateHiddenFields: function () {
21            $('#source_url').val(window.location.href);
22            $('#source_host').val(window.location.hostname);
23            $('#source_path').val(window.location.pathname);
24            $('#refererURL').attr("value", window.location.href);
25            $('#clickedatField').val(window.sessionStorage.getItem("gform-modal-clicked-at"));
26        },
27
28        addDashes: function (input, num1, num2) {
29            var val = $(input).val();
30            var regex = /(\d)/g;
31            var matches = val.match(regex);
32            if (val.length > num1 && val.length <= num2) {
33                matches.splice(num1, 0, '-');
34            }
35            if (val.length > num2) {
36                matches.splice(num1, 0, '-');
37                matches.splice(num2 + 1, 0, '-');
38            }
39            var val = matches.join('');
40            $(input).val(val);
41        },
42
43        checkPhoneNumber: function (input) {
44            SMSFriendForm.addDashes(input, 3, 6);
45        },
46
47        checkValidation: function (btn) {
48            var valid = true;
49            $(btn).parents('.panel-body').find('.sms-friend-input').each(function () {
50                if (!$(this)[0].checkValidity())
51                    valid = false;
52            });
53            if (!valid) {
54                // trigger submit button click to activate html5 msgs; ('submit') without ':' doesn't work for whatever reason
55                $('#sms-friend-form').find(':submit').click();
56                return false;
57            } else {
58                return true;
59            }
60        },
61
62        errorNotification: function (msg) {
63            msg = msg || 'Please complete all required fields';
64            $("#sms-friend-form .form-error").html(msg);
65            clearTimeout(SMSFriendForm.errorNotification.timer);
66            $('.form-error').fadeIn('fast');
67            SMSFriendForm.errorNotification.timer = setTimeout(function () {
68                $('.form-error').fadeOut();
69            }, 7000);
70        },
71
72        updateRequiredInformation: function (field) {
73            var phoneoremail = $(field).val();
74            if (phoneoremail == 'email') {
75                $('.emailrequired').show();
76                $('#email').attr("required", true);
77                $('.phonerequired').hide();
78                $('#phone').attr("required", false);
79            }
80            if (phoneoremail == 'phone') {
81                $('#phone').attr("required", true);
82                $('.phonerequired').show();
83                $('#email').attr("required", false);
84                $('.emailrequired').hide();
85
86            }
87        },
88
89        eventHandlers: function () {
90            $('.phone-input').on('keyup', function (e) {
91                if (e.keyCode == 8) return;
92                SMSFriendForm.checkPhoneNumber(this);
93            });
94
95            $('#emailorphone').on('change', function () {
96                SMSFriendForm.updateRequiredInformation(this);
97            })
98
99            $('.sms-friend-input').on('invalid', SMSFriendForm.errorNotification);
100
101            $('#smsFriendModal #preferredmethodofcontactField').on('change', function () {
102                SMSFriendForm.getDescriptionForDropdown(this);
103            });
104
105            $('#sms-friend-form input, #sms-friend-form textarea').on('focus', function name(params) {
106                if (sessionStorage.getItem("gform-modal-clicked-at") == null &&
107                    'DataLayer' in window) {
108                    DataLayer.setClickedAtValue();
109                }
110            });
111
112            $('#sms-friend-form input').on('click', function () {
113                if ($('#clickedatField').val() !== true && 'DataLayer' in window) {
114                    DataLayer.setClickedAtValue();
115                    $('#clickedatField').val(window.sessionStorage.getItem("gform-modal-clicked-at"))
116                }
117            });
118
119            $(document.body).on("click", ".sms-friend-btn", function() {
120                var vin = $(this).data("vin");
121                $(".hidden-group #vin").val(vin);
122
123                if("VLP" in window){                    
124                    var vehicle = VLP.getVehicle(vin);
125                    $("#source_url").val(window.location.origin + vehicle.vdp_href);
126                }
127
128            });
129
130            $('form#sms-friend-form').submit(function () {
131                // FRONT CAPTCHA CHECK 
132                var captchaResponse = grecaptcha.getResponse();
133                if (captchaResponse.length === 0) {
134                    SMSFriendForm.errorNotification('Please complete the captcha');
135                    return false;
136                }
137
138                let leadId = PmGforms.generateLeadId();
139                PmGforms.addHiddenField($(this), 'leadId', leadId);
140                let formTitle = 'SMS A Friend';
141                let displayType = 'page';
142                let prefContact = $('#preferredmethodofcontactField').val();
143
144                let vin = '';
145                PmGforms.pmGFormSubmit(this, leadId, formTitle, displayType, vin, prefContact);
146                return false;
147            });
148        }
149    };
150    $(document).ready(function(){
151        SMSFriendForm.init();
152    });
153})(jQuery);

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.