1// Documents 2$(document).ready(function () { 3var loader = '<img src="'+PATH+'lib/images/ajax-loader3.gif" alt="Chargement" class="center-block text-center no-float" id="loader_ajax" />'; 4var path_controller = PATH + 'controllers/ct_ajx.contact.ins.php'; 5 6/** 7 * Fonction appelée au clic sur "continuer" de l'étape 1 de l'inscription, sert à chercher les villes ayant pour code postal celui du champ "Code postal" 8 * */ 9function instantiateCodePostal() { 10 11 // $('#villePatient').click(function() { 12 // $('#codePostalPatient').autocomplete( "search", "" ); 13 14 // }); 15 16 17 $('#codePostalPatient').autocomplete({ 18 minLength: 0, 19 source : getVilleCodePostal(), 20 select: function( event, ui ) { 21 event.preventDefault(); 22 $("#villePatient").val(ui.item.commune); 23 $("#codePostalPatient").val(ui.item.cp); 24 //Cette ligne permet de mettre à jour la validation champ code Postal quand l'utilisateur clique sur un des résultats de l'autocomplete (au dessus) 25 $('#inscriptionContact2').data('bootstrapValidator').updateStatus($("#codePostalPatient"), 'NOT_VALIDATED').validateField($("#codePostalPatient")); 26 }, 27 }); 28 29 $('#villePatient').click(function() { 30 console.log("a"); 31 $('#villePatient').autocomplete({ 32 minLength: 0, 33 // source: sourceAutocomplete, 34 source: $("#codePostalPatient").autocomplete( "option", "source"), 35 select: function( event, ui ) { 36 event.preventDefault(); 37 $("#villePatient").val(ui.item.commune); 38 //Cette ligne permet de mettre à jour la validation champ code Postal quand l'utilisateur clique sur un des résultats de l'autocomplete (au dessus) 39 $('#inscriptionContact2').data('bootstrapValidator').updateStatus($("#codePostalPatient"), 'NOT_VALIDATED').validateField($("#codePostalPatient")); 40 } 41 }); 42 $('#villePatient').autocomplete("search", ""); 43 }); 44 45 function getVilleCodePostal() { 46 return function (requete, reponse) { 47 if ($('#codePostalPatient').val().length > 2 && $('#codePostalPatient').val().length <= 5) { 48 if (/^(-|\+)?(\d+|Infinity)$/.test($('#codePostalPatient').val())) { 49 $.ajax({ 50 url: PATH + 'controllers/ct_ajx.contact.ins.php', 51 type: 'POST', 52 dataType: 'json', 53 data: 'codePostalInscription=' + $('#codePostalPatient').val(), 54 success: function (donnee) { 55 reponse($.map(donnee, function (item) { 56 return { 57 value: item.commune + ' ' + item.codepostal, 58 cp: item.codepostal, 59 commune: item.commune 60 }; 61 })); 62 } 63 }); 64 } 65 } 66 }; 67 } 68} 69 70function instantiateNaissanceAutofill() { 71 $('#naissancePatient').keypress(function(event) { 72 if(event.key != "/" && event.key != "-") { 73 if(this.value.length == 2 || this.value.length == 5) { 74 $("#naissancePatient").val($("#naissancePatient").val()+"/"); 75 76 } 77 } 78 // if(event.which != 8) { 79 80 // } 81 }); 82} 83// Generate a simple captcha 84function randomNumber(min, max) { 85 return Math.floor(Math.random() * (max - min + 1) + min); 86}; 87$('#captchaOperation').html([randomNumber(1, 10), '+', randomNumber(1, 10), '='].join(' ')); 88//CHOIX MEDECIN 89$(document).on('click', "#btnRemUserIns", function (event) { 90 unsetSessIns(0); 91 location.reload(); 92}); 93$(document).on('click', "#btnRemContactIns", function (event) { 94 unsetSessIns(1); 95 $(this).closest('.form-group').addClass('hidden'); 96 $('#zoneEmailIns').removeClass('hidden'); 97 $('#passwordPatient').val(''); 98 $('#passwordPatient_c').val(''); 99 $('#zonePassIns').removeClass('hidden'); 100 return false; 101}); 102$('#nomUser').autocomplete({ 103 minLength: 1, 104 source : function(requete, reponse){ 105 $('#inscriptionContact1').data('bootstrapValidator').updateStatus('nomUser', 'INVALID').validateField('nomUser'); 106 $.ajax({ 107 url : path_controller, 108 dataType : 'json', 109 data : { 110 recherche : 'praticien', 111 query : $('#nomUser').val(), 112 maxRows : 5 113 }, 114 success : function(donnee){ 115 reponse($.map(donnee, function(item){ 116 return { 117 value: item.nomUser + ' ' + item.prenomUser + ' (' + item.nomSociete + ')', 118 idSociete: item.idSociete, 119 idUser: item.idUser 120 } 121 })); 122 } 123 }); 124 }, 125 select: function( event, ui ) { 126 $("#idSociete").val(ui.item.idSociete); 127 $("#idUser").val(ui.item.idUser); 128 $('#inscriptionContact1').data('bootstrapValidator').updateStatus('nomUser', 'VALID').validateField('nomUser'); 129 } 130}); 131$('#inscriptionContact1').bootstrapValidator({ 132 feedbackIcons: { 133 valid: 'glyphicon glyphicon-ok', 134 invalid: 'glyphicon glyphicon-remove', 135 validating: 'glyphicon glyphicon-refresh' 136 }, 137 fields: { 138 nomUser: { 139 validators: { 140 notEmpty: { 141 message: 'Veuillez indiquer et sélectionner le nom de votre praticien. <br> Votre praticien doit adhérer au service pour pouvoir vous inscrire.' 142 }, 143 // stringLength: { 144 // message: 'Le nom de votre praticien doit contenir au moins 3 lettres.', 145 // max: function (value, validator, $field) { 146 // return 3 - (value.match(/\r/g) || []).length; 147 // } 148 // } 149 } 150 } 151 } 152}).on('success.form.bv', function(e) { 153 // Prevent form submission 154 e.preventDefault(); 155 var $target = $('#thanks'); 156 var $form = $(e.target), 157 validator = $form.data('bootstrapValidator'), 158 submitButton = validator.getSubmitButton(); 159 //.1. 160 $.ajax({ 161 type: "POST", 162 url: path_controller,
163 data: $('form#inscriptionContact1').serialize(), 164 beforeSend: function(){ 165 $target.append(loader); 166 }, 167 success: function(msg){ 168 $('#loader_ajax').remove(); 169 $target.html(msg); 170 loadFormValidator(); 171 return true; 172 } 173 }); 174}); 175//ETAPE 3 VALIDATION INFOS 176$(document).on('click', "#btn_identification", function (event) { 177 var $target = $('#thanks'); 178 $.ajax({ 179 type: "POST", 180 url: path_controller, 181 data: $('form#inscriptionContact3').serialize(), 182 beforeSend: function(){ 183 $target.append(loader); 184 }, 185 success: function(msg){ 186 $('#loader_ajax').remove(); 187 if(msg == 1){ 188 $('#btn_identification').parent().prepend('<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>Erreur !</strong> Un ou plusieurs champs sont manquants</div>'); 189 }else if(msg == 2){ 190 $('#btn_identification').parent().prepend('<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>Erreur !</strong> Votre mot de passe n\'est pas valide pour cette adresse e-mail</div>'); 191 }else{ 192 $("#help").html(); 193 $("#thanks").html(msg); 194 } 195 return true; 196 } 197 }); 198 event.preventDefault(); 199}); 200// VALIDATION SMS 201$(document).on('click', "#btn_validation", function (event) { 202 var $target = $('#validationSmsContact'); 203 var $targetLoad = $('#thanks'); 204 //.3. 205 $.ajax({ 206 type: "POST", 207 url: path_controller, 208 data: $('form#validationSmsContact').serialize(), 209 beforeSend: function(){ 210 $('#divApresAccepte').after(loader); 211 }, 212 success: function(msg){ 213 $('#loader_ajax').remove(); 214 $("#validationSmsContact").html(msg); 215 return true; 216 } 217 }); 218 event.preventDefault(); 219}); 220 221$("#thanks").on('click','#accepteEnvoieSms', function(event) { 222 var loader = '<img src="'+PATH+'lib/images/ajax-loader3.gif" alt="Chargement" class="center-block text-center no-float" id="loader_ajax" />'; 223 event.preventDefault(); 224 console.log("coucou"); 225 var $target = $('#formSms'); 226 var targetLoad = $('#divApresAccepte'); 227 228 $.ajax({ 229 type: "POST", 230 url: PATH + 'controllers/ct_ajx.contact.ins.php',
231 data: $('form#formSms').serialize(), 232 beforeSend: function(){ 233 targetLoad.append(loader); 234 }, 235 success: function(msg){ 236 $('#loader_ajax').remove(); 237 $('#formSms').remove(); 238 $("#divApresAccepte").html(msg); 239 return true; 240 } 241 }); 242}); 243function unsetSessUserIns(){ 244 return $.ajax({ 245 type: "POST", 246 url: path_controller, 247 data : {unsetSessUserIns : '1'}, 248 async: false, 249 cache: false 250 }); 251} 252function unsetSessIns(type){ 253 return $.ajax({ 254 type: "POST", 255 url: path_controller, 256 data : {unsetSessIns : type}, 257 async: false, 258 cache: false 259 }); 260} 261/*DIVERS*/ 262function loadFormValidator(){ 263 sourceAutocomplete = ''; 264 instantiateCodePostal(); 265 instantiateNaissanceAutofill(); 266 var $mob = $('#mobile').val();//var mob = $('#inp_mob').val(); 267 var $valid_mob = ''; 268 var $message_mob = 'Vous devez inscrire un numéro MOBILE'; 269 $regex_mob = /^(0)[0-9]{9}$/; 270 if($mob == 1){ 271 $valid_mob = ",notEmpty: {message: 'Veuillez indiquer votre numéro de téléphone'}"; 272 var $message_mob = 'Vous devez inscrire un numéro de téléphone.'; 273 }else if($mob == 2){ 274 $valid_mob = ",notEmpty: {message: 'Veuillez indiquer votre numéro de mobile'}"; 275 var $message_mob = 'Vous devez inscrire un numéro MOBILE pour confirmer votre code reçu par sms'; 276 $regex_mob = /^(06|07)[0-9]{8}$/; 277 } 278 $('#captchaOperation').html([randomNumber(1, 10), '+', randomNumber(1, 10), '='].join(' ')); 279 $('#infos').tooltip(); 280 281 $('#inscriptionContact2').bootstrapValidator({ 282 feedbackIcons: { 283 valid: 'glyphicon glyphicon-ok', 284 invalid: 'glyphicon glyphicon-remove', 285 validating: 'glyphicon glyphicon-refresh' 286 }, 287 fields: { 288 nomPatient: { 289 validators: { 290 notEmpty: { 291 message: 'Veuillez indiquer votre nom de famille' 292 }, 293 regexp: { 294 regexp: /[a-zA-ZÃÃÃÃÃÃÃÃÃÃÃà âçèéêëîôöùû]+$/, 295 message: 'Votre nom ne doit pas contenir de caractères autres que des minuscules, des majuscules, des caractères avec accent et des espaces' 296 } 297 } 298 }, 299 prenomPatient: { 300 validators: { 301 notEmpty: { 302 message: 'Veuillez indiquer votre prénom' 303 }, 304 regexp: { 305 regexp: /[a-zA-ZÃÃÃÃÃÃÃÃÃÃÃà âçèéêëîôöùû]+$/, 306 message: 'Votre prénom ne doit pas contenir de caractères autres que des minuscules, des majuscules, des caractères avec accent et des espaces' 307 } 308 } 309 }, 310 emailPatient: { 311 validators: { 312 notEmpty: { 313 message: 'Votre adresse e-mail est vide' 314 }, 315 emailAddress: { 316 message: 'Veuillez indiquer une adresse e-mail valide' 317 } 318 } 319 }, 320 emailPatient_c: { 321 validators: { 322 notEmpty: { 323 message: 'Veuillez confirmer votre adresse e-mail.' 324 }, 325 identical: { 326 field: 'emailPatient', 327 message: 'Vous devez confirmer la même adresse e-mail' 328 } 329 } 330 }, 331 codePostal: { 332 validators: { 333 notEmpty: { 334 message:'Veuillez entrer votre code postal.' 335 }, 336 regexp: { 337 regexp: /^(\d{5})$/, 338 message: 'Veuillez entrer votre code postal (5 chiffres).' 339 } 340 } 341 }, 342 villePatient: { 343 validators: { 344 notEmpty: { 345 message:'Veuillez entrer votre ville.' 346 } 347 } 348 }, 349 adressePatient: { 350 validators: { 351 notEmpty: { 352 message:'Veuillez entrer votre adresse.' 353 } 354 } 355 }, 356 medecinTraitantPatient: { 357 validators: { 358 notEmpty: { 359 message: 'Veuillez entrer le nom de votre médecin traitant.' 360 } 361 } 362 }, 363 naissancePatient: { 364 validators: { 365 notEmpty: { 366 message:'Veuillez entrer votre date de naissance.' 367 }, 368 regexp: { 369 regexp: /(\d{2})(-|\/)(\d{2})(-|\/)(\d{4})$/, 370 message: 'Veuillez entrer votre date de naissance (JJ-MM-AAAA ou JJ/MM/AAAA).' 371 } 372 } 373 }, 374 portPatient: { 375 enabled : false, 376 validators: { 377 regexp: { 378 /*regexp: /^(06|07)[0-9]{8}$/,*/ 379 regexp: $regex_mob, 380 message: $message_mob 381 }, 382 notEmpty: { 383 message: 'Veuillez indiquer votre numéro de téléphone' 384 }, 385 } 386 }, 387 passwordPatient: { 388 validators: { 389 notEmpty: { 390 message: 'Vous devez indiquer un mot de passe.' 391 }, 392 stringLength: { 393 min: '4', 394 message: 'Le mot de passe doit contenir plus de 4 caractères.' 395 } 396 } 397 }, 398 passwordPatient_c: { 399 validators: { 400 notEmpty: { 401 message: 'Veuillez confirmer votre mot de passe.' 402 }, 403 identical: { 404 field: 'passwordPatient', 405 message: 'Vous devez confirmer le même mot de passe.' 406 } 407 } 408 }, 409 captcha: { 410 validators: { 411 callback: { 412 message: 'Captcha incorrect', 413 callback: function(value, validator) { 414 var items = $('#captchaOperation').html().split(' '), sum = parseInt(items[0]) + parseInt(items[2]); 415 return value == sum; 416 } 417 } 418 } 419 } 420 } 421 }) 422.on('success.form.bv', function(e) { 423 // Prevent form submission 424 e.preventDefault(); 425 var $target = $('#thanks'); 426 var $form = $(e.target), 427 validator = $form.data('bootstrapValidator'), 428 submitButton = validator.getSubmitButton(); 429 //.1. 430 $.ajax({ 431 type: "POST", 432 url: path_controller, 433 data: $('form#inscriptionContact2').serialize(), 434 beforeSend: function(){ 435 $target.append(loader); 436 }, 437 success: function(msg){ 438 $('#loader_ajax').remove(); 439 $target.html(msg); 440 return true; 441 } 442 }); 443}); 444if($mob >= 1){ 445 $('#inscriptionContact2').data('bootstrapValidator').enableFieldValidators('portPatient', true); 446} 447} 448 449function randomNumber(min, max) { 450 return Math.floor(Math.random() * (max - min + 1) + min); 451}; 452//popover btn_chat_off 453$('#btn_chat_off').on("mouseenter",function(){ 454 $(this).popover('show'); 455}).on("mouseleave",function(){ 456 $(this).popover('hide'); 457}); 458// mobile nav toggle 459$('#nav-toggle').on('click', function (event) { 460 event.preventDefault(); 461 $('#main-nav').toggleClass("open"); 462}); 463function inputFormatDate(d,e){ 464 var pK = e ? e.which : window.event.keyCode; 465 if (pK == 8) {d.value = substr(0,d.value.length-1); return;} 466 var dt = d.value; 467 var da = dt.split('/'); 468 for (var a = 0; a < da.length; a++) {if (da[a] != +da[a]) da[a] = da[a].substr(0,da[a].length-1);}
469 if (da[0] > 31) {da[1] = da[0].substr(da[0].length-1,1);da[0] = '0'+da[0].substr(0,da[0].length-1);} 470 if (da[1] > 12) {da[2] = da[1].substr(da[1].length-1,1);da[1] = '0'+da[1].substr(0,da[1].length-1);} 471 if (da[2] > 9999)da[2] = da[2].substr(0,4); 472 dt = da.join('/'); 473 if (dt.length == 2 || dt.length == 5) dt += '/'; 474 d.value = dt; 475} 476});//fin document
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.