1if (typeof isIE != 'function') { 2 function isIE(){ 3 var ua = window.navigator.userAgent; 4 5 return ua.indexOf('MSIE ') > 0 || ua.indexOf('Trident/') > 0 || ua.indexOf('Edge/') > 0 6 } 7} 8 9jQuery(document).ready(function($){ 10 // console.log(gloo_otp_action); 11 12 $("form[data-gloo-otp]").each(function(){ 13 gloo_otp_action = $(this).attr('data-gloo-otp'); 14 gloo_otp_action = JSON.parse(gloo_otp_action); 15 submit_button = $(this).find('button[type="submit"]'); 16 17 if(submit_button.length >= 1){ 18 old_label = submit_button.text(); 19 $(this).attr('data-label', old_label.trim()); 20 21 if(typeof gloo_otp_action != 'undefined' && gloo_otp_action.otp_type != 'undefined'){ 22 23 if(gloo_otp_action.otp_button_label != 'undefined'){ 24 $(this).attr('data-form-id', gloo_otp_action.form_id); 25 } 26 27 if(gloo_otp_action.otp_button_label != 'undefined'){ 28 submit_button.text(gloo_otp_action.otp_button_label); 29 $(this).attr('data-label-otp', gloo_otp_action.otp_button_label); 30 } 31 // if(gloo_otp_action.otp_type == 'email'){ 32 // if(typeof gloo_otp_action.otp_frontend_heading != 'undefined' && gloo_otp_action.otp_frontend_heading) 33 // submit_button.text(gloo_otp_action.otp_frontend_heading); 34 // }else if(gloo_otp_action.otp_type == 'sms'){ 35 // if(typeof gloo_otp_action.otp_frontend_heading_sms != 'undefined' && gloo_otp_action.otp_frontend_heading_sms) 36 // submit_button.text(gloo_otp_action.otp_frontend_heading_sms); 37 // } 38 } 39 } 40 41 }); 42 43 44 45 $(document).ajaxComplete(function(event, xhr, options){ 46 47 if(typeof xhr != 'undefined' && typeof options != 'undefined' && typeof options.data != 'undefined' && typeof options.data.has != 'undefined' && options.data.has('form_id') && options.data.has('action') && options.data.get('action') == 'elementor_pro_forms_send_form'){ 48 if(typeof xhr.responseText != 'undefined' && xhr.responseText){ 49 var response = JSON.parse(xhr.responseText); 50 var form_id = options.data.get('form_id'); 51 parent_form = $("form[data-form-id='"+form_id+"']"); 52 if(typeof response != 'undefined' && response && typeof response.success != 'undefined' && parent_form.length >= 1 && typeof response.data != 'undefined' && typeof response.data.otp_length != 'undefined' /*&& typeof response.data.frontend_heading != 'undefined'*/ && typeof response.data.form_id != 'undefined' && response.data.form_id == form_id){ 53 54 // parent_form = parent_form.closest('form'); 55 var otp_length = Number(response.data.otp_length); 56 if (!response.success && otp_length) { 57 parent_form.find('.elementor-message').removeClass('elementor-message-danger').addClass('elementor-message-success'); 58 parent_form.find('.elementor-message').remove(); 59 parent_form.find('.gloo-otp-container').remove(); 60 container_html = '<div class="gloo-otp-container elementor-field-group">'; 61 container_html += '<div class="gloo-otp-box">'; 62 container_html += '<div class="gloo-otp-channel">'; 63 //<p>'+response.data.frontend_heading+'</p> 64 container_html += '<div class="gloo-otp-heading"></div>'; 65 container_html += '<div class="gloo-otp-inputs">'; 66 for(i=0; i < otp_length; i++){ 67 container_html += '<input class="gloo-otp-input" name="form_fields[gloo_otp]['+i+']" type="tel" maxlength="1" data-index="'+i+'" required="required">'; 68 } 69 container_html += '</div><!-- gloo-otp-input-->'; 70 container_html += '</div><!-- gloo-otp-channel-->'; 71 container_html += '</div><!-- gloo-otp-box-->'; 72 container_html += '</div><!-- gloo-otp-container-->'; 73 parent_form.find('button[type="submit"]').closest('.elementor-field-group').before(container_html); 74 parent_form.find('button[type="submit"]').text(parent_form.attr('data-label')); 75 76 let display_message = parent_form.closest('.elementor-element').find('.gloo_otp_heading_container').html(); 77 // if(typeof response.data.renew_message != 'undefined' && response.data.renew_message) 78 // display_message = response.data.renew_message; 79 parent_form.find(".gloo-otp-heading").html(display_message); 80 } 81 }else if(typeof response != 'undefined' && response && typeof response.success != 'undefined' && response.success == true && parent_form.length >= 1){ 82 parent_form.find('.gloo-otp-container').remove(); 83 parent_form.find('button[type="submit"]').text(parent_form.attr('data-label-otp')); 84 } 85 } 86 } 87 88 }); 89 90 $(document).on('keyup', '.gloo-otp-container input', function(e){ 91 var allowed_keys = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105];
92 if($(this).val() && allowed_keys.includes(e.keyCode)){ 93 $(this).next().focus(); 94 } 95 }); 96 $(document).on('paste', '.gloo-otp-container input', function(e){ 97 var content = ''; 98 if (isIE()) { 99 //IE allows to get the clipboard data of the window object. 100 content = window.clipboardData.getData('text'); 101 } else { 102 //This works for Chrome and Firefox. 103 content = e.originalEvent.clipboardData.getData('text/plain'); 104 } 105 106 if(typeof content == 'string' && content && content != '' && content.length >= 2){ 107 current_object = $(this); 108 for (var i = 0; i < content.length; i++) { 109 if(current_object.hasClass('gloo-otp-input')){ 110 current_object.val(content.charAt(i)); 111 current_object = current_object.next(); 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.