1jQuery(window).load(function () { 2 webSdkOffers(); 3}); 4 5function webSdkOffers() { 6 // START WEB SDK CODE 7 jQuery('div[data-websdk]').each(function () { 8 var container = jQuery(this), 9 model_name = container.data('websdk'), 10 id = container.attr('id'), 11 custom_template = container.data('websdk-template'), 12 template_id, config, model, template, html; 13 template_id = custom_template ? custom_template : '#' + id + '_template'; 14 template = jQuery(template_id).text(); 15 16 if (typeof websdk_config !== 'undefined' && typeof websdk_config[id] !== 'undefined' && typeof ($fbsdk) !== 'undefined') { 17 config = websdk_config[id]; 18 $fbsdk.baseHost = config.baseHost; 19 20 //ROOM FEATURE 21 if (model_name == 'Accommodations') { 22 $fbsdk.Accommodations.prototype.getURLParams = function () { 23 var toRet = { 24 output: this.getConfig().output, 25 template: this.getConfig().template, 26 locale: this.getConfig().locale, 27 property: this.getConfig().property, 28 offset: this.getConfig().offset, 29 limit: this.getConfig().limit, 30 imagew: this.getConfig().imagew, 31 imageh: this.getConfig().imageh, 32 sortBy: this.getConfig().sortBy, 33 stripTags: this.getConfig().stripTags, 34 onlyBookableRooms: config.params.onlyBookableRooms, 35 orderType: this.getConfig().orderType, 36 _authCode: config._authCode 37 }; 38 return toRet; 39 }; 40 var curlLoader = new $fbsdk.Loader(); 41 curlLoader.add('rooms', new $fbsdk.Accommodations({ 42 property: config.params.property, 43 locale: config.params.locale, 44 limit: config.params.limit || 9999, 45 template: 'default', 46 output: 'json' 47 })); 48 49 curlLoader.add('i18n', new $fbsdk.I18n({ 50 property: config.params.property, 51 locale: config.params.locale, 52 template: 'default', 53 output: 'json', 54 module: 'accommodations' 55 })); 56 57 58 if (model_name == 'Accommodations') { 59 $fbsdk.Accommodations.prototype.getURLParams = function () { 60 var toRet = { 61 output: this.getConfig().output, 62 template: this.getConfig().template, 63 locale: this.getConfig().locale, 64 property: this.getConfig().property, 65 offset: this.getConfig().offset, 66 limit: this.getConfig().limit || 9999, 67 imagew: this.getConfig().imagew, 68 imageh: this.getConfig().imageh, 69 sortBy: this.getConfig().sortBy, 70 stripTags: this.getConfig().stripTags, 71 onlyBookableRooms: this.getConfig().onlyBookableRooms, 72 orderType: this.getConfig().orderType, 73 _authCode: config._authCode 74 }; 75 return toRet; 76 }; 77 var curlLoader = new $fbsdk.Loader(); 78 curlLoader.add('rooms', new $fbsdk.Accommodations({ 79 property: config.params.property, 80 locale: config.params.locale, 81 template: 'default', 82 output: 'json' 83 })); 84 curlLoader.add('i18n', new $fbsdk.I18n({ 85 property: config.params.property, 86 locale: config.params.locale, 87 template: 'default', 88 output: 'json', 89 module: 'accommodations' 90 })); 91 curlLoader.load(function (results) { 92 if (!results.i18n.error && !results.rooms.error) { 93 var rooms = results.rooms.origObject.getRawData(); 94 //console.log(rooms); 95 var i18n = results.i18n.origObject.getRawData(); 96 var template_data = {rooms: {}}; 97 for (var i = 0; i < rooms.rooms.length; i++) { 98 var room = rooms.rooms[i];
99 var room_name = room.beName; 100 var single_room = { 101 name: room_name, 102 occupancy: room.occupancy, 103 smoking: room.smoking, 104 roombathroomfeature_title: i18n["Bathroom features"], 105 roomequipments_title: i18n["Equipments"], 106 roomfeature_title: i18n["Room features"], 107 roombathroomfeature: [], 108 roomequipments: [], 109 roomfeature: [], 110 hasBedTypes: typeof room.bedTypes !== 'undefined' && room.bedTypes.length > 0, 111 bedTypes: room.bedTypes 112 }; 113 114 for (var featureType in room.features) { 115 if (room.features.hasOwnProperty(featureType)) { 116 single_room['has_' + featureType] = false; 117 for (var k = 0; k < room.features[featureType].length; k++) { 118 var string_id = featureType + '_' + room.features[featureType][k]; 119 var string_name = 'accommodation-feature-' + room.features[featureType][k]; 120 var i18n_string_name = typeof i18n[string_name] === 'undefined' ? '' : i18n[string_name]; 121 single_room[featureType].push({name: i18n_string_name.trim(), id: string_id}); 122 single_room['has_' + featureType] = true; 123 } 124 } 125 } 126 127 template_data.rooms[room_name] = single_room; 128 } 129 130 if (typeof config.roomType !== 'undefined') { 131 if(typeof template_data.rooms[room_name] !== 'undefined'){ 132 template_data.rooms = [template_data.rooms[config.roomType]]; 133 html = Mustache.render(template, template_data); 134 container.html(html); 135 container.closest('.loading').addClass(' processed noloading'); 136 container.find('.smoking .text').text(smokingTranslations[room.smoking]); 137 }else{ 138 console.log('Room type not found in the list of rooms'); 139 container.closest('.loading').addClass(' processed noloading'); 140 container.html('Room type not found in the list of rooms'); 141 } 142 143 }else{ 144 console.log('Room type not defined'); 145 console.log(template_data.rooms); 146 container.closest('.loading').addClass(' processed noloading'); 147 container.html('Room type not defined'); 148 } 149 } 150 }); 151 } 152 } 153 154 //OFFERS 155 if (model_name == 'Offers') { 156 model = new $fbsdk[model_name](config.params); 157 model.setAuthToken(config._authCode); 158 model.load(function (error) { 159 var data; 160 if (!error) { 161 data = jQuery.extend(true, {}, this.getRawData()); 162 /* 163 * id = offers_list : carousel or list of all offers 164 * id = offers_list_single : single highlighted offers 165 * id = room_xxx: room starting from 166 * */ 167 168 //normalize output 169 data.rates = data.rates.map(function (rate) { 170 return convertWebSDKOffer(rate, config); 171 }); 172 173 //offers to exclude using rate name (Fastbooking) 174 if (typeof rates_to_hide !== 'undefined' 175 && rates_to_hide !== '' 176 && id === 'offers_list') { 177 data.rates = data.rates.filter(function (el) { 178 return (rates_to_hide.indexOf(el.rate.id) == -1); 179 }); 180 } 181 182 //offers to exclude using rate id (Availpro) 183 if (typeof rates_to_hide !== 'undefined' 184 && rates_to_hide !== '' 185 && id === 'offers_list') { 186 data.rates = data.rates.filter(function (el) { 187 return (rates_to_hide.indexOf(el.rate.code) == -1); 188 }); 189 190 } 191 192 193 //fix order for AVP (ordering should be supported but in fact doesn't work as 2022-04-08) 194 if (is_AVP) { 195 //order should be always defined if config is generated by get_offer() php function 196 var order = config.params.orderBy; 197 198 //another fail-safe if order is not defined 199 order = typeof order === 'undefined' ? 'pricePerNight' : order; 200 data.rates.sort(function (a, b) { 201 switch (order) { 202 case 'totalPrice': 203 return parseFloat(a.best.totalPrice) - parseFloat(b.best.totalPrice); 204 case 'checkinDate': 205 return parseFloat(a.first.fromYYMMDD) - parseFloat(b.first.fromYYMMDD); 206 default: 207 return parseFloat(a.best.pricePerNight) - parseFloat(b.best.pricePerNight); 208 } 209 }); 210 211 //rooms starting from has no room id in the book link, so we need to fix it 212 if (typeof fusionConfig !== 'undefined') { 213 if (id.includes('room')) {
214 data.rates.forEach(function (rate) { 215 rate.best.bookLink.onclick = rate.first.bookLink.onclick 216 }); 217 } 218 } 219 220 } 221 222 //sort output 223 if (id === 'offers_list' || id === 'offers_list_single') { 224 data.rates.sort(function (a, b) { 225 return parseFloat(a.rate.order) - parseFloat(b.rate.order); 226 }); 227 } 228 229 data.id = id; 230 231 //add odd-even offers class 232 for (var k = 0; k < data.rates.length; k++) { 233 data.rates[k].rate.class += k % 2 === 0 ? ' even' : ' odd'; 234 } 235 236 237 //number of offers displayed 238 if (typeof data.rates !== 'undefined' && typeof config.number !== 'undefined' 239 && config.number < data.rates.length) { 240 data.rates = data.rates.slice(0, parseInt(config.number, 10)); 241 } 242 243 // console.log(container); 244 245 //print Mustache template 246 html = Mustache.render(template, data); 247 container.html(html); 248 249 250 container.closest('.loading').addClass(' processed noloading'); 251 lazyLoadInstance.update(); 252 253 container.trigger('builder_offers_ready', [data]); 254 } 255 }); 256 } 257 258 } 259 }); 260 // END WEB SDK CODE 261}
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.