1"use strict";(self.webpackChunkuon_2020_scripts=self.webpackChunkuon_2020_scripts||[]).push([[263],{605:function(t,e,o){o.r(e),e.default=class{constructor(){this.pre_select_text=document.querySelector(".pre-select-text"),this.rooms_content=document.getElementById("rooms-content"),this.location_dropdown_wrappers=document.querySelectorAll(".location-dropdown-wrapper"),this.select_location=document.querySelectorAll(".select-location"),this.location_btn=document.querySelectorAll(".location-btn"),this.room_dropdown_wrappers=document.querySelectorAll(".room-dropdown-wrapper"),this.select_room=document.querySelectorAll(".select-room"),this.room_dropdown_content=document.querySelectorAll(".room-dropdown-content"),this.hall_names=document.querySelectorAll(".hall-name"),this.room_btns_col_1,this.room_btns_col_2,this.room_btns_col_3,this.room_btns_col_4,this.room_costs=document.querySelectorAll(".room-cost"),this.features=document.querySelectorAll(".room-feature"),this.room_specs=document.querySelectorAll(".room-specs"),this.distances=document.querySelectorAll(".distances"),this.all_features=["wifi","utilities","shower","toilet","kitchen","space","kitchenette","accessible-en-suite"],this.all_features=[{value:"wifi",label:"Free Wi-Fi"},{value:"utilities",label:"Utilities included"},{value:"shower",label:"En-suite shower"},{value:"toilet",label:"Shared bathroom"},{value:"kitchen",label:"Communal kitchen"},{value:"space",label:"Communal spaces"},{value:"kitchenette",label:"Kitchenette"},{value:"accessible-en-suite",label:"Accessible en-suite"}],this.waterside_rooms=waterside_buildings,this.off_campus_buildings=off_campus_buildings,Object.keys(localStorage).forEach((t=>{t.startsWith("https://www.northampton.ac.uk/wp-json/wp/v2/accommodation")&&t.includes("?slug")&&localStorage.removeItem(t)})),this.events()}events(){this.select_location.forEach((t=>{t.addEventListener("click",(()=>{t.parentNode.classList.toggle("active"),t.parentNode.classList.contains("active")?t.setAttribute("aria-expanded",!0):t.setAttribute("aria-expanded",!1)}))})),this.select_room.forEach((t=>{t.addEventListener("click",(()=>{t.parentNode.classList.toggle("active"),t.parentNode.classList.contains("active")?t.setAttribute("aria-expanded",!0):t.setAttribute("aria-expanded",!1)}))})),this.location_btn.forEach((t=>{t.addEventListener("click",(()=>{let e=t.getAttribute("data-position"),o=t.getAttribute("data-location"),s=t.innerText;this.select_room.forEach((t=>{let s=t.getAttribute("data-position");e==s&&(t.getAttribute("data-location")!==o&&(t.innerHTML='Room<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve">\n <path class="icon" d="M50,75L2.5,28.4L6.1,25L50,68.2L93.9,25l3.6,3.4L50,75z"></path>\n </svg>'),t.dataset.location=o)})),this.hall_names.forEach((t=>{let s=t.getAttribute("data-position");e==s&&(t.getAttribute("data-location")!==o&&(t.innerHTML=""),t.dataset.location=o)})),this.set_location_dropdown_name(e,s),this.set_room_dropdown_content(e,o),this.room_btns_col_1=document.querySelectorAll(".room-1"),this.room_btns_col_2=document.querySelectorAll(".room-2"),this.room_btns_col_3=document.querySelectorAll(".room-3"),this.room_btns_col_4=document.querySelectorAll(".room-4"),this.set_room_events(this.room_btns_col_1),this.set_room_events(this.room_btns_col_2),this.set_room_events(this.room_btns_col_3),this.set_room_events(this.room_btns_col_4),this.location_dropdown_wrappers.forEach((t=>{let o=t.getAttribute("data-position");e==o&&t.classList.remove("active")}))}))}))}rooms_html(t,e){let o;o="waterside"==e?Object.entries(this.waterside_rooms):Object.entries(this.off_campus_buildings);const s=o.map((e=>{let[o,s]=e;return`<div class="room-group"><span>${o}</span>${s.map((e=>`<button aria-label="Select ${e.room_name}" class="room room-${t}" data-position="${t}" data-slug="${e.slug}" data-name="${e.room_name}" data-hall="${e.hall_name}" data-initials="${e.room_initials}">${e.room_name}</button>`)).join("")}</div>`})),a=s.join("");return`<div class="rooms" data-position="${t}">${a}</div>`}
1cost_html(t,e){this.room_costs.forEach((o=>{o.getAttribute("data-position")==t&&(o.innerHTML=`<div class="h3">${e}</div>`)}))}features_html(t,e){let o=this.all_features.map((t=>e.find((e=>e.value===t.value))||{value:!1,label:'<span class="feature-blank">‒</span>'})).map((t=>`<div class="active">${!1!==t.value?`<img src='/wp-content/themes/uon-2020/assets/images/svg/accommodation/${t.value}.svg' />`:""}${t.label}</div>`)).join("");this.features.forEach((e=>{e.getAttribute("data-position")==t&&(e.innerHTML=o)}))}room_specs_html(t,e){let o=e.map((t=>`<li>\n <span>${t.value}</span>\n </li> \n `)).join("");this.room_specs.forEach((e=>{e.getAttribute("data-position")==t&&(e.innerHTML=`<div><ul>${o}</ul></div>`)}))}distances_html(t,e){this.distances.forEach((o=>{o.getAttribute("data-position")==t&&(o.innerHTML=`<div>${e}</div>`)}))}set_location_dropdown_name(t,e){this.select_location.forEach((o=>{o.getAttribute("data-position")==t&&(o.innerHTML=`${e}<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve">\n <path class="icon" d="M50,75L2.5,28.4L6.1,25L50,68.2L93.9,25l3.6,3.4L50,75z"></path>\n </svg>`,o.setAttribute("aria-expanded",!1))}))}set_room_dropdown_name(t,e,o){this.select_room.forEach((o=>{o.getAttribute("data-position")==t&&(o.innerHTML=`${e}<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve">\n <path class="icon" d="M50,75L2.5,28.4L6.1,25L50,68.2L93.9,25l3.6,3.4L50,75z"></path>\n </svg>`,o.setAttribute("aria-expanded",!1))}))}set_room_events(t){t.forEach((e=>{let o=e.getAttribute("data-slug"),s=e.getAttribute("data-position"),a=e.getAttribute("data-name"),i=e.getAttribute("data-initials"),n=e.getAttribute("data-hall");e.addEventListener("click",(r=>{r.preventDefault(),this.pre_select_text.style.display="none",this.rooms_content.style.display="block",Array.from(t).filter((t=>t!==e)).forEach((t=>{t.classList.remove("active")})),e.classList.contains("active")||(this.set_room_dropdown_name(s,a,i),this.getRoomResults(o,s)),e.classList.add("active"),this.room_dropdown_wrappers.forEach((t=>{t.getAttribute("data-position")==s&&t.classList.remove("active")})),this.hall_names.forEach((t=>{t.getAttribute("data-position")==s&&(t.innerHTML=n)}))}))}))}set_room_dropdown_content(t,e){this.room_dropdown_content.forEach((o=>{let s=o.getAttribute("data-position");s==t&&(o.innerHTML="waterside"==e?this.rooms_html(s,"waterside"):this.rooms_html(s,"off-campus"))}))}async getRoomResults(t,e){try{let o;const s=localStorage.getItem("https://www.northampton.ac.uk/wp-json/wp/v2/accommodation?slug="+t);if(s)o=JSON.parse(s);else{const e=await fetch("https://www.northampton.ac.uk/wp-json/wp/v2/accommodation?slug="+t);o=await e.json()}o.map((t=>{this.cost_html(e,t.acf.cost),this.features_html(e,t.acf.features),this.room_specs_html(e,t.acf.room_specs),this.distances_html(e,t.acf.distance)}))}catch(t){console.warn(t)}}}}}]);
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.