1$(window).load(function () { 2 3 function ultimaReserva() { 4 5 var text1 = $('.text1').val(), 6 text2 = $('.text2').val(), 7 text3 = $('.text3').val(); 8 text4 = $('.text4').val(); 9 10 $.ajax({ 11 url: window.location.origin+"/onLoadRequests.php", 12 type: 'post', 13 data: {'action' : 'lastBooking', 'hot_code' : $('#id_hotel').val()}, 14 dataType: 'json', 15 success: function(data) { 16 17 if (data.error) { 18 $('#ultima_reserva').text('ERROR: '+data.error.msg); 19 } 20 else 21 { 22 if(data.result.ID_RESERVA) 23 { 24 var pais; 25 var ciutat; 26 27 if(data.result.PAIS.length > 0 && data.result.PAIS != '----------') { 28 pais = data.result.PAIS; 29 } 30 31 if(data.result.CIUTAT.length > 0) { 32 ciutat = data.result.CIUTAT; 33 } 34 35 var desti, 36 notification_message; 37 38 if(pais && ciutat) { 39 desti = ' '+text3+' '+ciutat+', '+pais; 40 } 41 else if(pais) { 42 desti = ' '+text3+' '+pais; 43 } 44 else if(ciutat) { 45 desti = ' '+text3+' '+ciutat; 46 } 47 else { 48 desti = ''; 49 } 50 51 console.log('new last bookig date: ' + data.result.DATA); 52 notification_message = '<input type="checkbox" id="reserva_cerrar"/>' 53 + '<div>' 54 + '<div class="notifi6"></div>' 55 + '<div>' 56 + '<div>'+text4+'</div>' 57 + '<div>
57'+ text1 + ' ' + data.result.DATA + ' ' + text2 + ' ' + data.result.HORA + desti +'</div>' 58 + '</div>' 59 + '<label for="reserva_cerrar"></label>' 60 + '</div>'; 61 62 $(".content_notification").prepend(notification_message); 63 } 64 else 65 { 66 console.log("no last booking"); 67 } 68 69 // Solo si tenemos notificaciones de algun tipo 70 if ( $(".content_notification > div") ) { 71 72 $('#notification_area').css({'display':'block'}); 73 74 //Animaciones JS 75 var cont_animation=2000, 76 cont_animation_out=12000, 77 max_notif = 4, 78 cont_notif = 0; 79 80 $(".content_notification > div").each(function() { 81 var o = $(this); 82 cont_notif ++; 83 84 if(cont_notif <= max_notif) { 85 86 $('> label',o).click(function(){ 87 o.removeClass("active_noti"); 88 o.addClass("no_active_noti"); 89 }); 90 91 setTimeout(function() { 92 o.addClass("active_noti"); 93 }, cont_animation); 94 95 setTimeout(function() { 96 o.removeClass("active_noti"); 97 o.addClass("no_active_noti"); 98 }, cont_animation_out); 99 100 cont_animation += 2000; 101 cont_animation_out += 4000; 102 } 103 }); 104 } 105 } 106 } 107 }); 108 } 109 110 function showNotifications() { 111 112 var hotel = '-'; 113 if ($("#id_hotel").val()) { 114 hotel = $("#id_hotel").val(); 115 } 116 117 // Distingim entre si estem a dispo o no 118 if( typeof config.city_id !== 'undefined' ) { 119 var date_from = $.datepicker.formatDate('yy-mm-dd', $.datepicker.parseDate( 'dd/mm/yy', $("#fecha_entrada").val() )); 120 var date_to   = $.datepicker.formatDate('yy-mm-dd', $.datepicker.parseDate( 'dd/mm/yy', $("#fecha_salida").val() ));
121 } 122 123 var language = config.lang; 124 125 // FIXME patch idioma 126 if (typeof language !== 'undefined' && language.toLowerCase() == 'de') { 127 language = 'al'; 128 } else if (typeof language !== 'undefined' && language.toLowerCase() == 'cs') { 129 language = 'cz'; 130 } else if (typeof language !== 'undefined' && language.toLowerCase() == 'zh') { 131 language = 'cn'; 132 } 133 134 var call_url = window.location.origin+"/buscador_nou/getHotelWebNotification/"+hotel+"/"+language; 135 if (date_from && date_to) { 136 call_url = call_url + "?date_from="+date_from+"&date_to="+date_to; 137 } 138 //console.log(call_url); 139 if (hotel !== '-') { 140 141 // Fem crida 142 $.ajax({ 143 url: call_url, 144 type: 'get', 145 dataType: 'json', 146 success: function(data) { 147 //console.log(data); 148 if (data.length > 0) { 149 150 var cont = 0, 151 notification_message = ''; 152 153 $.each( data, function( pos, notification ) { 154 if(notification.description || notification.name){ 155 notification_message += '<input type="checkbox" id="notif'+cont+'"/>' 156 + '<div>' 157 + '<div class="notifi'+notification.category+'"></div>' 158 + '<div>' 159 + '<div>'+ notification.name +'</div>' 160 + '<div>'+ notification.description +'</div>' 161 + '</div>' 162 + '<label for="notif'+cont+'"></label>' 163 + '</div>'; 164 165 cont++; 166 } 167 }); 168 169 $(".content_notification").append(notification_message); 170 171 $('#notification_area .close').click(function(event) { 172 $('#notification_area').fadeOut(); 173 }); 174 175 } else { 176 console.log("no active notifications"); 177 } 178 179 // Ultima reserva 180 ultimaReserva(); 181 }, 182 error: function(data) { 183 // Algo ha ido mal con las notificaciones, mostramos si hay aviso de ultima reserva 184 ultimaReserva(); 185 } 186 }); 187 188 } else { 189 // $('#notification_area').text('ERROR: Hotel Code failed'); 190 } 191 } 192 193 window.showNotifications = showNotifications; 194 195 // FIXME solucio temporal per evitar crida ajax lastBooking.js vell 196 if ( $( "script[src*='lastBooking.js']" ).length > 0) { 197 console.log("strip old lastBooking.js"); 198 $( "script[src*='lastBooking.js']" ).removeAttr('src'); 199 } 200 201 if ( ! window.search_params_ready ) { 202 Â Â $(document).on('search_params_ready', showNotifications); 203 204 } else { 205 Â Â showNotifications(); 206 } 207});
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.