PageSourceSearch

https://sorrentohotel.co.uk/js/dc868bc8ec1f1cdb80147379b79cd54a.js

js sorrentohotel.co.uk collected 2026-10-10 02:08:16 UTC 11,087 bytes, 323 lines download raw bytes

1function sendContactForm(s) {
2
3    $("#alert-working").css("display", "block");
4
5    inputs = {};
6
7    $("input").each(function () {
8        inputs[$(this).attr("name")] = $(this).val()
9    });
10
11    $("textarea").each(function () {
12        inputs[$(this).attr("name")] = $(this).val()
13    });
14
15    $("select").each(function () {
16        inputs[$(this).attr("name")] = $(this).val()
17    });
18
19    $.ajax({
20        url: "https://secure.hotels.uk.com/Core/API/ContactAPI.php?HotelID=" + s,
21        type: "POST",
22        dataType: "json",
23        data: inputs,
24        success: function (s) {
25            s.success ? ($("#alert-error").css("display", "none"), $("#alert-done").css("display", "block")) : ($("#alert-error").css("display", "block"), $("#alert-done").css("display", "none"), $("#alert-error").html(s.message)), $("#alert-working").css("display", "none"), pushToErrors(s.value)
26        },
27        error: function () {
28            $("#alert-error").css("display", "block"), $("#alert-done").css("display", "none"), $("#alert-working").css("display", "none"), clearErrors()
29        }
30    }), $(document).scrollTop(0), !1
31
32    alert(s);
33
34    return false;
35}
36
37function usableHotelID(value) {
38    if (value === null || value === undefined) {
39        return "";
40    }
41    var v = String(value).trim();
42    if (!v || v === "undefined" || v === "null") {
43        return "";
44    }
45    return v;
46}
47
48function readQueryValue(selector) {
49    try {
50        var el = document.querySelector(selector);
51        if (!el || el.value === undefined || el.value === null) {
52            return "";
53        }
54        return usableHotelID(el.value);
55    } catch (e) {
56        return "";
57    }
58}
59
60function readDataAttr(selector, name) {
61    try {
62        var el = document.querySelector(selector);
63        if (!el) {
64            return "";
65        }
66        return usableHotelID(el.getAttribute(name));
67    } catch (e) {
68        return "";
69    }
70}
71
72/**
73 * err23 fires when HotelID cannot be resolved. Prefer the contact form, then
74 * the page global, then a booking widget data-qbook attribute.
75 */
76function resolveContactHotelID(inputs) {
77    var sources = {
78        globalDefined: (typeof window.HotelID !== "undefined") ? "1" : "0",
79        globalValue: "",
80        formValue: "",
81        formDataAttr: "",
82        inputsValue: "",
83        widgetValue: ""
84    };
85
86    if (typeof window.HotelID !== "undefined") {
87        sources.globalValue = usableHotelID(window.HotelID);
88    }
89    sources.formValue = readQueryValue("#contactForm input[name='HotelID']") || readQueryValue("#contactForm #HotelID");
90    sources.formDataAttr = readDataAttr("#contactForm", "data-hotel-id");
91    if (inputs) {
92        sources.inputsValue = usableHotelID(inputs.HotelID);
93    }
94    sources.widgetValue = readDataAttr("script[data-qbook]", "data-qbook") || readDataAttr("[data-qbook]", "data-qbook");
95
96    var order = ["formValue", "formDataAttr", "inputsValue", "globalValue", "widgetValue"];
97    var resolved = "";
98    for (var i = 0; i < order.length; i++) {
99        if (sources[order[i]]) {
100            resolved = sources[order[i]];
101            break;
102        }
103    }
104    return { hotelId: resolved || null, sources: sources };
105}
106
107function fieldPresence(inputs) {
108    var present = [];
109    var missing = [];
110    if (!inputs) {
111        return { present: present, missing: missing };
112    }
113    for (var name in inputs) {
114        if (!Object.prototype.hasOwnProperty.call(inputs, name)) {
115            continue;
116        }
117        if (name === "undefined" || name === "null") {
118            continue;
119        }
120        var val = inputs[name];
121        if (val === null || val === undefined || String(val).trim() === "") {
122            missing.push(name);
123        } else {
124            present.push(name);
125        }
126    }
127    return { present: present, missing: missing };
128}
129
130function reportErr23(inputs, sources) {
131    var presence = fieldPresence(inputs);
132    $("#alert-error").css("display", "block");
133    $("#alert-done").css("display", "none");
134    $("#alert-working").css("display", "none");
135    $("#alert-error").html("ERR23: Please contact the accommodation directly.");
136
137    // POST-only, no ?err23=true — that query string was a crawler magnet.
138    $.ajax({
139        url: "https://secure.hotels.uk.com/Core/API/ContactAPI.php",
140        type: "POST",
141        dataType: "json",
142        data: {
143            event: "err23",
144            reason: "missing_hotel_id",
145            href: window.location.href || "",
146            referrer: document.referrer || "",
147            hotelIdGlobalDefined: sources ? sources.globalDefined : ((typeof window.HotelID !== "undefined") ? "1" : "0"),
148            hotelIdGlobalValue: sources ? sources.globalValue : "",
149            hotelIdFormValue: sources ? (sources.formValue || sources.formDataAttr) : "",
150            hotelIdWidgetValue: sources ? sources.widgetValue : "",
151            presentFieldNames: presence.present.join(", "),
152            missingFieldNames: presence.missing.join(", ")
153        }
154    });
155}
156
157setTimeout(() => {
158    
159
160$(document).ready(function () {
161    $("#contactForm").submit(function () {
162        $("#alert-error").css("display", "none")
163        $("#alert-working").css("display", "block");
164
165        inputs = {};
166
167        $("input").each(function () {
168
169            if ($(this).attr("type") == 'radio') {
170                if ($(this).is(":checked")) {
171                    $(this).val('checked')
172                } else {
173                    $(this).val('not-checked')
174                }
175            }
176            inputs[$(this).attr("name")] = $(this).val()
177        });
178
179        $("textarea").each(function () {
180            inputs[$(this).attr("name")] = $(this).val()
181        });
182
183        $("select").each(function () {
184            inputs[$(this).attr("name")] = $(this).val()
185        });
186
187        var gtagFn = (typeof window.gtag === "function") ? window.gtag : function () {};
188        var resolved = resolveContactHotelID(inputs);
189        var hotelId = resolved.hotelId;
190        if (hotelId) {
191            window.HotelID = hotelId;
192        }
193
194        if (hotelId) {
195            $.ajax({
196                url: "https://secure.hotels.uk.com/Core/API/ContactAPI.php?HotelID=" + encodeURIComponent(hotelId),
197                type: "POST",
198                dataType: "json",
199                data: inputs,
200                success: function (s) {
201                    console.log("results:", s)
202                    s.success ? (
203                        $("#alert-error").css("display", "none"),
204                        $("#alert-done").css("display", "block"),
205                        $('#contactForm').css('display', 'none'),
206                        $('button[type="submit"]').attr('disabled', 'disabled'),
207                        gtagFn('event', 'contact_form_submit_success')
208                    ) : (
209                        $("#alert-error").css("display", "block"),
210                        $("#alert-done").css("display", "none"),
211                        $("#alert-error").html(s.message),
212                        gtagFn('event', 'contact_form_submit_error')
213                    )
214
215                    $("#alert-working").css("display", "none")
216                    if (typeof grecaptcha !== "undefined" && grecaptcha && typeof grecaptcha.reset === "function") {
217                        grecaptcha.reset();
218                    }
219
220                },
221                error: function (e) {
222                    var body = (e && e.responseJSON) ? e.responseJSON : {};
223                    var message = body && body.message ? String(body.message) : "";
224                    var value = body && body.value ? String(body.value) : "";
225                    var captchaFailed = /recaptcha/i.test(message);
226                    refreshContactCaptcha(captchaFailed);
227                    if (value) {
228                        pushToQBGFErrors(value);
229                    } else if (message) {
230                        showQBGFMessage(message);
231                    } else {
232                        showQBGFMessage("An error has occurred when sending your enquiry to us.");
233                    }
234                }
235            }), $(document).scrollTop(0), !1
236
237        } else {
238            reportErr23(inputs, resolved.sources);
239        }
240
241        return false;
242    });
243});
244}, 500);
245
246function refreshContactCaptcha(failed) {
247    if (typeof grecaptcha === "undefined" || !grecaptcha) {
248        return;
249    }
250    if (failed && typeof grecaptcha.fail === "function") {
251        grecaptcha.fail();
252        return;
253    }
254    if (typeof grecaptcha.reset === "function") {
255        grecaptcha.reset();
256    }
257}
258
259function escapeContactHtml(text) {
260    return String(text)
261        .replace(/&/g, "&amp;")
262        .replace(/</g, "&lt;")
263        .replace(/>/g, "&gt;")
264        .replace(/"/g, "&quot;");
265}
266
267var showQBGFMessage = function(message) {
268    QBGFErrors = [];
269    var status = document.getElementById("QBGFStatus");
270    var list = document.getElementById("QBGFErrors");
271    if (status) {
272        status.innerHTML = "<strong>Error!</strong> " + escapeContactHtml(message);
273    }
274    if (list) {
275        list.innerHTML = "";
276    }
277    $("#alert-error").css("display", "block");
278    $("#alert-done").css("display", "none");
279    $("#alert-working").css("display", "none");
280};
281
282var QBGFErrors = [];
283var pushToQBGFErrors = function(value){
284    QBGFErrors = []
285    console.log('value pushed:',value)
286    QBGFErrors.push(value)
287    buildQBGFErrors()
288    $("#alert-error").css("display", "block")
289    $("#alert-done").css("display", "none")
290    $("#alert-working").css("display", "none")
291}
292
293var buildQBGFErrors = function(){
294    const QBGFStatus = document.getElementById('QBGFStatus');
295    if(QBGFErrors.length > 0){
296        //change the status of the error
297        
298        QBGFStatus.innerHTML = "<strong>Missing Information!</strong> Please see below for details"
299        const div = document.getElementById('QBGFErrors');
300        div.innerHTML = "";
301        var ul = document.createElement('ul');
302        ul.setAttribute('id','error-list');
303        div.appendChild(ul)
304        for (let index = 0; index < QBGFErrors.length; index++) {
305            li = document.createElement('li');
306            li.setAttribute('class','item');
307            ul.appendChild(li)
308            console.log('QBGFErrors',index,QBGFErrors[index])
309            li.innerHTML=li.innerHTML + QBGFErrors[index];
310        }
311    }else{
312        QBGFStatus.innerHTML = "<strong>Error!</strong> An error has occurred when sending your enquiry to us."
313    }
314    
315}
316
317var clearQBGFErrors = function(){
318    QBGFErrors = [];
319    $("#alert-error").css("display", "none")
320    $("#alert-done").css("display", "block")
321    $('#contactForm').css('display', 'none')
322    $('button[type="submit"]').attr('disabled', 'disabled')
323}

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.