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 98 99 bindInDatePicker('#arrivo-rf'); 100 bindOutDatePicker('#partenza-rf'); 101 var calManagerRf = new CalendarManager('arrivo-requestform','partenza-requestform'); 102 calManagerRf.init(); 103}); 104 105function updateCampiTrattamento(){ 106 var tratts = jQuery('#vendor').find('option:selected').attr('data-tratts').split(','); 107 if(tratts){ 108 jQuery('#trattamento option').each(function(){ 109 if(tratts.indexOf(jQuery(this).val()) > -1){ 110 jQuery(this).show(); 111 } 112 else { 113 jQuery(this).hide(); 114 } 115 }); 116 } 117} 118 119function getSubjectForAnchor(){ 120 var url = document.location.href; 121 var hash = ''; 122 var idx = url.indexOf("#mbsubject-"); 123 if(idx > -1){ 124 var hash = url.substring(idx+11); 125 } 126 return hash; 127} 128 129function ajax_form_submit_handler(form) { 130 try{ 131 var bRet = true; 132 document.error_disp_handler.clear_msgs(); 133 for(var itr=0;itr < form.elements.length;itr++) 134 { 135 if(form.elements[itr].validationset && 136 !form.elements[itr].validationset.validate()) 137 { 138 bRet = false; 139 } 140 if(!bRet && !form.show_errors_together) 141 { 142 break; 143 } 144 } 145 if(!bRet) 146 { 147 document.error_disp_handler.FinalShowMsg(); 148 return false;
149 } 150 151 if(form.addnlvalidation) 152 { 153 str =" var ret = "+form.addnlvalidation+"()"; 154 eval(str); 155 if(!ret) { 156 return ret; 157 } 158 } 159 return true; 160 } 161 catch(e){ 162 alert(e); 163 return false; 164 } 165} 166 167function getValueFromGet(key) { 168 var result = "", 169 tmp = []; 170 location.search 171 //.replace ( "?", "" ) 172 // this is better, there might be a question mark inside 173 .substr(1) 174 .split("&") 175 .forEach(function (item) { 176 tmp = item.split("="); 177 if (tmp[0] === key) result = decodeURIComponent(tmp[1]); 178 }); 179 return result; 180} 181 182function invisibleCaptchaCallBack(token) { 183 sendFormRqToMgc(jQuery("#mybooking-rf-form")); 184 grecaptcha.reset(); 185} 186 187function invisibleCaptchaCallBackOnlyReq(token) { 188 sendFormRqToMgc(jQuery("#mybooking-rf-form-onlyreq")); 189 grecaptcha.reset(); 190} 191 192 193function sendFormRqToMgc(currentForm){ 194 var idForm = currentForm.attr('id'); 195 currentForm.find(".ckbmsg").remove(); 196 197 198 var currentFormValidator = null; 199 if(idForm == 'mybooking-rf-form-onlyreq'){ 200 currentFormValidator = frmvalidatorOreq; 201 } 202 else { 203 currentFormValidator = frmvalidator; 204 } 205 206 var fieldChecked = ajax_form_submit_handler(currentFormValidator.formobj); 207 if(fieldChecked) { 208 jQuery("#" + idForm + " .actions input.btn").hide(); 209 jQuery("#" +idForm + " .actions").append(jQuery(".waitingmessage")); 210 var parameters = getFormParameters('#' + idForm); 211 parameters['action']='easyrequest'; 212 213 214 //jQuery.post('http://crm.localhost.myguestcare.com:8080/.eshop', parameters, 215 jQuery.post('/mybookingrfform', parameters, 216 function(data) { 217 var results = jQuery.parseJSON( data ); 218 currentForm.find(".waitingmessage").detach(); 219 var msg = ''; 220 if(results.errorType > 0) { 221 jQuery("#" + idForm + " .actions input.btn").show(); 222 jQuery("#" + idForm + " .actions").addClass("error"); 223 if(results.errorType === 1) { 224 msg = mbRfMessages['verifica_no_robot']; 225 } 226 else if(results.errorType === 2) { 227 msg = mbRfMessages['verifica_no_robot']; 228 grecaptcha.reset(); 229 } 230 else if(results.errorType === 3) { 231 msg = mbRfMessages['errore_invio_richiesta']; 232 } 233 } 234 else { 235 if(typeof richDispThankyoupage!=='undefined'){ 236 window.location.href = richDispThankyoupage; 237 } 238 else { 239 try{ 240 if(typeof gtag !== 'undefined'){ 241 gtag('event', 'page_view', { 242 page_title: 'Richiesta disponibilita completata', 243 page_path: '/richiesta-disponibilita-completata/' 244 }); 245 } else if(typeof ga !== 'undefined'){ 246 ga('send', 'pageview', '/richiesta-disponibilita-completata/'); 247 } 248 249 if(typeof fbq !== 'undefined'){ 250 fbq('track', 'Lead'); 251 } 252 } 253 catch(e){} 254 if(typeof parameters['onlymessage'] !== 'undefined' && parameters['onlymessage'] == '1'){ 255 msg = mbRfMessages['success_richiesta_inviata_only_req']; 256 } else { 257 msg = mbRfMessages['success_richiesta_inviata']; 258 } 259 jQuery("#" + idForm + " .actions").addClass("success"); 260 } 261 262 } 263 jQuery("#" + idForm + " .actions").prepend("<p class=\"ckbmsg\">" + msg + "</p>"); 264 } 265 ); 266 } 267}
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.