1var OJ = OJ || {}; 2 3OJ.DataConnector = function(hotelID) { 4 this.config = apiOptions 5 6 hotelID = hotelID || apiOptions.hotelID; 7 8 try { 9 this.adapter = new OJ.DataAdapter(apiOptions, hotelID) 10 } catch (error) { 11 console.log("onejourney error: valid hotel required") 12 } 13} 14 15OJ.DataConnector.prototype.getAvailability = function(dates, rate, room, callback) { 16 let data = { 17 adults: this.config.adults, 18 infants: this.config.infants, 19 fromDate: dates[0], 20 toDate: dates[1], 21 rate: rate, 22 room: room 23 } 24 25 this.adapter.cancelExistingRequest() 26 27 this.adapter.getAvailability(data, (result) => { 28 callback(result) 29 }) 30} 31 32OJ.DataConnector.prototype.getRooms = function(query, callback) { 33 let data = { 34 fromDate: query['fromDate'], 35 toDate: query['toDate'], 36 adults: query['adults'], 37 infants: query['infants'] 38 } 39 40 this.adapter.cancelExistingRequest() 41 42 this.adapter.getAvailableRoomDetails(data, (result) => { 43 callback(result) 44 }) 45} 46 47OJ.DataConnector.prototype.getRoomDetails = function(query) { 48 let data = { 49 roomID: query['roomID'], 50 fromDate: query['fromDate'], 51 toDate: query['toDate'], 52 adults: query['adults'], 53 infants: query['infants'] 54 } 55 56 return this.makePromise('getRoomsDetails', data, (result, resolve) => { 57 if(query['roomID']) { 58 resolve(result[0]) 59 } else { 60 resolve(result) 61 } 62 }) 63} 64 65OJ.DataConnector.prototype.getRestaurants = function(callback) { 66 67 this.adapter.cancelExistingRequest() 68 69 this.adapter.getRestaurants((result) => { 70 callback(result) 71 }) 72} 73 74OJ.DataConnector.prototype.getCategories = function(type) { 75 76 this.adapter.cancelExistingRequest() 77 78 if(typeof(type) == 'function') { 79 callback = type 80 type = '' 81 } 82 83 return this.makePromise('getCategories', type) 84} 85 86OJ.DataConnector.prototype.getSpaPackages = function(type) { 87 88 this.adapter.cancelExistingRequest() 89 90 if(typeof(type) == 'function') { 91 callback = type 92 type = '' 93 } 94 95 return this.makePromise('getSpaPackages', type) 96} 97 98OJ.DataConnector.prototype.getSpaTreatments = function(type) { 99 100 this.adapter.cancelExistingRequest() 101 102 if(typeof(type) == 'function') { 103 callback = type 104 type = '' 105 } 106 107 return this.makePromise('getSpaTreatments', type) 108} 109 110OJ.DataConnector.prototype.getSpaTreatment = function(id) { 111 112 this.adapter.cancelExistingRequest() 113 114 if(typeof(id) == 'function') { 115 callback = id 116 type = '' 117 } 118 119 return this.makePromise('getSpaTreatment', id) 120} 121 122OJ.DataConnector.prototype.makePromise = function(method, data, callback) { 123 return new Promise((resolve) => { 124 this.adapter[method](data, (result) => { 125 126 $(window).trigger('OJ.' + method, result) 127 128 if(callback) { 129 callback(result, resolve) 130 } else { 131 resolve(result) 132 } 133 }) 134 }) 135}
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.