PageSourceSearch

https://www.indospace.in/wp-content/plugins/miniorange-otp-verification/includes/js/mogravity.js?ver=5.5.6

js indospace.in collected 2026-09-26 02:05:44 UTC 6,702 bytes, 117 lines download raw bytes

1jQuery(document).on('gform_post_render', function (event, form_id) {
2    const $mo = window.$mo || window.jQuery;
3
4    let loaderHtml = '<div class="moloader"></div>';
5    let sendOtpHtml = '<div class="mo_gravity_validate">\
6                            <input type="button" name="mo_send_otp_gravity" id="mo_send_otp_gravity" style="margin-top: 15px;' + mogravity.buttonCSS + '" value="' + mogravity.buttonText + '" />\
7                            <div id="mo_message" style="background-color: #f7f6f7;padding: 1em 2em 1em 3.5em; display:none;"></div>\
8                        </div>';
9
10    Object.keys(mogravity.formDetails).forEach(function (formId) {
11        if (formId == form_id) {
12            if (formId in mogravity.formDetails) {
13                let fieldKey = mogravity.otpType === 'mo_gf_contact_email_enable' ? mogravity.formDetails[formId]['emailkey'] : mogravity.formDetails[formId]['phonekey'];
14
15                $mo(sendOtpHtml).insertAfter($mo("#input_" + formId + "_" + fieldKey));
16
17                $mo("#mo_send_otp_gravity").off('click').on('click', function (e) {
18                    let userInput = $mo("#input_" + formId + "_" + fieldKey).val();
19
20                    $mo("#mo_message").show().empty().append(loaderHtml);
21
22                    $mo.ajax({
23                        url: mogravity.siteURL,
24                        type: "POST",
25                        data: {
26                            user_phone: userInput,
27                            user_email: userInput,
28                            action: mogravity.gaction,
29                            security: mogravity.nonce
30                        },
31                        crossDomain: true,
32                        dataType: "json",
33                        success: function (response) {
34                            if (response.result == "error") {
35                                $mo("#mo_message").empty().append(response.message).css({
36                                    "background-color": "#ffefef",
37                                    "color": "#ff5b5b"
38                                });
39                            } else {
40                                $mo("#mo_message").empty().append(response.message).css({
41                                    "background-color": "#dbfff7",
42                                    "color": "#008f6e"
43                                });
44                            }
45                        },
46                        error: function (xhr, status, error) {
47                            console.error('AJAX Error:', error);
48                            $mo("#mo_message").empty().append("An error occurred. Please try again.").css({
49                                "background-color": "#ffefef",
50                                "color": "#ff5b5b"
51                            });
52                        }
53                    });
54                });
55
56                // Initialize or reinitialize intlTelInput for the phone input field
57                let phoneInput = $mo("#input_" + formId + "_" + fieldKey)[0]; // Get the DOM element
58
59                if (phoneInput && !$mo(phoneInput).data('intlTelInputInitialized') && mogravity.isDropdownEnabled && mogravity.otpType === 'mo_gf_contact_phone_enable') {
60                    $mo("<input id='country_code' name='country_code' type='hidden'>").insertAfter(phoneInput);
61                    var allowed = Array.isArray(modropdownvars.onlyCountries)
62                                            ? modropdownvars.onlyCountries.map(function(c){ return (c.alphacode || "").toLowerCase(); })
63                                            : [];
64                    let moCountryCode = window.intlTelInput(phoneInput, { // Use the DOM element
65                        initialCountry: modropdownvars.defaultCountry,
66                        nationalMode: false,
67                        onlyCountries: allowed.filter(Boolean),
68                        // intl-tel-input v25+ expects a function returning names for hidden inputs.
69                        // Preserve previous behavior by creating a hidden input named "full".
70                        hiddenInput: function (originalName) {
71                            return { phone: "full" };
72                        },
73                    });
74
75                    let selectedCountryData = moCountryCode.getSelectedCountryData();
76                    $mo("#country_code").val(selectedCountryData.dialCode);
77
78                    let moCodeLength = selectedCountryData.dialCode.length + 1;
79                    let restrictedPositions = Array.from({ length: moCodeLength }, (_, index) => index + 1);
80                    
81                    $mo(phoneInput).on('countrychange', function () {
82                        let selectedCountryData = moCountryCode.getSelectedCountryData();
83
84                        if (typeof selectedCountryData.dialCode !== "undefined") {
85                            $mo("#country_code").val(selectedCountryData.dialCode);
86                            let moCodeLength = selectedCountryData.dialCode.length + 1;
87                            restrictedPositions = Array.from({ length: moCodeLength }, (_, index) => index + 1);
88                        }
89                    });
90
91                    $mo(".intl-tel-input.allow-dropdown, .iti.iti--allow-dropdown").css({ "width": "100%" });
92                    $mo(".intl-tel-input.allow-dropdown input[type='tel'], .iti.iti--allow-dropdown .iti__tel-input").css({ "width": "100%" });
93
94                    if (!$mo("#mo-gravity-intl-tel-style").length) {
95                        $mo("head").append(
96                            "<style id='mo-gravity-intl-tel-style'>" +
97                            ".gform_wrapper .iti .iti__selected-country," +
98                            ".gform_wrapper .iti .iti__selected-country:focus," +
99                            ".gform_wrapper .iti .iti__selected-country:hover{background-color:transparent !important;color:inherit;border:0;box-shadow:none;}" +
100                            "</style>"
101                        );
102                    }
103
104                    $mo(phoneInput).keydown(function (event) {
105                        if (restrictedPositions.includes(event.target.selectionStart)) {
106                            const key = event.key || event.keyCode;
107
108                            if (key === "Backspace" || key === 8 || key === 37 || key === "ArrowLeft" || key === "a") {
109                                event.preventDefault();
110                            }
111                        }
112                    });
113                }
114            }
115        }
116    });
117});

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.