1function oxypp_setup_form_field(element_id, field_name, field_type, tab_index, textarea_rows, textarea_cols, field_value, form_options, additional_class, required, placeholder, enable_input_mask, input_mask_format) { 2 new Promise((resolve) => setTimeout(resolve, 600)).then(() => { 3 if (required == "" || required == "false") required = ""; 4 else required = " opprequired"; 5 var isBuilder = jQuery("body").hasClass("oxygen-builder-body"); 6 var field = ""; 7 var value = field_value; 8 if (isBuilder) tab_index = "-1"; 9 10 if (field_type == "submit" && value == "") value = "Submit"; 11 12 if (additional_class.trim() != "") { 13 additional_class = ' class="' + additional_class.trim() + '"'; 14 } else additional_class = ""; 15 16 if (form_options.trim() != "") { 17 form_options = atob(form_options); 18 form_options = JSON.parse(form_options); 19 } else { 20 form_options = []; 21 } 22 23 for (var i = 0; i < form_options.length; i++) { 24 form_options[i].label = decodeURIComponent(escape(atob(form_options[i].label.replace("oxy_base64_encoded::", "")))); 25 form_options[i].value = decodeURIComponent(escape(atob(form_options[i].value.replace("oxy_base64_encoded::", "")))); 26 } 27 28 switch (field_type) { 29 case "simple_captcha": 30 field = '<input name="simple_captcha_number_1" type="hidden" value="' + (Math.floor(Math.random() * 49) + 1) + '">'; 31 field += '<input name="simple_captcha_number_2" type="hidden" value="' + (Math.floor(Math.random() * 49) + 1) + '">'; 32 field += '<input id="' + element_id + '_field" name="simple_captcha" type="text" tabindex="' + tab_index + '" value=""' + additional_class + "" + required + ">"; 33 break; 34 case "select": 35 field = '<select name="' + field_name + '" id="' + element_id + '_field"' + additional_class + "" + required + ">"; 36 for (var i = 0; i < form_options.length; i++) { 37 field += ' <option value="' + form_options[i].value + '">' + form_options[i].label + "</option>"; 38 } 39 field += "</select>"; 40 break; 41 case "radio": 42 field = '<div class="power-form-radio-group"' + required + ">"; 43 for (var i = 0; i < form_options.length; i++) { 44 field += ' <div class="power-form-radio-container">'; 45 field += ' <input id="' + element_id + "_field_" + i + '" name="' + field_name + '" type="' + field_type + '" tabindex="' + tab_index + '" value="' + form_options[i].value + '"' + additional_class + ">"; 46 field += ' <label for="' + element_id + "_field_" + i + '">' + form_options[i].label + "</label>"; 47 field += " </div>"; 48 } 49 field += "</div>"; 50 break; 51 case "textarea": 52 field = '<textarea id="' + element_id + '_field" name="' + field_name + '" tabindex="' + tab_index + '" rows="' + textarea_rows + '" cols="' + textarea_cols + '"' + additional_class + "" + required + ' placeholder="' + placeholder + '">' + value + "</textarea>"; 53 break; 54 default: 55 if (enable_input_mask === "true" && field_type === "tel") { 56 field = '<input id="' + element_id + '_field" name="' + field_name + '" type="' + field_type + '" tabindex="' + tab_index + '" value="' + value + '"' + additional_class + "" + required + ' placeholder="' + placeholder + '" data-inputmask-format="' + input_mask_format + '">'; 57 } else { 58 field = '<input id="' + element_id + '_field" name="' + field_name + '" type="' + field_type + '" tabindex="' + tab_index + '" value="' + value + '"' + additional_class + "" + required + ' placeholder="' + placeholder + '">'; 59 } 60 } 61 jQuery("#" + element_id + " label") 62 .first() 63 .attr(field_type, ""); 64 if (field_type == "submit") jQuery("#" + element_id + " label[submit]").remove(); 65 jQuery("#" + element_id + " .power-form-field-wrapper").prepend(field); 66 if (field_type == "simple_captcha") jQuery("#" + element_id + " label").html(jQuery("#" + element_id + ' input[name="simple_captcha_number_1"]').val() + " + " + jQuery("#" + element_id + ' input[name="simple_captcha_number_2"]').val() + " ="); 67 68 if (field_type === "checkbox") { 69 var spanVerificationCheck = jQuery("#" + element_id + " .power-form-field-wrapper").find("span"); 70 jQuery("#" + element_id + " .power-form-field-wrapper") 71 .find("span") 72 .remove(); 73 jQuery("#" + element_id).append(spanVerificationCheck); 74 spanVerificationCheck.css("display", "none"); 75 } 76 }); 77} 78 79jQuery(function () { 80 // Enable Input Masks with its formats 81 var inputPhone = jQuery("[data-inputmask-format]"); 82 var numberPhoneFormat = inputPhone.attr("data-inputmask-format"); 83 inputPhone.inputmask(numberPhoneFormat); 84 85 var forms = jQuery("form.oxy-power-form"); 86 var inputsRecaptcha = jQuery('input[name="recaptcha"]'); 87 var sitekey = ""; 88 89 // If only there are some inputs to active google recaptcha api 90 if (inputsRecaptcha.length > 0) {
91 sitekey = inputsRecaptcha[0].getAttribute("data-sitekey"); 92 jQuery("head").append(`
vendor: 81 bytes, line 92
92<script src="https://www.google.com/recaptcha/api.js?render=${sitekey}"></script>
92`); 93 } 94 95 jQuery.each(forms, function (i, form) { 96 form = jQuery(this); 97 form.on("submit", function (event) { 98 event.preventDefault(); 99 event.stopPropagation(); 100 101 var status_validate_form = false; 102 var inputbutton = form.find('input[type="submit"]').first(); 103 var inputRecaptcha = form.find('input[name="recaptcha"]'); 104 105 // The action when recaptcha is enable 106 if (inputRecaptcha.val() !== undefined && sitekey !== "") { 107 grecaptcha.ready(function () { 108 grecaptcha 109 .execute(sitekey, { action: "submit" }) 110 .then(function (token) { 111 status_validate_form = formValidate(form, inputbutton); 112 if (status_validate_form) { 113 form.append(`<input type="hidden" name="token" value="${token}"/>`); 114 send_to_server(form, inputbutton); 115 } 116 }) 117 .catch(function (err) { 118 alert("Recatpcha is not available"); 119 console.log(err); 120 }); 121 }); 122 } else { 123 status_validate_form = formValidate(form, inputbutton); 124 if (status_validate_form) { 125 send_to_server(form, inputbutton); 126 } 127 } 128 }); 129 }); 130 131 // Function for validate forms 132 function formValidate(form, inputbutton) { 133 form.find(".power-form-field-wrapper span").slideUp(); 134 form.find('input[type="checkbox"]').closest(".oxy-power-form-field").find("span").slideUp(); 135 136 inputbutton.attr("oppval", inputbutton.val()).val("...")[0].disabled = true; 137 var validated = true; 138 139 form.find("[opprequired]") 140 .not('input[type="submit"]') 141 .each(function () { 142 if (jQuery(this).is("div")) { 143 if (jQuery(this).find(":checked").length == 0) { 144 jQuery(this).closest(".label-and-field-wrapper").find("span").slideDown(); 145 validated = false; 146 } 147 } else { 148 if (jQuery(this).is('[type="checkbox"]') && !jQuery(this).is(":checked")) { 149 jQuery(this).closest(".oxy-power-form-field").find("span").slideDown(); 150 validated = false; 151 } else if (!jQuery(this).is('[type="checkbox"]') && jQuery(this).val().trim() == "") { 152 jQuery(this).closest(".power-form-field-wrapper").find("span").slideDown(); 153 validated = false; 154 } 155 } 156 }); 157 158 if (!validated) { 159 inputbutton.val(inputbutton.attr("oppval"))[0].disabled = false; 160 return validated; 161 } 162 163 return validated; 164 } 165 166 // Function to send to server side for verification it 167 function send_to_server(form, inputbutton) { 168 jQuery 169 .ajax({ 170 url: location.pathname + (location.pathname.match(/[\?]/g) ? "&" : "?") + "oppPowerFormSubmission", 171 type: "POST", 172 dataType: "json", 173 data: form.serialize(), 174 }) 175 .done(function (result) { 176 if (typeof result.error != "undefined" && result.error != false) { 177 if (result.message == "Invalid Captcha") { 178 form.find('input[name="simple_captcha"]').closest(".power-form-field-wrapper").find("span").slideDown(); 179 } 180 alert(result.message); 181 } else { 182 if (result.message != "") alert(result.message); 183 if (typeof oxyPowerPackEvents != "undefined") oxyPowerPackEvents.trigger("powerform-submitted", { form: form }); 184 form[0].reset(); 185 if (form.find('input[name="simple_captcha"]').length > 0) { 186 var element_id = form.find('input[name="simple_captcha"]').first().closest(".oxy-power-form-field").first().attr("id"); 187 jQuery("#" + element_id + ' input[name="simple_captcha_number_1"]').val(Math.floor(Math.random() * 49) + 1); 188 jQuery("#" + element_id + ' input[name="simple_captcha_number_2"]').val(Math.floor(Math.random() * 49) + 1); 189 jQuery("#" + element_id + " label").html(jQuery("#" + element_id + ' input[name="simple_captcha_number_1"]').val() + " + " + jQuery("#" + element_id + ' input[name="simple_captcha_number_2"]').val() + " ="); 190 } 191 } 192 }) 193 .fail(function (result) { 194 alert("Something went wrong sending your form. Please try again."); 195 }) 196 .always(function () { 197 inputbutton.val(inputbutton.attr("oppval"))[0].disabled = false; 198 }); 199 return false; 200 } 201});
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.