PageSourceSearch

https://venngage.com/blog/wp-content/themes/venngage_v2/js/email-octopus.js

js venngage.com collected 2026-10-01 07:30:05 UTC 3,949 bytes, 91 lines download raw bytes

1$( document ).ready(function() {
2    if (window.__venngage_email_octopus_loaded__) return;
3    window.__venngage_email_octopus_loaded__ = true;
4    var emailOctopus = {
5        missingEmailAddressMessage: 'Your email address is required.',
6        missingNamesMessage: 'Please enter your first name and last name.',
7        invalidEmailAddressMessage: 'Your email address looks incorrect, please try again.',
8        botSubmissionErrorMessage: 'This doesn\'t look like a human submission.',
9        unknownErrorMessage: 'Sorry, an unknown error has occurred. Please try again later.',
10        isBotPost: function() {
11            return $('.email-octopus-form-row-hp input').val();
12        },
13        basicValidateEmail: function(email) {
14            var regex = /\S+@\S+\.\S+/;
15            return regex.test(email);
16        },
17        ajaxSuccess: function() {
18            $('.email-octopus-success-message').show();
19            $('.email-octopus-form').hide();
20            $('.email-octopus-form-info').hide();
21        },
22        ajaxError: function(textStatus) {
23            var response = $.parseJSON(textStatus.responseText);
24            if (response && response.error && response.error.code) {
25                switch(response.error.code) {
26                    case 'INVALID_PARAMETERS':
27                        $('.email-octopus-error-message').text(
28                            emailOctopus.invalidParametersErrorMessage
29                        );
30                        return;
31                    case 'BOT_SUBMISSION':
32                        $('.email-octopus-error-message').text(
33                            emailOctopus.botSubmissionErrorMessage
34                        );
35                        return;
36                }
37            }
38
39            $('.email-octopus-error-message').text(
40                emailOctopus.unknownErrorMessage
41            );
42        },
43        ajaxSubmit: function(form) {
44            $.ajax({
45                type: form.attr('method'),
46                url: form.attr('action'),
47                data: form.serialize(),
48                success: function() {
49                    emailOctopus.ajaxSuccess();
50                },
51                error: function(textStatus) {
52                    emailOctopus.ajaxError(textStatus);
53                }
54            });
55        }
56    };
57
58    window.__venngage_email_octopus_trigger_submit__ = function(form) {
59            $('.email-octopus-error-message').empty();
60            var emailAddress = $(form).find('.email-octopus-email-address').val();
61            var requireName = false;
62            var firstName = '';
63            var lastName = '';
64
65            // If there are first/last name inputs, then make them required.
66            if ($(form).find('.email-octopus-first-name').length > 0 && $(form).find('.email-octopus-last-name').length > 0) {
67                requireName = true;
68                firstName = $(form).find('.email-octopus-first-name').val();
69                lastName = $(form).find('.email-octopus-last-name').val();
70            }
71
72            if (emailOctopus.isBotPost()) {
73                $('.email-octopus-error-message').text(
74                    emailOctopus.botSubmissionErrorMessage
75                );
76            } else if (!$.trim(emailAddress)) {
77                $('.email-octopus-error-message').text(emailOctopus.missingEmailAddressMessage);
78            } else if (requireName && (!$.trim(firstName) || !$.trim(lastName))) {
79                $('.email-octopus-error-message').text(emailOctopus.missingNamesMessage);
80            } else if (!emailOctopus.basicValidateEmail(emailAddress)) {
81                $('.email-octopus-error-message').text(emailOctopus.invalidParametersErrorMessage);
82            } else {
83                emailOctopus.ajaxSubmit($(form));
84            }
85    };
86
87    $('.email-octopus-form').submit(function(e) {
88        window.__venngage_email_octopus_trigger_submit__(this);
89        return false;
90    });
91});

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.