PageSourceSearch

https://www.trendforce.com/news/wp-content/themes/twentyten/tf_resources/js/php/contact-form.js

js trendforce.com collected 2026-09-24 08:31:56 UTC 3,306 bytes, 89 lines download raw bytes

1/*
2--------------------------------
3Ajax Contact Form
4--------------------------------
5+ https://github.com/pinceladasdaweb/Ajax-Contact-Form
6+ A Simple Ajax Contact Form developed in PHP with HTML5 Form validation.
7+ Has a fallback in jQuery for browsers that do not support HTML5 form validation.
8+ version 1.0.1
9+ Copyright 2014 Pedro Rogerio
10+ Licensed under the MIT license
11+ https://github.com/pinceladasdaweb/Ajax-Contact-Form
12*/
13
14(function ($, window, document, undefined) {
15    'use strict';
16
17    $(document).ready(function () {
18        $('.form-ajax').each(function (index) {
19            var form = this;
20            var sendToEmail = $(this).attr("data-email");
21            if (isEmpty(sendToEmail)) sendToEmail = '';
22            var subject = $(this).attr("data-subject");
23            if (isEmpty(subject)) subject = '';
24
25            $(form).submit(function (e) {
26                // remove the error class
27                $('.form-group').removeClass('has-error');
28                $('.help-block').remove();
29
30                // Google reCaptcha
31                if ((typeof grecaptcha !== 'undefined') && $(this).find(".g-recaptcha").length) {
32                    if (grecaptcha.getResponse().length === 0) {
33                        e.preventDefault;
34                        return false;
35                    }
36                }
37
38                $(form).find(".cf-loader").show();
39
40                // get the form data
41                var formData = {
42                    'values': {},
43                    'domain': window.location.hostname.replace("www.", ""),
44                    'email': sendToEmail,
45                    'subject_email': subject
46                };
47
48                $(form).find(".form-value").each(function () {
49                    var val = $(this).val();
50                    if (!isEmpty(val)) {
51                        var name = $(this).attr("data-name");
52                        if (isEmpty(name)) name = $(this).attr("name");
53                        if (isEmpty(name)) name = $(this).attr("id");
54                        var error_msg = $(this).attr("data-error");
55                        if (isEmpty(error_msg)) error_msg = "";
56                        formData['values'][name] = [val, error_msg];
57                    }
58                });
59
60                // process the form
61                $.ajax({
62                    type: 'POST',
63                    url: $(form).attr("action"),
64                    data: formData,
65                    dataType: 'json',
66                    encode: true
67                }).done(function (data) {
68                    if (!data.success) {
69                        // Error
70                        console.log(data);
71                        $(form).find(".error-box").show();
72                    } else {
73                        // Success
74                        $(form).html($(form).find(".success-box").html());
75                    }
76                    $(form).find(".cf-loader").hide();
77                }).fail(function (data) {
78                    // Error
79                    console.log(data);
80                    $(form).find(".error-box").show();
81                    $(form).find(".cf-loader").hide();
82                });
83
84                e.preventDefault();
85            });
86        });
87    });
88
89}(jQuery, window, document));

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.