1/** 2 * Functions for the Maps Page. 3 */ 4const floors = document.querySelectorAll('.clickFloor'); 5 6let firstLoadMaps = true; 7let firstLoadFloors = true; 8let lastRoom = ''; 9 10async function loadTabMaps (element, tabFields, pavilionId, floorId) { 11 const tabsElement = findParent(element, '#tabs'); 12 const currentPavilion = element.id; 13 14 if (tabsElement) { 15 const tabElementsButtons = tabsElement.querySelectorAll('.dropdown__list-item'); 16 const floorTabsElements = document.querySelectorAll('.tabs-component-floors .tabs-component'); 17 18 if (tabElementsButtons) { 19 tabElementsButtons.forEach(tabElementsButton => { 20 let removeAllActive = document.querySelectorAll('#' + tabElementsButton.getAttribute('id') + ', .' + tabElementsButton.getAttribute('id')); 21 22 if (removeAllActive) { 23 removeAllActive.forEach((activeItem) => { 24 activeItem.classList.remove('active'); 25 }); 26 } 27 }); 28 } 29 30 if (floorTabsElements) { 31 floorTabsElements.forEach((floorTabsElement) => { 32 if (!floorTabsElement.classList.contains('tab-hidden')) { 33 floorTabsElement.classList.add('tab-hidden'); 34 floorTabsElement.classList.remove('active'); 35 } 36 }); 37 38 document.querySelector('.tabs-component-floors .tabs-component.' + currentPavilion).classList.remove('tab-hidden'); 39 } 40 } 41 42 firstLoadMaps = false; 43 44 document.getElementsByClassName(currentPavilion)[0].classList.add('active'); 45 document.getElementById(pavilionId).click(); 46 document.getElementById(floorId).click(); 47 48 const mainTabElement = getMainTabElement(element); 49 const mainTabOutput = mainTabElement.querySelector('#tabs-output'); 50 51 addLoading(mainTabOutput); 52 53 const tabContent = await fetchReactComponentByFields('acf/text-images', tabFields); 54 55 updateInnerHTML(mainTabOutput, tabContent); 56 57 removeLoading(mainTabOutput); 58} 59 60async function loadTabFloors (element, finalUrl, roomId) { 61 const tabsElement = findParent(element, '#tabs'); 62 const sectionMapFloor = document.querySelectorAll('.at-map-floor'); 63 64 sectionMapFloor.forEach(floor => { 65 floor.classList.add('floor-hidden'); 66 }); 67 68 let currentfloorId = element.getAttribute('id'); 69 let currentFloor = document.querySelector('.' + currentfloorId); 70 71 let firstRoom = currentFloor.querySelector('.at-map-spot:first-child'); 72 let firstRoomId = firstRoom.getAttribute('data-room-id'); 73 74 currentFloor.classList.remove('floor-hidden'); 75 76 let roomIdReplaced = roomId.replace('room-', ''); 77 let currentRoom = document.querySelector('.' + currentfloorId + '-' + roomIdReplaced); 78 79 if (firstLoadFloors) { 80 if (currentRoom) { 81 currentRoom.click(); 82 } else { 83 firstRoom.click(); 84 85 roomId = 'room-' + firstRoomId; 86 } 87 } else { 88 firstRoom.click(); 89 90 roomId = 'room-' + firstRoomId; 91 } 92 93 firstLoadFloors = false; 94 95 finalUrl = finalUrl + roomId + '/'; 96 97 if (tabsElement) { 98 const tabElementsButtons = tabsElement.querySelectorAll('.dropdown__list-item'); 99 100 if (tabElementsButtons) { 101 tabElementsButtons.forEach(tabElementsButton => { 102 tabElementsButton.classList.remove('active'); 103 }); 104 } 105 } 106 107 element.classList.add('active'); 108 109 if (window.location.hash) { 110 let targetScroll = document.querySelector('.at-map-floor-container'); 111 112 await scrollToElement(targetScroll); 113 } 114 115 injectURL('tabFloors', finalUrl); 116 117 mapTabFloorsURL = finalUrl; 118} 119 120if (floors) { 121 floors.forEach((item, index) => { 122 item.addEventListener('click', async () => { 123 const target = item.getAttribute('data-target'); 124 const targetFloor = document.querySelector('#' + target); 125 const targetScroll = document.querySelector('.tabs-component-floors'); 126 127 await scrollToElement(targetScroll); 128 targetFloor.click(); 129 }); 130 }); 131} 132const mapCollectionsOutput = document.querySelector('#at-maps-collections-output'); 133 134async function changeMapRoom (element, pavilion, roomNumber, locationId, isClicked = false, finalURL) { 135 if (roomNumber === 'RR') { 136 return; 137 } 138 139 mapTabFloorsURL = finalURL; 140 141 if (!Object.keys(mapRoomContent).length) { 142 await fetch('/wp-content/themes/icelander-child/assets/maps/_rooms.json') 143 .then((response) => response.json()) 144 .then(async (mapResponse) => { 145 mapRoomContent = mapResponse; 146 }); 147 } 148 149 for (let pavilion in mapRoomContent) { 150 for (let floor in mapRoomContent[pavilion]['floors']) { 151 if (mapRoomContent[pavilion]['floors'][floor]['roomMappings'][roomNumber]) { 152 let roomTitle = mapRoomContent[pavilion]['floors'][floor]['roomMappings'][roomNumber].title 153 let roomDescription = mapRoomContent[pavilion]['floors'][floor]['roomMappings'][roomNumber].gallery 154 155 document.querySelector('.at-room-map-title').innerHTML = roomTitle ?? ''; 156 document.querySelector('.at-room-map-description >
156 p').innerHTML = roomDescription ?? ''; 157 158 if (isClicked) { 159 activeRoomMap(Object.keys(mapRoomContent[pavilion]['floors'][floor]['roomMappings']), floor, roomNumber); 160 161 let page = roomNumber != lastRoom && lastRoom.length > 0 ? 1 : (mapCollectionsOutput.getAttribute('data-loaded-page') ?? 1); 162 163 await loadMapsRoom(locationId, page); 164 165 lastRoom = roomNumber; 166 } 167 } 168 } 169 } 170} 171 172function activeRoomMap (listRooms, floor, clickedRoom) { 173 listRooms.forEach(item => { 174 document.querySelector('.' + floor + '-' + item).classList.remove('active'); 175 }) 176 177 document.querySelector('.' + floor + '-' + clickedRoom).classList.add('active'); 178} 179 180async function loadMapsRoom (roomNumber, page = 1) { 181 addLoading(mapCollectionsOutput); 182 183 const collectionListToRender = await fetchMapsDynamicGrid(roomNumber, page); 184 185 updateInnerHTML(mapCollectionsOutput, collectionListToRender); 186 187 if (page > 1) { 188 injectURL('maps', mapTabFloorsURL + 'page/' + page); 189 } else { 190 injectURL('maps', mapTabFloorsURL); 191 } 192}
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.