1jQuery.noConflict(); 2 jQuery(document).ready(function(){ 3 jQuery('.infos_trigger').click(function(){ 4 jQuery(this).next('.infos_content').slideToggle(); 5 jQuery(this).next('.infos_content').toggleClass('on'); 6 }); 7 }); 8 jQuery(document).ready(function(){ 9 cp_autocomplete(); 10 ville_autocomplete(); 11 }); 12 jQuery(document).ready(function(){ 13 // GENERATE ARRAY VALIDATOR 14 jQuery('.contact_inner').each(function(){ 15 var elmt = jQuery(this); 16 var parent = elmt.parent(); 17 var id = elmt.attr('id'); 18 19 var array_validation_contact = {}; 20 jQuery("#"+id+" input[required], #"+id+" select[required], #"+id+" textarea[required]").each(function(){ 21 var name = jQuery(this).attr("name"); 22 var value = 'false'; 23 array_validation_contact[name] = value; 24 }); 25 26 jQuery("#"+id+" input, #contact_inner select").focus(function(){ 27 var value = jQuery(this).attr("name"); 28 29 var info_form = jQuery(".infos_retour_"+value); 30 info_form.empty(); 31 32 jQuery(this).removeClass("unvalid").addClass("actif valid"); 33 jQuery(this).next(".infos").addClass("decale"); 34 }); 35 36 jQuery("#"+id+" .input ").click(function(){ 37 var name = jQuery(this).find('input').attr("name"); 38 39 var info_form = jQuery(".infos_retour_"+name); 40 info_form.empty(); 41 42 jQuery(this).find('input').focus(); 43 jQuery(this).find('input').removeClass("unvalid").addClass("actif valid"); 44 jQuery(this).find('input').next(".infos").addClass("decale"); 45 }); 46 47 jQuery("#"+id+" input[required], #"+id+" select[required], #"+id+" textarea[required]").on('blur click change',function(){ 48 var name = jQuery(this).attr("name"); 49 var value = jQuery(this).val(); 50 var info_form = jQuery(".infos_retour_"+name); 51 52 if(value == undefined){ 53 info_form.html("<span class='rouge'>Obligatoire</span>"); 54 } 55 else { 56 switch(name){ 57 default: // CHANGE TYPE OF VALIDATION -> BASE ON input TYPE 58 case 'nom': 59 case 'prenom': 60 case 'telephone': 61 if(value == '') { 62 jQuery(this).removeClass("valid").addClass("unvalid"); 63 info_form.html("<i class='fal fa-times-circle' style='color:red'></i>"); // 64 array_validation_contact[name] = 'false'; 65 }else{ 66 jQuery(this).removeClass("unvalid").addClass("valid"); 67 info_form.html("<i class='fal fa-check-circle' style='color:green'></i>"); // 68 array_validation_contact[name] = 'true'; 69 } 70 break; 71 case 'email': 72 var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; 73 var emailaddressVal = jQuery(this).val(); 74 75 if(emailaddressVal == '') { 76 jQuery(this).removeClass("valid").addClass("unvalid"); 77 info_form.html("<i class='fal fa-times-circle' style='color:red'></i>"); 78 array_validation_contact[name] = 'false'; 79 } 80 else if(!emailReg.test(emailaddressVal)) { 81 jQuery(this).removeClass("valid").addClass("unvalid"); 82 info_form.html("<i class='fal fa-times-circle' style='color:red'></i>"); 83 array_validation_contact[name] = 'false'; } 84 else { 85 jQuery(this).removeClass("unvalid").addClass("valid"); 86 info_form.html("<i class='fal fa-check-circle' style='color:green'></i>"); 87 array_validation_contact[name] = 'true'; 88 } 89 break; 90 case 'type': 91 var Type = jQuery(this); 92 if(Type.val() == '' ) { 93 jQuery(this).removeClass("valid").addClass("unvalid"); 94 info_form.html("<i class='fal fa-times-circle' style='color:red'></i>"); 95 array_validation_contact[name] = 'false'; 96 } 97 else { 98 jQuery(this).removeClass("unvalid").addClass("valid"); 99 info_form.html("<i class='fal fa-check-circle' style='color:green'></i>"); 100 array_validation_contact[name] = 'true'; 101 } 102 break; 103 case 'rgpd': 104 var RGPD = jQuery(this); 105 if(!RGPD.is(':checked')) {
106 jQuery(this).removeClass("valid").addClass("unvalid"); 107 info_form.html("<i class='fal fa-times-circle' style='color:red'></i>"); 108 array_validation_contact[name] = 'false'; 109 } 110 else { 111 jQuery(this).removeClass("unvalid").addClass("valid"); 112 info_form.html("<i class='fal fa-check-circle' style='color:green'></i>"); 113 array_validation_contact[name] = 'true'; 114 } 115 break; 116 } 117 118 if(jQuery.inArray('false', getValues(array_validation_contact)) != '-1'){ 119 jQuery('#'+id+' .envoyer').css('background-color','#402b37'); 120 texte = 'unvalid'; 121 }else{ 122 jQuery('#'+id+' .envoyer').css('background-color','#402b37'); 123 texte = 'valid'; 124 } 125 console.log(array_validation_contact); 126 } 127 128 }); // FIN BLUR 129 130 function getValues(array){ 131 var return_array = []; 132 var values = Object.keys(array).map(function(e) { 133 return_array.push(array[e]); 134 }); 135 return return_array; 136 } 137 138 jQuery('#'+id).submit(function(e) { 139 console.log('submit'); 140 console.log(array_validation_contact); 141 142 if(jQuery.inArray('false', array_validation_contact) == '-1'){ 143 e.preventDefault(); 144 grecaptcha.enterprise.ready(async () => { 145 const token = await grecaptcha.enterprise.execute('6LfLlzMnAAAAAMkscWulbuo50SEJaL5PCuLMTG6N', {action: 'contactForm2023'}); 146 // IMPORTANT: The 'token' that results from execute is an encrypted response sent by 147 // reCAPTCHA Enterprise to the end user's browser. 148 // This token must be validated by creating an assessment. 149 // See https://cloud.google.com/recaptcha-enterprise/docs/create-assessment 150 // Add your logic to submit to your backend server here. 151 jQuery.ajax({ 152 type:"POST", 153 data: jQuery("#"+id).serialize()+"&captcha_token="+token, 154 url:"formulaires_example/envoi_mail.php", 155 beforeSend : function(){ 156 parent.html('<i class="fa fa-circle-notch fa-spin"></i>'); 157 }, 158 success: function(returnMessage){ 159 returnMessage = JSON.parse(returnMessage); 160 console.log('RETOUR = > '+ returnMessage[0].text); 161 parent.html(returnMessage[0].text); 162 } 163 }); 164 }); 165 }else{ 166 var texte_alert = ARRAY_TRAD.RENSEIGNER_TOUS_LES_CHAMPS[lang].content; // GET TRANSLATION 167 //texte_alert += 'Vous n\'avez pas renseigner les champs : \r\n'; 168 jQuery.each(array_validation_contact, function(i, val){ 169 if(val == 'false') { 170 console.log(texte_alert); 171 texte_alert += i+" \r\n"; 172 } 173 }); 174 //alert(texte_alert); 175 jQuery.fancybox.open({ 176 src : "<div id='popUp' class='centre'>"+texte_alert+"</div>", 177 type : 'html', 178 opts : { 179 modal : false, 180 touch: false, 181 }, 182 smallBtn : true, 183 showCloseBtn : true, 184 toolbar : false, 185 186 }); 187 return false; 188 } 189 return false; 190 }); 191 }); 192}); 193 194function cp_autocomplete(){ 195 if(jQuery("input[cp_autocomplete]").length > 0){ 196 jQuery("input[cp_autocomplete]").each(function(index, elmt){ 197 jQuery(elmt).parent('div').append("<div id='cp_autocomplete_container"+index+"'></div>"); 198 jQuery(elmt).attr('index', index); 199 jQuery(elmt).autocomplete({ 200 appendTo: "#cp_autocomplete_container"+index, 201 source: function (request, response) { 202 jQuery.ajax({ 203 url: "https://vicopo.selfbuild.fr/cherche/"+jQuery("input[cp_autocomplete][index="+index+"]").val(), //https://api-adresse.data.gouv.fr/search/?postcode= 204 //data: { q: request.term }, 205 dataType: "json", 206 success: function (data) { 207 var cities = []; 208 response(jQuery.map(data.cities, function (item) { 209 // Ici on est obligé d'ajouter les CP dans un array pour ne pas avoir plusieurs fois le même 210 if (jQuery.inArray(item.city, cities) == -1) { 211 cities.push(item.city); 212 return { label: item.code + " - " + item.city, 213 city: item.city, 214 postcode : item.code, 215 value: item.code 216 }; 217 } 218 })); 219 } 220 }); 221 }, 222 // On remplit aussi le CP 223 // On remplit aussi la ville 224 select: function(event, ui) { 225 console.log(ui.item); 226 jQuery(elmt).parents('form').find("input[cp_autocomplete][index="+index+"]").val(ui.item.postcode).change(); 227 jQuery(elmt).parents('form').find("input[ville_autocomplete][index="+index+"]").val(ui.item.city).change(); 228 jQuery(elmt).parents('form').find("input[ville_autocomplete][index="+index+"]").focus(); 229 } 230 }); 231 }); 232 } 233} 234function ville_autocomplete(){ 235 if(jQuery("input[ville_autocomplete]").length > 0){ 236 jQuery("input[ville_autocomplete]").each(function(index, elmt){ 237 jQuery(elmt).parent('div').append("<div id='ville_autocomplete_container"+index+"'></div>"); 238 jQuery(elmt).attr('index', index); 239 jQuery(elmt).autocomplete({ 240 appendTo: "#ville_autocomplete_container"+index, 241 source: function (request, response) { 242 jQuery.ajax({ 243 url: "https://vicopo.selfbuild.fr/cherche/"+jQuery("input[ville_autocomplete][index="+index+"]").val(), //https://api-adresse.data.gouv.fr/search/?city= 244 //data: { q: request.term }, 245 dataType: "json", 246 success: function (data) { 247 var cities = []; 248 response(jQuery.map(data.cities, function (item) { 249 // Ici on est obligé d'ajouter les villes dans un array pour ne pas avoir plusieurs fois la même 250 if (jQuery.inArray(item.city, cities) == -1) { 251 cities.push(item.city); 252 return { label: item.code + " - " + item.city, 253 postcode: item.code, 254 city : item.city, 255 value: item.city 256 }; 257 } 258 })); 259 } 260 }); 261 }, 262 // On remplit aussi le CP 263 // On remplit aussi la ville 264 select: function(event, ui) { 265 console.log(ui.item); 266 jQuery(elmt).parents('form').find("input[cp_autocomplete][index="+index+"]").val(ui.item.postcode).change(); 267 jQuery(elmt).parents('form').find("input[ville_autocomplete][index="+index+"]").val(ui.item.city).change(); 268 jQuery(elmt).parents('form').find("input[ville_autocomplete][index="+index+"]").focus(); 269 } 270 }); 271 }); 272 } 273} 274
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.