PageSourceSearch

https://www.yathit.com/assets/js/contact_us.js

js yathit.com collected 2026-10-02 07:41:01 UTC 2,573 bytes, 84 lines download raw bytes

1function getFormData($form) {
2    var unindexed_array = $form.serializeArray();
3    var indexed_array = {};
4
5    $.map(unindexed_array, function (n, i) {
6        indexed_array[n['name']] = n['value'];
7    });
8
9    indexed_array['other'] = '';
10    ['p0', 'p1', 'p2', 'r0', 'r1', 's0', 's1', 'd0', 'd1'].forEach((x) => {
11        if (Object.keys(indexed_array).indexOf(x) >= 0) {
12            indexed_array['other'] += x + ' ';
13        }
14    });
15
16    return indexed_array;
17}
18
19
20$('button[type="submit"]').click(function (ev) {
21    var btn = $(this).get(0);
22    var form = $('#contactus');
23    ev.preventDefault();
24
25    var data = getFormData(form);
26    data['type'] = location.pathname;
27
28    console.log('submit now', data);
29    btn.setAttribute('disabled', '1');
30
31    data['usercount'] = data['usercount'] || 0;
32
33    form.find('.has-error').removeClass('has-error');
34
35    $.ajax({
36        type: "POST",
37        url: 'https://www.yathit.com/feedback/trial-request.json',
38        data: JSON.stringify(data),
39        dataType: 'json',
40        contentType: 'application/json',
41        success: function (data) {
42            btn.textContent = 'SUBMITTED';
43            btn.removeAttribute('disabled');
44            console.log(data);
45            if (data.error) {
46                toastr.error(data.message);
47                if (data.field) {
48                    form.find('input[name="' + data.field + '"]').parent('.form-group').addClass('has-error');
49                }
50            } else {
51                toastr.success(data.message);
52                form.html('<div class="alert alert-success" role="alert">' + data.message + '</div>');
53            }
54
55        },
56        error: function (xhr, status) {
57            btn.removeAttribute('disabled');
58            console.log(status);
59            var msg = xhr.responseText;
60            if (/json/.test(xhr.getResponseHeader('content-type'))) {
61                try {
62                    var data = JSON.parse(xhr.responseText);
63                    msg = Object.values(data.errors).join('\n');
64                } catch (e) {
65                    console.warn('expecting json respond');
66                }
67            }
68            toastr.error(msg, 'Error updating');
69
70        }
71    });
72});
73
74function quoteForProduct(pid) {
75    document.querySelector('input[name=' + pid + ']').checked = true;
76}
77
78if (location.search.indexOf('quote=p0') >= 0) {
79    quoteForProduct('p0');
80} else if (location.search.indexOf('quote=p1') >= 0) {
81    quoteForProduct('p1');
82} else if (location.search.indexOf('quote=p2') >= 0) {
83    quoteForProduct('p2');
84}

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.