1/* global mbRfMessages, ajaxurl, frmvalidator, grecaptcha, fbq, ga, ret */ 2 3jQuery(function(){ 4 jQuery("#mybooking-rf-form #bambini").change(function() { 5 if (jQuery(this).val()===0) 6 jQuery(".etabambini").hide(); 7 else{ 8 jQuery(".etabambini").show(); 9 } 10 var j; 11 for(j=1;j <= 10; j=j+1){ 12 if (j <= jQuery(this).val()){ 13 jQuery("#etabambino_" + j).show(); 14 jQuery("#etabambino_" + j).attr("disabled",false); 15 } 16 else{ 17 jQuery("#etabambino_" + j).hide(); 18 jQuery("#etabambino_" + j).attr("disabled",true); 19 //alert( indexBb + " . " + j ); 20 } 21 } 22 }); 23 24 jQuery('#zonapartenza').change(function () { 25 jQuery('#rotteModal').modal('show'); 26 jQuery('#rotteModalBody').html("In Caricamento attendere..."); 27 var actionRotta = { 28 'action': 'mybooking-rf-getrotte', 29 'goZone': this.value, 30 'checkIn': jQuery('#arrivo-rf').val(), 31 'checkOut': jQuery('#partenza-rf').val() 32 }; 33 34 jQuery.ajax({ 35 type: "POST", 36 url: ajaxurl, 37 success: function (msg) { 38 39 jQuery('#rotteModalBody').html(msg); 40 jQuery('#rotteModalFooter').html('<button type="button" class="btn btn-primary">Salva e continua</button>'); 41 }, 42 43 data: actionRotta 44 }); 45 46 }); 47 48 jQuery('body').on("submit","#mybooking-rf-form.static, #mybooking-rf-form-onlyreq.static",function(){ 49 sendFormRqToMgc(jQuery(this)); 50 return false; 51 }); 52 53 54 //Riempio i campi del form con eventuali campi passati dalla get 55 if(jQuery('#mybooking-rf-form').length > 0){ 56 57 var tmp = getValueFromGet('idvendor'); 58 if(tmp!==''){ 59 jQuery("input[name='ref-idvendor']").val(tmp); 60 } 61 62 jQuery('#mybooking-rf-form input, #mybooking-rf-form select').each(function(){ 63 var name = jQuery(this).attr('name'); 64 if(name==='checkin'){ 65 name = 'arrivo'; 66 } 67 68 if(name==='checkout'){ 69 name = 'partenza'; 70 } 71 tmp = getValueFromGet(name); 72 if(tmp!==''){ 73 jQuery(this).val(tmp); 74 } 75 }); 76 } 77 78 var subject = getSubjectForAnchor(); 79 if(subject!==null && subject.length > 0 ){ 80 jQuery('#oggetto').val(subject); 81 } 82 83 jQuery('[data-toggle="modal"]').click(function(){ 84 if(jQuery(this).attr('data-subject')!==undefined && jQuery(this).attr('data-subject')!==null && jQuery(this).attr('data-subject').length > 0){ 85 jQuery('#mybooking-rf-form .oggetto').val(jQuery(this).attr('data-subject')); 86 } 87 }); 88 89 if(jQuery('#vendor').length > 0 && jQuery('#trattamento').length > 0){ 90 updateCampiTrattamento(); 91 92 jQuery('#vendor').change(function(){ 93 updateCampiTrattamento(); 94 }); 95 } 96 97 bindInDatePicker('#arrivo-rf'); 98 bindOutDatePicker('#partenza-rf'); 99 var calManagerRf = new CalendarManager('arrivo-requestform','partenza-requestform'); 100 calManagerRf.init(); 101}); 102 103function updateCampiTrattamento(){ 104 var tratts = jQuery('#vendor').find('option:selected').attr('data-tratts').split(','); 105 if(tratts){ 106 jQuery('#trattamento option').each(function(){ 107 if(tratts.indexOf(jQuery(this).val()) > -1){ 108 jQuery(this).show(); 109 } 110 else { 111 jQuery(this).hide(); 112 } 113 }); 114 } 115} 116 117function getSubjectForAnchor(){ 118 var url = document.location.href; 119 var hash = ''; 120 var idx = url.indexOf("#mbsubject-"); 121 if(idx > -1){ 122 var hash = url.substring(idx+11); 123 } 124 return hash; 125} 126 127function ajax_form_submit_handler(form) { 128 try{ 129 var bRet = true; 130 document.error_disp_handler.clear_msgs(); 131 for(var itr=0;itr < form.elements.length;itr++) 132 { 133 if(form.elements[itr].validationset && 134 !form.elements[itr].validationset.validate()) 135 { 136 bRet = false; 137 } 138 if(!bRet && !form.show_errors_together) 139 { 140 break; 141 } 142 } 143 if(!bRet) 144 { 145 document.error_disp_handler.FinalShowMsg(); 146 return false;
147 } 148 149 if(form.addnlvalidation) 150 { 151 str =" var ret = "+form.addnlvalidation+"()"; 152 eval(str); 153 if(!ret) { 154 return ret; 155 } 156 } 157 return true; 158 } 159 catch(e){ 160 alert(e); 161 return false; 162 } 163} 164 165function getValueFromGet(key) { 166 var result = "", 167 tmp = []; 168 location.search 169 //.replace ( "?", "" ) 170 // this is better, there might be a question mark inside 171 .substr(1) 172 .split("&") 173 .forEach(function (item) { 174 tmp = item.split("="); 175 if (tmp[0] === key) result = decodeURIComponent(tmp[1]); 176 }); 177 return result; 178} 179 180function invisibleCaptchaCallBack(token) { 181 sendFormRqToMgc(jQuery("#mybooking-rf-form")); 182 grecaptcha.reset(); 183} 184 185function sendFormRqToMgc(currentForm){ 186 var idForm = currentForm.attr('id'); 187 currentForm.find(".ckbmsg").remove(); 188 189 190 var currentFormValidator = null; 191 if(idForm == 'mybooking-rf-form-onlyreq'){ 192 currentFormValidator = frmvalidatorOreq; 193 } 194 else { 195 currentFormValidator = frmvalidator; 196 } 197 198 var fieldChecked = ajax_form_submit_handler(currentFormValidator.formobj); 199 if(fieldChecked) { 200 jQuery("#" + idForm + " .actions input.btn").hide(); 201 jQuery("#" +idForm + " .actions").append(jQuery(".waitingmessage")); 202 var parameters = getFormParameters('#' + idForm); 203 parameters['action']='easyrequest'; 204 205 206 //jQuery.post('http://crm.localhost.myguestcare.com:8080/.eshop', parameters, 207 jQuery.post('/mybookingrfform', parameters, 208 function(data) { 209 var results = jQuery.parseJSON( data ); 210 currentForm.find(".waitingmessage").detach(); 211 var msg = ''; 212 if(results.errorType > 0) { 213 jQuery("#" + idForm + " .actions input.btn").show(); 214 jQuery("#" + idForm + " .actions").addClass("error"); 215 if(results.errorType === 1) { 216 msg = mbRfMessages['verifica_no_robot']; 217 } 218 else if(results.errorType === 2) { 219 msg = mbRfMessages['verifica_no_robot']; 220 grecaptcha.reset(); 221 } 222 else if(results.errorType === 3) { 223 msg = mbRfMessages['errore_invio_richiesta']; 224 } 225 } 226 else { 227 if(typeof richDispThankyoupage!=='undefined'){ 228 window.location.href = richDispThankyoupage; 229 } 230 else { 231 try{ 232 if(typeof ga !== 'undefined'){ 233 ga('send', 'pageview', '/richiesta-disponibilita-completata/'); 234 } 235 if(typeof fbq !== 'undefined'){ 236 fbq('track', 'Lead'); 237 } 238 } 239 catch(e){} 240 msg = mbRfMessages['success_richiesta_inviata']; 241 jQuery("#" + idForm + " .actions").addClass("success"); 242 } 243 } 244 jQuery("#" + idForm + " .actions").append("<p class=\"ckbmsg\">" + msg + "</p>"); 245 246 } 247 ); 248 } 249}
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.