PageSourceSearch

https://www.londonnet.co.uk/wp-content/themes/Newspaper-child/js/search.js?v=1790883615

js londonnet.co.uk collected 2026-10-02 07:54:24 UTC 11,161 bytes, 298 lines download raw bytes

1
2jQuery(document).ready(function() {
3
4   var total_guests_selected = 0;
5   $("select").each(function () {
6      $(this).val($(this).find('option[selected]').val());
7   });
8
9   $('.submit-search').on('click', function(event) {
10      if ($(this).hasClass('booking-submit-button')) {
11         event.preventDefault();
12         $('#distance').val('');
13      }
14
15
16
17      var filter_type = $(this).data('filter-type');
18      if (($(this).hasClass('show-all-filter')) && ($(this).find('input').prop('checked'))) {
19         $('#filter-type-' + filter_type + ' label.specific-filter input').each(function(index, el) {
20            $(el).prop('checked', false);
21            $(el).parent().removeClass('checked');
22         });
23      } else {
24         var checked = false;
25         $('#filter-type-' + filter_type + ' label.specific-filter input').each(function(index, el) {
26            if ($(el).prop('checked')) {
27               checked = true;
28            }
29         });
30
31         if (!checked) {
32            $('#filter-type-' + filter_type + ' label.show-all-filter input').prop('checked', true);
33            $('#filter-type-' + filter_type + ' label.show-all-filter').addClass('checked');
34         }
35      }
36
37      if ($(this).hasClass('main-search-button')) {
38         date_changed();
39      }
40      var entity_code = $('#entity_code').val();
41      var override = false;
42      if(entity_code.indexOf('LC')  > -1) {
43        override = true;
44      }
45      $('#preloader').show();
46      submit_search(true);
47   });
48
49
50   $('.submit-button').on('click', function(event) {
51     var iframe = $('#in_frame').val();
52     if( iframe === 1 ) {
53       event.preventDefault();
54       $('#preloader').show();
55
56       submit_search(true);
57     }
58   });
59
60   $('.remove-filters-button').on('click', function(event) {
61      event.preventDefault();
62      $('#distance').val('');
63      $('#sort').val('Price');
64
65      $('#filter-type-6 label.specific-filter input').each(function(index, el) {
66         $(el).prop('checked', false);
67         $(el).parent().removeClass('checked');
68      });
69      $('#filter-label-177').addClass('checked');
70      $('#filter-label-177 input').prop('checked', true);
71      $('#entity_code').val('CY1');
72      $('#preloader').show();
73      submit_search(false);
74   });
75
76   
77
78   function submit_search(with_filters, special) {
79      var orderValue;
80      if(special) {
81        orderValue = 'Distance';
82      } else {
83        orderValue = $('#sort').val();
84      }
85  //    var base_url = window.location.href.split('?')[0];
86      var base_url = "/hotels/search";
87      var in_date = $('#ts-checkin-date').val();
88      var out_date = $('#ts-checkout-date').val();
89      var order = $('#sort').val();
90      var language = $('#language').val();
91      var entity_code = $('#entity_code').val();
92      var current_page = $('#current_page').val();
93      var guests = $('#ts-guest').val();
94      var limit = $('#limit').val();
95      var distance = $('#distance').val();
96      var voucher = $('#voucher_input').val();
97      if (!voucher) {
98         var voucher = $('#voucher').val();
99      }
100      var newsletter = $('#newsletter').val();
101      var single = $('#single_hotel').val();
102      var hotel_ids = $('#hotel_ids').val();
103      var iframe = $('#in_frame').val();
104      var site_id = $('#site_id').val();
105      var agent_id = $('#AgentId').val();
106      var price_type = $('#ts-prices').val();
107      var rooms_filter = $('#ts-rooms').val();
108      var microsite_url = $('#microsite_url').val();
109      var filter_ids = [];
110      var display_thumbs = $('#display_thumbs').val();
111
112      var test_mode = $('#ts-test-mode').val();
113      var _sExpires = '';
114      document.cookie = 'ts-search-date' + '=' + in_date + ',' + out_date + ',undefined,null,N,'+ guests +',undefined,undefined,undefined,undefined,undefined' + _sExpires + '; path=/';
115
116      if ($('#rooms_search').length) {
117         var single = 0;
118         var hotel_ids = "";
119         var limit = 20;
120         var entity_code = $('#hotel_code').val();
121      }
122      if (with_filters) {
123         $('input[name^="filter"]:checked').each(function() {
124            filter_ids.push($(this).val());
125         });
126         if ($('#hidden_filter').val() != "") {
127            filter_ids.push($('#hidden_filter').val());
128         }
129      } else {
130         filter_ids.push($('#filter-label-177 input').val());
131      }
132      if(price_type == 'PP') rooms_filter = 1;
133      var url = {
134         a: in_date,
135         d: out_date,
136         order: order,
137         lang: language,
138         entity_code: entity_code,
139         page: current_page,
140         limit: limit,
141         guests: guests,
142         voucher: voucher,
143         distance: distance,
144         single: single,
145         iframe: iframe,
146         hotel_ids: hotel_ids,
147         agentid: agent_id,
148         site_id: site_id,
149         page: 1,
150         pricing: price_type,
151         norooms: rooms_filter,
152         url: microsite_url,
153         filter_ids: [
154            filter_ids
155         ],
156         thumbs: display_thumbs
157      };
158
159      if(typeof test_mode !== undefined && test_mode == 1) {
160        Object.assign(url, {test: 1});
161      }
162      if(typeof newsletter !== undefined && newsletter == 'success') {
163        Object.assign(url, {newsletter: 'success'});
164      }
165
166      url = decodeURIComponent($.param(url, true));
167      
168      if ($('#rooms_search').length) {
169         var location = "https://www.travelstay.com/latest-offers/" + "?site=sglondonnet-js&" + url;
170         top.window.location.href = location;
171      } else {
172         var location = base_url + "/?" + url;
173         window.location.href = location;
174      }
175   }
176
177   function date_changed() {
178      $('input[name^="filter"]:checked').each(function() {
179         if ($(this).attr('name') != "filter[6]") {
180            $(this).prop('checked', false);
181         }
182      });
183   }
184
185   $('#mobile-guests').on('change', function(event) {
186      event.preventDefault();
187      $('#ts-guest').val($(this).val());
188   });
189
190   $('#mobile-price-type').on('change', function(event) {
191      event.preventDefault();
192      $('#ts-prices').val($(this).val());
193   });
194
195   $('#mobile-rooms').on('change', function(event) {
196      event.preventDefault();
197      $('#ts-rooms').val($(this).val());
198   });
199
200   $('#ts-rooms, #ts-guest').on('change', function(event) {
201      event.preventDefault();
202      var selected = $(this).val();
203      if (selected == "10+" || selected == "20+") {
204         if ($('.page-wrapper-expanded').hasClass('no-margin-top')) {
205            var url = $('#microsite_url').val();
206            window.parent.location.href= "https://" + url + "/groups";
207         } else {
208            window.location.href = "https://www.travelstay.com/groups.htm";
209         }
210      }
211   });
212   
213   $('#ts-prices, #mobile-price-type').on('change', function(event) {
214      event.preventDefault();
215      $this = $(this);
216      var selected = $this.val();
217      var $dorms = $('#dorms').val();
218      if(!$dorms || $dorms == 'undefined'){
219        if (selected == "PR") {
220           $('.room-number-drop').show();
221           $('#filter-type-6 .specific-filter').each(function() {
222             $(this).addClass('checked');
223             $(this).find('input').prop('checked', true);
224           });
225           $('#filter-label-177 input').prop('checked', false);
226           $('#filter-label-177').removeClass('checked');
227           $('#filter-label-65 input').prop('checked',false);
228           $('#filter-label-65').removeClass('checked');
229           $('#filter-label-130 input').prop('checked',false);
230           $('#filter-label-130').removeClass('checked');
231
232        } else {
233           $('.room-number-drop').hide();
234        }
235      }
236   });
237
238     
239   $('.button--book').on('click', function(event) {
240      event.preventDefault();
241      $('.loader-text').text('');
242      $('#preloader').show();
243      var hotel_id = $(this).data('hotel-id');
244      var room_id = $(this).data('room-id');
245      var hotel_index = $(this).data('hotel-index');
246      var quantity = $(this).data('quantity');
247      construct_book_json(hotel_id, room_id, hotel_index, quantity);
248   });
249
250   var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9+/=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/rn/g,"n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r)}else if(r>127&&r<2048){t+=String.fromCharCode(r>>6|192);t+=String.fromCharCode(r&63|128)}else{t+=String.fromCharCode(r>>12|224);t+=String.fromCharCode(r>>6&63|128);t+=String.fromCharCode(r&63|128)}}return t},_utf8_decode:function(e){var t="";var n=0;var r=c1=c2=0;while(n<e.length){r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r);n++}else if(r>191&&r<224){c2=e.charCodeAt(n+1);t+=String.fromCharCode((r&31)<<6|c2&63);n+=2}else{c2=e.charCodeAt(n+1);c3=e.charCodeAt(n+2);t+=String.fromCharCode((r&15)<<12|(c2&63)<<6|c3&63);n+=3}}return t}}
251
252   function getSearchParams(k){
253     var p={};
254     location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(s,k,v){p[k]=v})
255     return k?p[k]:p;
256    }
257   function construct_book_json(hotel_id, room_id, hotel_index, quantity) {
258      var search_id = $('#search_id').val();
259      var agent_id = $('#AgentId').val();
260      var site_id = parseInt($('#site_id').val());
261      var BasketItems = construct_basket_items(room_id, quantity);
262      var bookObject = {
263         Id: search_id,
264         Index: hotel_index,
265         HotelId: hotel_id,
266         SiteId: site_id,
267         SiteUrl: getSearchParams("url"),
268         uaCode: getSearchParams("ua"),
269         BasketItems: [BasketItems]
270      };
271      var b64_string = Base64.encode(JSON.stringify(bookObject));
272      $('#book-data').val(b64_string);
273      $clientId = $('#book-form').attr( 'data-client-id' );
274
275      $action = $('#book-form').attr('action') + '&_ga=' + $clientId;
276      $('#book-form').attr('action', $action);
277      $('#book-form').submit();
278   }
279
280   function construct_basket_items(room_id, quantity) {
281      var roomItem = {};
282      if (room_id != undefined) {
283         var roomItem = {
284            Id: room_id,
285            Quantity: quantity
286         }
287      }
288
289      return roomItem;
290   }  
291});
292
293jQuery(window).ready(function () {
294   // $('#acc-in').val($('#acc-in').data('val'));
295   // $('#acc-in').typeahead('val', $('#acc-in').data('val'));
296   $('#acc-in').removeAttr('disabled');
297   $('.hasDatepicker').hide();
298});

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.