PageSourceSearch

https://www.thechicagohotelcollection.com/script.js

js thechicagohotelcollection.com collected 2026-10-04 20:31:53 UTC 7,719 bytes, 120 lines download raw bytes

1(function(){
2const inlineHotelControls=/^\/(?:ambassadorgoldcoast|magnificentmile|river-north|wrigleyville)\/?$/.test(window.location.pathname);
3const header=inlineHotelControls ? null : document.querySelector("[data-header]");
4const menuButton=inlineHotelControls ? null : document.querySelector(".menu-toggle");
5const navigation=inlineHotelControls ? null : document.querySelector(".primary-nav");
6const updateHeader=()=>header?.classList.toggle("scrolled",window.scrollY>80);
7window.addEventListener("scroll",updateHeader,{passive:true});updateHeader();
8menuButton?.addEventListener("click",()=>{const open=navigation.classList.toggle("open");menuButton.setAttribute("aria-expanded",String(open));});
9navigation?.querySelectorAll("a").forEach(link=>link.addEventListener("click",()=>{navigation.classList.remove("open");menuButton?.setAttribute("aria-expanded","false");}));
10const bookingForm=inlineHotelControls ? null : document.querySelector("[data-booking-form]");
11const bookingUrls={
12  ambassador:"https://thechicagohotelcollection.ihotelier.com/ambassador/book/dates-of-stay",
13  "magnificent-mile":"https://thechicagohotelcollectionmagnificentmile.ihotelier.com/book/dates-of-stay",
14  "river-north":"https://thechicagohotelcollectionrivernorth.ihotelier.com/book/dates-of-stay",
15  wrigleyville:"https://thechicagohotelcollectionwrigleyville.ihotelier.com/book/dates-of-stay"
16};
17const checkInField=bookingForm?.elements.namedItem("check-in");
18const checkOutField=bookingForm?.elements.namedItem("check-out");
19const toLocalDateValue=date=>{
20  const year=date.getFullYear();
21  const month=String(date.getMonth()+1).padStart(2,"0");
22  const day=String(date.getDate()).padStart(2,"0");
23  return `${year}-${month}-${day}`;
24};
25const addDays=(dateValue,days)=>{
26  const [year,month,day]=dateValue.split("-").map(Number);
27  const date=new Date(year,month-1,day);
28  date.setDate(date.getDate()+days);
29  return toLocalDateValue(date);
30};
31const formatIHotelierDate=dateValue=>{
32  const [year,month,day]=dateValue.split("-");
33  return `${month}/${day}/${year}`;
34};
35if(checkInField&&checkOutField){
36  const today=toLocalDateValue(new Date());
37  checkInField.min=today;
38  checkOutField.min=addDays(today,1);
39  checkInField.addEventListener("change",()=>{
40    const earliestCheckout=addDays(checkInField.value,1);
41    checkOutField.min=earliestCheckout;
42    if(!checkOutField.value||checkOutField.value<=checkInField.value)checkOutField.value=earliestCheckout;
43    checkOutField.setCustomValidity("");
44  });
45  checkOutField.addEventListener("change",()=>checkOutField.setCustomValidity(""));
46}
47bookingForm?.addEventListener("submit",event=>{
48  event.preventDefault();
49  if(!bookingForm.reportValidity())return;
50  const formData=new FormData(bookingForm);
51  const destination=String(formData.get("destination")||"");
52  const checkIn=String(formData.get("check-in")||"");
53  const checkOut=String(formData.get("check-out")||"");
54  const [rooms,adults]=String(formData.get("guests")||"1|2").split("|");
55  if(!bookingUrls[destination])return;
56  if(checkOut<=checkIn){
57    checkOutField?.setCustomValidity("Check-out must be after check-in.");
58    checkOutField?.reportValidity();
59    return;
60  }
61  checkOutField?.setCustomValidity("");
62  const bookingUrl=new URL(bookingUrls[destination]);
63  bookingUrl.search=new URLSearchParams({
64    DateIn:formatIHotelierDate(checkIn),
65    DateOut:formatIHotelierDate(checkOut),
66    Adults:adults,
67    Children:"0",
68    Rooms:rooms
69  }).toString();
70  if (bookingUrl.hostname.endsWith(".ihotelier.com")) {
71    let bookingMcpId = "";
72    if (window.CHCMCP && typeof window.CHCMCP.prepareBookingUrl === "function") {
73      try { bookingMcpId = new URL(window.CHCMCP.prepareBookingUrl(bookingUrl.toString())).searchParams.get("chc_mcp_id") || ""; } catch (_) {}
74    }
75    try {
76      bookingMcpId ||= new URL(window.location.href).searchParams.get("chc_mcp_id") || window.localStorage.getItem("chc_mcp_id") || "";
77      if (!bookingMcpId) bookingMcpId = window.crypto?.randomUUID?.() || "chc-" + Date.now().toString(36) + "-" + Math.random().toString(36).slice(2);
78      window.localStorage.setItem("chc_mcp_id", bookingMcpId);
79    } catch (_) {
80      bookingMcpId ||= "chc-" + Date.now().toString(36) + "-" + Math.random().toString(36).slice(2);
81    }
82    bookingUrl.searchParams.set("chc_mcp_id", bookingMcpId);
83  }
84  window.dataLayer=window.dataLayer||[];
85  window.dataLayer.push({
86    event:"booking_search_submit",
87    hotel:destination,
88    check_in:checkIn,
89    check_out:checkOut,
90    rooms:Number(rooms),
91    adults:Number(adults),
92    booking_engine:"ihotelier"
93  });
94  let destinationUrl=window.chcDecorateBookingUrl ? window.chcDecorateBookingUrl(bookingUrl.toString()) : bookingUrl.toString();
95  try {
96    if(window.CHCMCP && typeof window.CHCMCP.prepareBookingUrl==="function") {
97      destinationUrl=window.CHCMCP.prepareBookingUrl(destinationUrl);
98    } else if(destination==="ambassador" || destination==="magnificent-mile") {
99      const visitorId=window.localStorage.getItem("chc_mcp_id");
100      if(visitorId){const prepared=new URL(destinationUrl);prepared.searchParams.set("chc_mcp_id",visitorId);destinationUrl=prepared.toString();}
101    }
102  } catch (_) { /* Booking must remain available if attribution storage is unavailable. */ }
103  window.location.assign(destinationUrl);
104});
105const track=document.querySelector("[data-track]");
106const scrollEvents=direction=>track?.scrollBy({left:direction*Math.min(track.clientWidth*.72,520),behavior:"smooth"});
107document.querySelector("[data-prev]")?.addEventListener("click",()=>scrollEvents(-1));document.querySelector("[data-next]")?.addEventListener("click",()=>scrollEvents(1));
108const reviewsWidget=document.querySelector(".embedsocial-hashtag");
109if(reviewsWidget){const loadReviews=()=>
109{if(document.getElementById("EmbedSocialHashtagScript"))return;const script=document.createElement("script");script.id="EmbedSocialHashtagScript";script.src="https://embedsocial.com/cdn/ht.js";script.async=true;document.head.appendChild(script);};if("IntersectionObserver" in window){const reviewsObserver=new IntersectionObserver(entries=>{if(entries.some(entry=>entry.isIntersecting)){loadReviews();reviewsObserver.disconnect();}},{rootMargin:"500px 0px"});reviewsObserver.observe(reviewsWidget);}else{loadReviews();}}
110const privateEventsFrame=document.querySelector(".video-frame");
111const privateEventsVideo=privateEventsFrame?.querySelector("video");
112const privateEventsPlay=privateEventsFrame?.querySelector(".media-play");
113const syncPrivateEventsState=()=>{const playing=Boolean(privateEventsVideo&&!privateEventsVideo.paused);privateEventsFrame?.classList.toggle("playing",playing);privateEventsPlay?.setAttribute("aria-label",playing?"Pause private events video":"Play private events video");};
114privateEventsPlay?.addEventListener("click",()=>privateEventsVideo?.play());
115privateEventsVideo?.addEventListener("click",()=>privateEventsVideo.paused?privateEventsVideo.play():privateEventsVideo.pause());
116privateEventsVideo?.addEventListener("play",syncPrivateEventsState);
117privateEventsVideo?.addEventListener("pause",syncPrivateEventsState);
118if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){const heroVideo=document.querySelector(".hero-media");heroVideo?.pause();heroVideo?.removeAttribute("autoplay");}
119if("IntersectionObserver" in window){const observer=new IntersectionObserver((entries,watcher)=>entries.forEach(entry=>{if(entry.isIntersecting){entry.target.classList.add("visible");watcher.unobserve(entry.target);}}),{threshold:.1});document.querySelectorAll(".reveal").forEach(element=>observer.observe(element));}else{document.querySelectorAll(".reveal").forEach(element=>element.classList.add("visible"));}
120})();

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.