PageSourceSearch

https://www.tylerbarnettpr.com/assets/js/vendor/jquery.ajaxchimp.js

js tylerbarnettpr.com collected 2026-10-02 16:15:39 UTC 6,232 bytes, 153 lines download raw bytes

1/*!
2Mailchimp Ajax Submit
3jQuery Plugin
4Author: Siddharth Doshi
5
6*/
7
8(function ($) {
9    'use strict';
10
11    $.ajaxChimp = {
12        responses: {
13            'We have sent you a confirmation email'                                             : 0,
14            'Please enter a value'                                                              : 1,
15            'An email address must contain a single @'                                          : 2,
16            'The domain portion of the email address is invalid (the portion after the @: )'    : 3,
17            'The username portion of the email address is invalid (the portion before the @: )' : 4,
18            'This email address looks fake or invalid. Please enter a real email address'       : 5
19        },
20        translations: {
21            'en': null
22        },
23        init: function (selector, options) {
24            $(selector).ajaxChimp(options);
25        }
26    };
27
28    $.fn.ajaxChimp = function (options) {
29        $(this).each(function(i, elem) {
30            var form = $(elem);
31            var email = form.find('input[type=email]');
32            var label = form.find('label[for=' + email.attr('id') + ']');
33
34            var settings = $.extend({
35                'url': form.attr('action'),
36                'language': 'en'
37            }, options);
38
39            var url = settings.url.replace('/post?', '/post-json?').concat('&c=?');
40
41            form.attr('novalidate', 'true');
42            email.attr('name', 'EMAIL');
43
44            form.submit(function () {
45                var msg;
46                function successCallback(resp) {
47                    if (resp.result === 'success') {
48                        msg = 'We have sent you a confirmation email';
49                        label.removeClass('error').addClass('valid');
50                        email.removeClass('error').addClass('valid');
51                    } else {
52                        email.removeClass('valid').addClass('error');
53                        label.removeClass('valid').addClass('error');
54                        var index = -1;
55                        try {
56                            var parts = resp.msg.split(' - ', 2);
57                            if (parts[1] === undefined) {
58                                msg = resp.msg;
59                            } else {
60                                var i = parseInt(parts[0], 10);
61                                if (i.toString() === parts[0]) {
62                                    index = parts[0];
63                                    msg = parts[1];
64                                } else {
65                                    index = -1;
66                                    msg = resp.msg;
67                                }
68                            }
69                        }
70                        catch (e) {
71                            index = -1;
72                            msg = resp.msg;
73                        }
74                    }
75
76                    // Translate and display message
77                    if (
78                        settings.language !== 'en'
79                        && $.ajaxChimp.responses[msg] !== undefined
80                        && $.ajaxChimp.translations
81                        && $.ajaxChimp.translations[settings.language]
82                        && $.ajaxChimp.translations[settings.language][$.ajaxChimp.responses[msg]]
83                    ) {
84                        msg = $.ajaxChimp.translations[settings.language][$.ajaxChimp.responses[msg]];
85                    }
86                    label.html(msg);
87
88                    label.show(2000);
89                    if (settings.callback) {
90                        settings.callback(resp);
91                    }
92                }
93
94                var data = {};
95                var dataArray = form.serializeArray();
96                $.each(dataArray, function (index, item) {
97                    data[item.name] = item.value;
98                });
99
100                $.ajax({
101                    url: url,
102                    data: data,
103                    success: successCallback,
104                    dataType: 'jsonp',
105                    error: function (resp, text) {
106                        console.log('mailchimp ajax submit error: ' + text);
107                    }
108                });
109
110                // Translate and display submit message
111                var submitMsg = 'Submitting...';
112                if(
113                    settings.language !== 'en'
114                    && $.ajaxChimp.translations
115                    && $.ajaxChimp.translations[settings.language]
116                    && $.ajaxChimp.translations[settings.language]['submit']
117                ) {
118                    submitMsg = $.ajaxChimp.translations[settings.language]['submit'];
119                }
120                label.html(submitMsg).show(2000);
121
122                return false;
123            });
124        });
125        return this;
126    };
127})(jQuery);
128
129
130
131/* --------------------------------------------------
132    Your info from MailChimp goes bellow
133-------------------------------------------------- */
134(function ($) {
135    
136    "use strict";
137
138    $('.mc-ajax').ajaxChimp({
139        callback: mailchimpCallback,
140        // Replace this with your own url, id and user code (see documentation). 
141        url: "http://viktorandonov.us8.list-manage.com/subscribe/post?u=0d1613dc78dfba6e3ad02aaa5&id=25d4404c02" 
142    });
143
144    function mailchimpCallback(resp) {
145        if (resp.result === 'success') {
146            $('.subscribe-result').hide().html('<div class="alert alert-success alert-dismissible wow fadeInUp" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><strong>Thank you!</strong><br>You must confirm the subscription in your inbox.</div>').slideDown().delay(10000).slideUp();
147        }
148        else if (resp.result === 'error') {
149            $('.subscribe-result').hide().html('<div class="alert alert-danger alert-dismissible wow fadeInUp" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>' + resp.msg + '</div>').slideDown().delay(10000).slideUp();
150        }
151    }
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.