1function dotNotateObject(obj, maxdepth = 2) { 2 3 if (obj.constructor?.name !== 'Object') { return; } 4 5 function doLayer(layer, path = []) { 6 var keyPrefix = path.join("."); 7 if (keyPrefix.length) { keyPrefix += "."; } 8 9 Object.entries(layer).forEach(function([key, val]) { 10 obj[keyPrefix + key] = val; 11 if (path.length < maxdepth && typeof val === 'object' && val?.constructor?.name === 'Object') { 12 doLayer(val, [...path, key]); 13 } 14 }); 15 } 16 17 Object.entries(obj).forEach(function([key, val]) { 18 if (typeof val !== 'object' || val?.constructor?.name !== 'Object') { return; } 19 doLayer(val, [key]); 20 }); 21 22} 23 24function parseIconClass(cla) { 25 cla = cla ?? ""; 26 var icon = { class: "", ligature: "" }; 27 icon.class = cla.replaceAll(/\|[\w-].+/g, ""); 28 29 if (cla.search(/[\w-].+\|/g) > -1) { 30 icon.ligature = cla.replaceAll(/[\w-].+\|/g, ""); 31 } 32 33 return icon; 34} 35 36document.addEventListener('DOMContentLoaded', async function() { 37 38 window.revizeFeeds = window.revizeFeeds ?? {}; 39 40 function addToBucket(map, key, val) { 41 if (!map[key]) map[key] = []; 42 map[key].push(val); 43 } 44 45 document.querySelectorAll("slot[data-type='dot-feed']").forEach(function(slotEl) { 46 47 var template = slotEl.dataset["contentTemplate"] ?? null; 48 var feedURL = slotEl.dataset["contentFeed"] ?? null; 49 if (template == null || feedURL == null) { return; } 50 51 var options = {}; 52 try { 53 options = JSON.parse(slotEl.dataset["contentOptions"] ?? null) ?? {}; 54 } catch (e) { } 55 56 addToBucket(window.revizeFeeds, feedURL, { elem: slotEl, template, options }); 57 }); 58 59 Object.entries(window.revizeFeeds).forEach(async function([feedURL, feedValues]) { 60 61 var feedData = await fetch(feedURL + "?v=" + Math.floor(Math.random() * 9999)).then(async function(resp) { return await resp.json(); }); 62 if (!feedData) { return; } 63 64 feedValues.forEach(async function(feedValue) { 65 if (!(feedValue.elem instanceof HTMLElement) || !(feedValue.elem.parentElement instanceof HTMLElement)) { return; } 66 67 var contentMarkup = feedValue.template; 68 if (!contentMarkup) { return; } 69 70 var markupFn = function() { return ""; }; 71 72 if (contentMarkup && typeof window[contentMarkup] === "function") { 73 markupFn = window[contentMarkup]; 74 } else { 75 try { 76 var templateString = await fetch(contentMarkup).then(async function(resp) { return await resp.text(); }); 77 var templateSettings = Object.assign({}, doT.templateSettings); 78 79 templateSettings.strip = false; 80 81 markupFn = doT.template(templateString, templateSettings, {}); 82 } catch (e) { 83 console.error("Template fetch error:", e); 84 } 85 } 86 87 var containerEl = feedValue.elem.parentElement; 88 89 Object.keys(feedData).forEach(function(key) { 90 if (!Number.isNaN(parseInt(key))) { 91 dotNotateObject(feedData[key]); 92 } 93 }); 94 95 if (!(feedValue.elem instanceof HTMLElement) || !(feedValue.elem.parentElement instanceof HTMLElement)) { return; } // We're in an async thread now so we need to check again. 96 containerEl.innerHTML = markupFn({ data: feedData, options: feedValue.options }); 97 98 document.dispatchEvent(new CustomEvent('rz:cards-ready', { detail: { container: containerEl } })); // added this for search bars 99 100 if (containerEl.classList.contains("tiny-deferred")) { 101 if (window.RZTinyCarousel) window.RZTinyCarousel(containerEl); 102 } else if (containerEl.classList.contains("masonry-deferred")) { 103 if (window.RZMasonry) window.RZMasonry(containerEl); 104 } 105 }); 106 }); 107 108}); 109/* 110document.addEventListener('DOMContentLoaded', async function() { 111 112 function addToBucket(map, key, val) { 113 if (!map[key]) map[key] = []; 114 map[key].push(val); 115 } 116 function safeGet(el, name, def = '') { 117 return el && el.dataset ? el.dataset[name] : def; 118 } 119 120 const feedMap = {}; 121 122 document.querySelectorAll(".rz-news-card-wrapper .rz-news-card-list slot").forEach((slotEl) => { 123 const containerEl = slotEl.closest(".rz-news-card-list"); 124 const feedURL = safeGet(slotEl, "contentFeed") || "_includes_/published/news_list.json"; 125 if (containerEl) addToBucket(feedMap, feedURL, { slotEl, containerEl }); 126 }); 127 128 document.querySelectorAll(".rz-job-post-wrap .rz-job-card-list slot").forEach((slotEl) => { 129 const containerEl = slotEl.closest(".rz-job-card-list"); 130 const feedURL = safeGet(slotEl, "contentFeed") || "_includes_/published/job_list.json"; 131 if (containerEl) addToBucket(feedMap, feedURL, { slotEl, containerEl }); 132 }); 133 134 document.querySelectorAll(".rz-catalogue-wrap .rz-catalogue-card-list slot").forEach((slotEl) => { 135 const containerEl = slotEl.closest(".rz-catalogue-card-list"); 136 const feedURL = safeGet(slotEl, "contentFeed") || "_includes_/published/catalogue.json"; 137 if (containerEl) addToBucket(feedMap, feedURL, { slotEl, containerEl }); 138 }); 139 140 141 const renderedContainers = new WeakSet(); 142 143 function buildFeedMarkup(_json) { return ""; } 144 145 async function buildListFromJSON(entry, json) { 146 const { slotEl, containerEl } = entry; 147 if (!containerEl || renderedContainers.has(containerEl)) return; 148 149 let markupFn = buildFeedMarkup; 150 151 const contentMarkup = safeGet(slotEl, "contentMarkup"); 152 const contentTemplateURL = safeGet(slotEl, "contentTemplate"); 153 const contentFeedLimit = parseInt(safeGet(slotEl, "feedLimit", "-1")); 154 155 if (contentMarkup && typeof window[contentMarkup] === "function") { 156 markupFn = window[contentMarkup]; 157 } else if (contentTemplateURL) {
158 try { 159 const res = await fetch(contentTemplateURL); 160 const templateString = await res.text(); 161 markupFn = doT.template(templateString); 162 } catch (e) { 163 console.error("Template fetch error:", e); 164 } 165 } 166 167 const catsRaw = 168 safeGet(slotEl, "articleCategories") || 169 safeGet(containerEl, "articleCategories") || 170 ""; 171 const feedCategories = catsRaw ? catsRaw.split("|").map(s => s.trim()).filter(Boolean) : []; 172 173 let filtered = json; 174 if (feedCategories.length && json && typeof json === "object") { 175 filtered = Object.fromEntries( 176 Object.entries(json).filter(([_, val]) => { 177 const rid = val && val.options ? val.options.category_rid : null; 178 return rid ? feedCategories.indexOf(rid) > -1 : false; 179 }) 180 ); 181 } 182 183 if (contentFeedLimit > -1) { 184 filtered = filtered.slice(0, Math.min(filtered.length, contentFeedLimit)); 185 } 186 187 try { 188 // Some templates expect an array; if yours expects an object, keep 'filtered' as is 189 const html = typeof markupFn === "function" ? markupFn(filtered) : ""; 190 containerEl.innerHTML = html; 191 192 document.dispatchEvent(new CustomEvent('rz:cards-ready', { detail: { container: containerEl } })); // added this for search bars 193 194 renderedContainers.add(containerEl); 195 } catch (e) { 196 console.error("Markup render error:", e); 197 } 198 199 if (containerEl.classList.contains("tiny-deferred")) { 200 if (window.RZTinyCarousel) window.RZTinyCarousel(containerEl); 201 } else if (containerEl.classList.contains("masonry-deferred")) { 202 if (window.RZMasonry) window.RZMasonry(containerEl); 203 } 204 } 205 206 for (const feedURL of Object.keys(feedMap)) { 207 try { 208 const resp = await fetch(feedURL); 209 if (!resp.ok) { 210 console.error("Feed HTTP error:", resp.status, feedURL); 211 continue; 212 } 213 const feedJSON = await resp.json(); 214 215 for (const entry of feedMap[feedURL]) { 216 await buildListFromJSON(entry, feedJSON); 217 } 218 } catch (e) { 219 console.error("Feed fetch/parse error:", feedURL, e); 220 } 221 } 222});*/
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.