1//************************************** 2//********** MODULE 1: SLIDER ********** 3//************************************** 4 5$(window).on("load", () => { 6 $(".template-module .slider").each(function() { 7 var slider = $(this), 8 prev = slider.parent().find(".slider-arrows .prev"), 9 next = slider.parent().find(".slider-arrows .next"), 10 hasAutoplay = slider.parent().hasClass("has-autoplay"); 11 12 13 slider.slick({ 14 slidesToShow: 1, 15 slidesToScroll: 1, 16 autoplay: hasAutoplay, 17 speed:1000, 18 fade: false, 19 arrows: true, 20 prevArrow: prev, 21 nextArrow: next, 22 dots: false 23 }); 24 25 slider.find(".video .play").click(function() { 26 slider.slick("slickPause"); 27 }); 28 }); 29}); 30 31 32//************************************** 33//********** MODULE 11: VIDEO ********** 34//************************************** 35 36$(".template-module .video a.play").click(function(e) { 37 var src = $(this).siblings("iframe").data("src"); 38 39 $(".template-module .video iframe").removeAttr("data-src") 40 41 $(this).siblings("iframe").attr("src", src); 42 $(this).parents(".video").addClass("open"); 43}); 44 45 46/***************************************/ 47/*********** FORM VALIDATION ***********/ 48/***************************************/ 49 50 51 52var url_page = window.location.href, idioma = url_page.replace(location.origin, ""); 53 54idioma = idioma.split("/"); 55 56if(idioma[1] == "pt") 57{ 58 var stringEmpty = "Por favor, preencha este campo", 59 stringInvalid = "Por favor, preencha este campo com um valor válido"; 60} 61else 62{ 63 var stringEmpty = "Please fill this field", 64 stringInvalid = "Please fill this field with a valid amount"; 65} 66 67 68function checkForm(form) { 69 form = $(form); 70 71 var type, val, 72 valid = true, 73 regex_telm = /\+[0-9]|[0-9]/, 74 regex_zip = /[0-9]{4}\-[0-9]{3}/, 75 regex_email = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 76 77 form.find(".warning").remove(); 78 form.find(":input").each(function() { 79 type = $(this).data("type") || $(this).attr("type") || "text"; 80 val = $(this).val(), 81 isReq = $(this).is("[required]"); 82 83 $(this).removeClass("not-filled"); 84 85 if($(this).parents(".honey-input").length > 0 && val != "") { 86 valid = false; 87 return false; 88 } else if(type != "hidden") { 89 if(isReq && (type == "checkbox" || type == "radio")) { 90 var name = $(this).attr("name"), 91 isChecked = false; 92 93 form.find("input[name='" + name + "']").each(function() { 94 if($(this).is(":checked")) 95 isChecked = true; 96 }); 97 98 if(!isChecked) { 99 $(this).addClass("not-filled"); 100 101 valid = false; 102 } 103 } else if(isReq && val == "") { 104 $(this).parent().append("<p class='warning'>" + stringEmpty + "</p>"); 105 106 $(this).addClass("not-filled"); 107 valid = false; 108 } else if((type == "email" && val != "" && !regex_email.test(val)) || 109 (type == "phone" && val != "" && !regex_telm.test(val)) || 110 (type == "zip" && val != "" && !regex_zip.test(val))) { 111 $(this).parent().append("<p class='warning'>" + stringInvalid + "</p>"); 112 $(this).addClass("not-filled"); 113 valid = false; 114 } 115 } 116 }); 117 118 119 if(!valid) { 120 var first = $(".not-filled:first"); 121 if(first.is("[type='checkbox']")) first = $(".not-filled:first + label"); 122 123 $("html, body").animate({scrollTop: first.offset().top - ($(window).height() / 2)}, Math.abs($(window).scrollTop() - first.offset().top)); 124 125 return false; 126 } 127 128 return true 129} 130 131function submitForm(form) { 132 133 if(checkForm(form)) { 134 var action = form.data("action"), 135 goTo = form.data("goto"); 136
137 if(goTo == "https://genpro.ruralbit.com/login0.php") 138 { 139 var form_inputs = ""; 140 141 $(form).find(":input").each(function (index, element) { 142 form_inputs = form_inputs + "<input type='hidden' name='"+ $(this).attr("name") +"' value='"+ $(this).val() +"' />"; 143 }); 144 145 var form_to_submit = $('<form action="' + goTo + '" method="post" target="_blank">' + form_inputs + '</form>'); 146 $('body').append(form_to_submit); 147 form_to_submit.submit(); 148 } 149 else 150 { 151 152 if(action) { 153 form.find("[submit]").addClass("disabled"); 154 155 if(form.find("input[type='file']").length > 0) { 156 var data = new FormData(), 157 options; 158 159 form.find(":input").each(function() { 160 if($(this).is("[type='file']")) 161 data.append($(this).attr("name"), $(this)[0].files[0]) 162 else 163 data.append($(this).attr("name"), $(this).val()) 164 }); 165 166 options = { 167 method: "POST", 168 url: action, 169 data: data, 170 processData: false, 171 contentType: false, 172 cache: false 173 }; 174 } else { 175 var data = form.find(":input").serialize(), 176 options = { 177 method: "POST", 178 url: action, 179 data: data 180 }; 181 } 182 183 $.ajax(options).done(function(response) { 184 if(response) { 185 response = JSON.parse(response); 186 var c = document.createElement("p"); 187 c.innerHTML = response.message 188 189 if(response.reload) { 190 swal({ 191 title: $("h1").text(), 192 content: c, 193 icon: response.type 194 }).then(() => { 195 window.location.reload(); 196 }); 197 198 return false; 199 } else { 200 swal({ 201 title: $("h1").text(), 202 content: c, 203 icon: response.type 204 }).then(() => { 205 console.log("1"); 206 window.location.href = goTo; 207 }); 208 209 return false; 210 } 211 } 212 console.log("2"); 213 window.location.href = goTo; 214 }); 215 } 216 } 217 } 218} 219 220 221$(".form [submit]").click(function() { 222 var form = $(this).parents(".form"); 223 submitForm(form) 224}); 225$(".form").on("keydown", function(e) { 226 if(e.keyCode == 13 && !$(e.target).is("textarea")) 227 submitForm($(this)) 228}); 229 230/*********** CHECK IF INPUT IS FILLED ***********/ 231 232function inputFilled(input) { 233 if(input.val() != "") 234 input.parent().addClass("filled"); 235 else 236 input.parent().removeClass("filled"); 237} 238 239$(document).on("keyup", ".form .input-wrapper :input", function() { 240 inputFilled($(this)) 241}); 242$(document).on("change", ".form .input-wrapper select", function() { 243 inputFilled($(this)) 244}); 245$(document).ready(function() { 246 $(".form .input-wrapper :input, .form .input-wrapper select").each(function() { 247 inputFilled($(this)) 248 }); 249}); 250 251 252/***************************************/ 253/********** FORM CLONING AREA **********/ 254/***************************************/ 255 256function cloningAreaClone(wrapper) { 257 var input = wrapper.find("> input.length"), 258 div = wrapper.find(">
258 div:first-child").clone(), 259 options_max = wrapper.find(".button.clone").data("max"); 260 261 262 div.find(":input").val(""); 263 div.find(".input-wrapper").removeClass("filled"); 264 div.find(":input").removeClass("not-filled"); 265 div.find("p.warning").remove(); 266 267 268 div.insertBefore(wrapper.find(".button.clone")); 269 input.val(wrapper.find("> div").length); 270 271 div.find(":input").each(function() { 272 var input = $(this), 273 name = input.attr("name"), 274 id = input.attr("id"), 275 label = div.find("label[for='" + id + "']"); 276 277 input.attr("name", name + "-" + (wrapper.find("> div").length - 1)); 278 input.attr("id", id + "-" + (wrapper.find("> div").length - 1)); 279 label.attr("for", id + "-" + (wrapper.find("> div").length - 1)) 280 }); 281 282 div.find("div.custom-select").remove(); 283 div.find("select.custom-select").each(function() { 284 $(this).customSelect(); 285 }); 286 287 wrapper.find(".close").removeClass("d-none"); 288 289 if($(".cloning-wrapper > div").length == options_max) 290 { 291 $(".form .cloning-wrapper .button.clone").addClass("d-none"); 292 } 293 294} 295 296$(".form .cloning-wrapper .button.clone").on("click", function() { 297 cloningAreaClone($(this).parents(".cloning-wrapper")); 298}); 299 300$(document).on("blur", ".form .cloning-wrapper > div :input", function() { 301 var parent = $(this).parents(".cloning-wrapper"), 302 flag = false; 303 304 parent.find("> div").each(function() { 305 $(this).find(":input").each(function() { 306 if($(this).val() != "") { 307 flag = true; 308 return false; 309 } 310 }); 311 }); 312 313 314 315 if(flag) 316 parent.find(".button.clone").removeClass("d-none"); 317 else 318 parent.find(".button.clone").addClass("d-none"); 319}); 320 321$(document).on("click", ".form .cloning-wrapper .close", function() { 322 323 var parent = $(this).parents(".cloning-wrapper > div"), 324 index = parent.index(), 325 length = $(this).parents(".cloning-wrapper").find("> div").length; 326 327 console.log(parent); 328 console.log(index); 329 console.log(length); 330 331 if(length > 1) { 332 333 console.log(parent.nextAll("div")); 334 335 parent.nextAll("div").each((i, e) => { 336 337 console.log("entra "+ i); 338 339 $(e).find(":input").each((j, el) => { 340 var input = $(el), 341 name = input.attr("name"), 342 id = input.attr("id"), 343 label = $(e).find("label[for='" + id + "']"); 344 345 name = name.split("-"); 346 name.pop(); 347 348 id = id.split("-"); 349 id.pop(); 350 351 name = name.join("-"); 352 id = id.join("-"); 353 354 if(index === 0 && i === 0) { 355 input.attr("name", name); 356 input.attr("id", id); 357 label.attr("for", id); 358 } else { 359 name = name + "-" + (index + i); 360 id = id + "-" + (index + i); 361 362 input.attr("name", name); 363 input.attr("id", id); 364 label.attr("for", id); 365 } 366 }); 367 }); 368 369 parent.siblings(".length").val(length - 1); 370 if(length - 1 === 1) 371 parent.siblings().find(".close").addClass("d-none"); 372 373 parent.remove(); 374 375 if ($(".cloning-wrapper > div").length < $(".form .cloning-wrapper .button.clone").data("max")) 376 { 377 $(".form .cloning-wrapper .button.clone").removeClass("d-none"); 378 } 379 380 381 } 382});
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.