1var tosc5Controller = { 2 3 doQuicksearch: false, 4 5 options: { 6 occupancy1: {}, 7 dbCode: 'EBG' 8 }, 9 10 /** 11 * init: function() 12 */ 13 init: function () { 14 tosc5Controller.fetchQuicksearchParameters(); 15 16 if (tosc5Controller.doQuicksearch) { 17 tosc5Controller.prepareQuicksearch(); 18 } else { 19 tosc5Controller.loadTOSC5(); 20 } 21 22 tosc5Controller.translate(); 23 }, 24 25 /** 26 * fetchQuicksearchParameters: function () 27 * open url with following url parameters, examples: 28 * 29 * ?providerid=37d46748-eb5e-45d4-b9f6-735d6d368739&arrival=2021-12-15&departure=2021-12-17&adults=2&children=4,7&units=1 30 * ?providerid=37d46748-eb5e-45d4-b9f6-735d6d368739&arrival=2021-12-15&departure=2021-12-17&adults=3&children=4&units=2 31 * ?providerid=37d46748-eb5e-45d4-b9f6-735d6d368739&arrival=2022-03-15&departure=2022-03-17&adults=3&units=2 32 * 33 */ 34 fetchQuicksearchParameters: function () { 35 const urlParams = new URLSearchParams(window.location.search); 36 37 if (arrival = urlParams.get('arrival')) { 38 tosc5Controller.options.dateFrom = new Date(arrival); 39 tosc5Controller.doQuicksearch = true; 40 } 41 if (departure = urlParams.get('departure')) { 42 tosc5Controller.options.dateTo = new Date(departure); 43 tosc5Controller.doQuicksearch = true; 44 } 45 if (units = urlParams.get('units')) { 46 tosc5Controller.options.occupancy1.units = units; 47 tosc5Controller.doQuicksearch = true; 48 } 49 if (adults = urlParams.get('adults')) { 50 tosc5Controller.options.occupancy1.adults = adults; 51 tosc5Controller.doQuicksearch = true; 52 } 53 if (children = urlParams.get('children')) { 54 if (children.length > 0) { 55 var _children = children.split(","); 56 tosc5Controller.options.occupancy1.children = _children; 57 tosc5Controller.doQuicksearch = true; 58 } 59 } 60 if (providerid = urlParams.get('providerid')) { 61 tosc5Controller.options.id = providerid; 62 tosc5Controller.doQuicksearch = true; 63 } 64 65 tosc5Controller.log('doQuicksearch: ' + tosc5Controller.doQuicksearch); 66 }, 67 68 /** 69 * loadTOSC5: function 70 * 71 * TODO: tracking 72 * - quantity: is not yet set, number of rooms? nights? 73 * - track other booking options apart from accommodation (packages) 74 * 75 * see: 76 * https://fdcwiki.deskline.net/display/CONNECTIVITY/Event+onUserAction 77 * https://fdcwiki.deskline.net/display/CONNECTIVITY/Event+onPageLoad 78 */ 79 loadTOSC5: function () { 80 tosc5Controller.log('loadTOSC5'); 81 window.dw = window.dw || function () { 82 (dw.q = dw.q || []).push(arguments) 83 }; 84 85 var defaultCurrency = 'CHF'; 86 var thisurl = window.location.href; 87 if (thisurl.match('/.*\/#\/.*/')) { 88 // parse the tosc5 url with /#/ to get the currency (yes, complicated!) 89 // example: https://dev.engelberg.aws.pxia.de/unterkuenfte-online-buchbar/hotels/#/unterkuenfte/EBG/35aff74c-adc5-4341-a145-182c5a5978e2/hotel-alpenclub?useDetailSearch=false¤cy=EUR 90 var currencyArgument = tosc5Controller.getQueryVariable( 91 new URL( 92 new URL(window.location.href).hash.replace('#', ''), 93 'http://dummy' 94 ).search, 95 'currency' 96 ); 97 } else { 98 var currencyArgument = tosc5Controller.getQueryVariable(new URL(window.location.href).search, 'currency'); 99 } 100 101 // defaultCurrency only works with emptied cookies! once a currency is selected, it is always used and this argument has no function! 102 switch (currencyArgument) { // only EUR is respected this time 103 case 'EUR': 104 defaultCurrency = 'EUR'; 105 106 var localStorage = window.localStorage; 107 var deskline_config = localStorage.getItem('deskline/web/Engelberg_data'); 108 if (deskline_config) { 109 var json_deskline_config = JSON.parse(deskline_config); 110 if (json_deskline_config != 'undefined') { 111 if (json_deskline_config['UserContextBase.currency'] != 'undefined') { 112 json_deskline_config['UserContextBase.currency'] = ''; 113 localStorage.setItem('deskline/web/Engelberg_data', JSON.stringify(json_deskline_config)); 114 } 115 } 116 } 117 118 break; 119 } 120 121 tosc5Controller.log('defaultCurrency: ' + defaultCurrency); 122 123 var context = { 124 "targetRoute": ["/" + settings['targetRoute']], 125 "defaultCurrency": defaultCurrency 126 } 127 if (settings['urlOptionalParams_string']) context.urlOptionalParams = settings['urlOptionalParams_string']; 128 129 var options = { 130 "context": context, 131 "allowScrollOnApplicationStart": (settings['allowScrollOnApplicationStart'] == '1' ? true : false), 132 "lang": settings['sys_language_isocode'], 133 "target": "tosc5target_" + settings['currentRecord'], 134 "styleResources": settings['styleResources'], 135 "useHashNavigation" : (settings['useHashNavigation'] == '1' ? true : false), 136 "baseHref" : settings['baseHref'] 137 }; 138 139 //console.log(options); 140 141 dw("settings", settings['tagId'], 142 options 143 ); 144 145 var script = document.createElement('script'); 146 script.src = "https://resc.deskline.net/DW5/start/ENGELBERG/" + settings['tagId'] + "/index.js"; 147 document.head.appendChild(script); 148 149 dw('onPageLoad', settings['tagId'], function (e) { 150 tosc5Controller.log('onPageLoad'); 151 tosc5Controller.trackOnPageLoad(e); 152 }); 153 154 dw('onUserAction', settings['tagId'], function (e) { 155 tosc5Controller.log('onUserAction'); 156 tosc5Controller.trackUserAction(e); 157 }); 158 159 160 }, 161 162 /** 163 * prepareQuicksearch: function ()
164 * Function which is called in a loop until dwutility.js is completely loaded. 165 * Example taken over 1:1 from feratel 166 */ 167 prepareQuicksearch: function () { 168 if (dw && dw.accommodationQuickFind) { 169 // Travel data example 170 /* 171 tosc5Controller.options = { 172 dateFrom: new Date('2021-12-10'), 173 dateTo: new Date('2021-12-13'), 174 occupancy1: { 175 units: 1, 176 adults: 2, 177 children: [0, 1] 178 }, 179 dbCode: 'EBG', // Database code (3 digits, visible in the URL of the detail page of a site) 180 id: '246d424d-c84a-4a03-8ed2-ccf5dfa743de' // ID of the landlord (Visible in the URL of the detail page of an establishment) 181 }; 182 */ 183 184 // Quick search function to pass desired data. Data should be loaded dynamically from URL parameters. 185 dw.accommodationDetailQuickFind( 186 // LocalStorageID: Usually the link key. You can request this from your service center. 187 'Engelberg', 188 tosc5Controller.options, 189 function () { 190 // Start of TOSC 5 as soon as quick search is prepared. 191 tosc5Controller.loadTOSC5(); 192 } 193 ); 194 } else { 195 tosc5Controller.log('loop until dwutility.js is completely loaded'); 196 requestAnimationFrame(tosc5Controller.prepareQuicksearch) 197 } 198 }, 199 200 /** 201 * trackUserAction: function (e) 202 */ 203 trackUserAction: function (e) { 204 if (e.type == 5) { 205 tosc5Controller.log('onUserAction / eec.addToCart'); 206 207 /* e example 208 { 209 "linkkey": "engelberg", 210 "lang": "de", 211 "tagId": "809225db-0d65-4035-aa05-6a26d88b3b71", 212 "orgCode": "ENGELBERG", 213 "parentId": "", 214 "type": 5 215 } 216 */ 217 218 window.dataLayer = window.dataLayer || []; 219 window.dataLayer.push({ 220 'event': 'eec.addToCart', 221 'pageTitle': e.pageTitle, 222 'pageType': e.pageType, 223 'lang': e.lang, 224 'ecommerce': { 225 'currencyCode': 'CHF', 226 'add': { 227 'products': [{ 228 //'name': 'Rock and Safety Days', 229 'id': e.tagId 230 //'price': '450.00', 231 //'category': 'Erlebnisse', 232 //'quantity': 1, 233 }] 234 } 235 } 236 }); 237 } 238 }, 239 240 /** 241 * trackOnPageLoad: function (e) 242 * 243 * calls sub-methods to track different page types. 244 * always track 245 * 'event': 'eec.giveMeAName', 246 * 'pageTitle': e.pageTitle, 247 * 'pageType': e.pageType, 248 * 'lang': e.lang, 249 */ 250 trackOnPageLoad: function (e) { 251 252 switch (parseInt(e.pageType)) { 253 case 101: // service provider detail page 254 tosc5Controller.trackOnPageLoad_101(e); 255 break; 256 257 case 9901: // confirmation page 258 tosc5Controller.trackOnPageLoad_9901(e); 259 break; 260 261 case 9900: // confirmation page 262 tosc5Controller.trackOnPageLoad_9900(e); 263 break; 264 265 default: // all other pages 266 tosc5Controller.trackOnPageLoad_page(e); 267 } 268 }, 269 270 trackOnPageLoad_101: function (e) { 271 var dataLayerPush = { 272 'event': 'eec.serviceprovider', 273 'pageTitle': e.pageTitle, 274 'pageType': e.pageType, 275 'lang': e.lang, 276 'serviceprovider': { 277 'spName': e.spName, 278 'spTown': e.spTown, 279 'spId': e.spId 280 } 281 }; 282 window.dataLayer = window.dataLayer || []; 283 window.dataLayer.push(dataLayerPush); 284 285 tosc5Controller.log('eec.serviceprovider'); 286 console.log({'dataLayer.Push': dataLayerPush}); 287 }, 288 289 trackOnPageLoad_9901: function (e) { 290 if (typeof e.bookingConfirmation.items.accommodations[0] != 'undefined') { 291 292 /* 293 { 294 "linkkey": "engelberg", 295 "lang": "de", 296 "tagId": "809225db-0d65-4035-aa05-6a26d88b3b71", 297 "orgCode": "ENGELBERG", 298 "pageType": 9901, 299 "pageTitle": "Bestätigung", 300 "bookingConfirmation": { 301 "transactionId": "0ed95a6f-e24d-489a-adf8-f96179d69b02", 302 "transactionNumber": 62190, 303 "transactionDate": "2022-03-23T14:34:01.87", 304 "transactionType": 1, 305 "databaseCode": "EBG",
306 "guestId": "00000000-0000-0000-0000-000000000000", 307 "guestDetails": { 308 "city": "Test", 309 "country": "DE", 310 "salutationId": "9d1acf1a-db25-4578-8c42-a0658677a599", 311 "firstName": "xxx", 312 "lastName": "xxx", 313 "company": "", 314 "address1": "Test 1", 315 "zipCode": "11111", 316 "email": "xxx" 317 }, 318 "bookingFee": 0, 319 "visitorTax": 0, 320 "totalAmount": 400, 321 "userTotalAmount": 400, 322 "totalAmountGuestCurrency": 378.75, 323 "userTotalAmountGuestCurrency": 378.75, 324 "bookingFeeGuestCurrency": 0, 325 "guestSettlerCode": "ENGELBERG", 326 "guestSettlerName": null, 327 "hasCancellationInsurance": false, 328 "cancellationInsuranceType": 0, 329 "cancellationRecipientName": null, 330 "cancellationInsuranceFee": 0, 331 "cancellationInsuranceFeeGuestCurrency": 0, 332 "items": { 333 "accommodations": [ 334 { 335 "productId": "12692920-5b57-4296-ba8d-dff429dcc784", 336 "product": { 337 "name": "Nur für Tests", 338 "owner": "ENGELBERG" 339 }, 340 "serviceId": "60cb5859-9e9f-4233-ae40-159644b0e53e", 341 "serviceProviderId": "fde11a4f-675b-45c6-a769-bccb5db11d2a", 342 "serviceProvider": { 343 "name": "Test Hotel Test", 344 "descriptions": [ 345 { 346 "type": 21, 347 "description": "" 348 }, 349 { 350 "type": 4, 351 "description": "" 352 } 353 ], 354 "location": { 355 "town": "Engelberg" 356 }, 357 "addresses": [ 358 { 359 "addressType": 0, 360 "address1": "Klosterstrasse 3", 361 "city": "Engelberg", 362 "country": "CH", 363 "zipCode": "6390", 364 "email": "[email protected]", 365 "mobile": "", 366 "phone": "+41 41 639 77 77" 367 }, 368 { 369 "addressType": 2, 370 "address1": "Klosterstrasse 3", 371 "city": "Engelberg", 372 "country": "CH", 373 "zipCode": "6390", 374 "email": "[email protected]", 375 "mobile": "", 376 "phone": "+41 41 639 77 77" 377 } 378 ], 379 "galleryImages": [ 380 { 381 "urls": [ 382 "//resc.deskline.net/images/EBG/1/29c66860-fb66-4cda-8248-0c55a5e45c14/54/Hotel_Hess_5.jpg" 383 ], 384 "name": "Hotel Hess 5" 385 } 386 ], 387 "forceRequestRecipientServiceProvider": false 388 }, 389 "alternativeName": "", 390 "owner": "ENGELBERG", 391 "price": 400, 392 "priceGuestCurrency": 378.75, 393 "units": 1, 394 "isBestPrice": false, 395 "dateFrom": "2022-03-26T23:00:00.000Z", 396 "dateTo": "2022-03-27T22:00:00.000Z", 397 "paymentCancellationPolicy": { 398 "cancellationPolicy": { 399 "cancellationTextType": 4,
400 "defaultHeaderTextNumber": 42, 401 "hasFreeCancellation": false, 402 "lastFreeDate": null, 403 "lastFreeTime": null, 404 "textLines": [ 405 { 406 "cancellationCalculationType": 0, 407 "cancellationNights": 0, 408 "cancellationPercentage": 0, 409 "defaultTextNumber": 48, 410 "hasFreeTime": false, 411 "freeTime": null, 412 "cancellationDate": null 413 }, 414 { 415 "cancellationCalculationType": 0, 416 "cancellationNights": 0, 417 "cancellationPercentage": 0, 418 "defaultTextNumber": 50, 419 "hasFreeTime": false, 420 "freeTime": null, 421 "cancellationDate": null 422 } 423 ] 424 }, 425 "paymentPolicy": { 426 "paymentMethods": [ 427 1 428 ], 429 "defaultHeaderText": 59, 430 "defaultText": 61, 431 "hasPrePaymentLink": false, 432 "depositCalculationRule": 0, 433 "depositAmount": 0, 434 "textType": 2 435 } 436 }, 437 "dataOwner": { 438 "name": "Engelberg-Titlis Tourismus AG", 439 "code": "ENGELBERG" 440 } 441 } 442 ], 443 "additionalServices": [], 444 "brochures": [] 445 } 446 } 447 } 448 */ 449 450 var dateFrom = e.bookingConfirmation.items.accommodations[0].dateFrom; 451 var dateTo = e.bookingConfirmation.items.accommodations[0].dateTo; 452 453 var date1 = new Date(dateFrom); 454 var date2 = new Date(dateTo); 455 456 var Difference_In_Time = date2.getTime() - date1.getTime(); 457 var Difference_In_Days = Difference_In_Time / (1000 * 3600 * 24); 458 459 var dataLayerPush = { 460 'event': 'eec.confirmation', 461 'pageTitle': e.pageTitle, 462 'pageType': e.pageType, 463 'lang': e.lang, 464 'ecommerce': { 465 'transactionNumber': e.bookingConfirmation.transactionNumber, 466 'totalAmount': e.bookingConfirmation.items.accommodations[0].price * e.bookingConfirmation.items.accommodations[0].units, 467 'currencyCode': 'CHF', 468 'serviceProviderId': e.bookingConfirmation.items.accommodations[0].serviceProviderId, 469 'dateFrom': date1.getFullYear() + '-' + (date1.getMonth() + 1) + '-' + date1.getDate()/*e.bookingConfirmation.items.accommodations[0].dateFrom*/, 470 'dateTo': date2.getFullYear() + '-' + (date2.getMonth() + 1) + '-' + date2.getDate()/*e.bookingConfirmation.items.accommodations[0].dateTo*/, 471 'bookedNights': Difference_In_Days, 472 'units': e.bookingConfirmation.items.accommodations[0].units, 473 '_all': e.bookingConfirmation 474 } 475 }; 476 477 window.dataLayer = window.dataLayer || []; 478 window.dataLayer.push(dataLayerPush); 479 480 tosc5Controller.log('eec.confirmation'); 481 console.log({'dataLayer.Push': dataLayerPush}); 482 483 } 484 }, 485 486 trackOnPageLoad_9900: function (e) { 487 488 // tracking of "zur kasse" button 489 if (typeof e.shoppingCart != 'undefined') { 490 if (typeof e.shoppingCart.items != 'undefined') { 491 if (typeof e.shoppingCart.items.accommodationItems != 'undefined') { 492 493 var products = []; 494 $.each(e.shoppingCart.items.accommodationItems, function (i, o) { 495 var product = { 496 'name': o.serviceProvider.name, 497 'id': o.serviceProvider.id, 498 'price': o.price.totalPrice, 499 'category': settings['pagetitle'], 500 'quantity': 1 // fehlt noch 501 }; 502 products.push({product: product}); 503 }); 504 505 var dataLayerPush = { 506 'event': 'eec.checkout', 507 'pageTitle': e.pageTitle, 508 'pageType': e.pageType, 509 'lang': e.lang, 510 'ecommerce': { 511 'currencyCode': e.shoppingCart.bookingInformation.payment.currencyCode, 512 'checkout': { 513 'actionField': { 514 'step': 1 515 }, 516 'products': products 517 } 518 } 519 }; 520 window.dataLayer = window.dataLayer || []; 521 window.dataLayer.push(dataLayerPush); 522 523 tosc5Controller.log('eec.checkout'); 524 console.log({'dataLayer.Push': dataLayerPush}); 525 } 526 } 527 } 528 529 // Tacking of "Kostenpflichtig Buchen" Button 530 if (typeof e.bookingConfirmation != 'undefined') { 531 if (typeof e.bookingConfirmation.items != 'undefined') { 532 if (typeof e.bookingConfirmation.items.accommodations != 'undefined') { 533 534 var products = []; 535 $.each(e.bookingConfirmation.items.accommodations, function (i, o) { 536 var product = { 537 'name': o.serviceProvider.name, 538 'id': o.serviceProviderId, 539 'price': o.price, 540 'category': settings['pagetitle'], 541 'quantity': 1 // fehlt noch 542 }; 543 products.push({product: product}); 544 }); 545 546 var toPush = products; 547 if (typeof products[0] != 'undefined') toPush = products[0]; 548 549 var dataLayerPush = { 550 'event': 'eec.purchase', 551 'pageTitle': e.pageTitle, 552 'pageType': e.pageType, 553 'lang': e.lang, 554 'ecommerce': { 555 'purchase': { 556 'actionField': { 557 'id': e.bookingConfirmation.transactionId, 558 'revenue': e.bookingConfirmation.totalAmount, 559 }, 560 'products': toPush 561 } 562 } 563 }; 564 565 window.dataLayer = window.dataLayer || []; 566 window.dataLayer.push(dataLayerPush); 567 568 tosc5Controller.log('eec.purchase'); 569 console.log({'dataLayer.Push': dataLayerPush}); 570 } 571 } 572 } 573 }, 574 575 trackOnPageLoad_page: function (e) { 576 577 var dataLayerPush = { 578 'event': 'eec.page', 579 'pageTitle': e.pageTitle, 580 'pageType': e.pageType, 581 'lang': e.lang 582 }; 583 window.dataLayer = window.dataLayer || []; 584 window.dataLayer.push(dataLayerPush); 585 586 tosc5Controller.log('eec.page'); 587 console.log({'dataLayer.Push': dataLayerPush}); 588 }, 589 590 591 /** 592 * translate: function () 593 */ 594 translate: function () { 595 dw("onAppStart", settings['tagId'], function () { 596 if (settings['translations91']) i18n.translations[91] = settings['translations91']; 597 if (settings['translations92']) i18n.translations[92] = settings['translations92']; 598 }); 599 }, 600 601 getQueryVariable: function (query, variable) { 602 var vars = query.split('&'); 603 for (var i = 0; i < vars.length; i++) { 604 var pair = vars[i].split('='); 605 if (decodeURIComponent(pair[0]) == variable) { 606 return decodeURIComponent(pair[1]); 607 } 608 } 609 return false; 610 }, 611 612 /** 613 * log: function (message) 614 */ 615 log: function (message) { 616 var output = (Math.round(performance.now()) / 1000) + ': [tosc5Controller] ' + message; 617 console.log(output); 618 } 619 620}; 621 622// do not use document ready function! 623//$(document).ready(function () { 624tosc5Controller.init();
625//}); 626 627
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.