window.addEventListener("DOMContentLoaded", function () { document.querySelectorAll(".combo-cache-item").forEach((metadataControlItem) => { metadataControlItem.addEventListener("click", async function (event) { event.preventDefault(); const combo = /** @type {import('combo.d.ts')} */ (window.combo); if(!('JSINFO' in window)){ throw new Error("JSINFO is not available") } const JSINFO = window.JSINFO; let pageId = JSINFO.id; let modalBacklinkId = combo.Html.toHtmlId(`combo-cache-${pageId}`); let cacheModal = combo.Modal .getOrCreate(modalBacklinkId) .resetIfBuild() .addDialogClass("modal-fullscreen-md-down"); /** * Creating the form */ let html = `

List of cache information for the slots of the page (${pageId}).

`; /** * Add the page runtime cache metadata field */ let cachePageInfo = document.querySelector('script[type="application/combo+cache+json"]'); if (cachePageInfo !== null) { let cachePageJsonString = cachePageInfo .innerText .trim() .slice("/**/".length)); html += ``; let cachePageJson = JSON.parse(cachePageJsonString); for (let slot in cachePageJson) { if (!cachePageJson.hasOwnProperty(slot)) { continue; } let formatResults = cachePageJson[slot]; let outputCounterBySlot = 0; let slotUrl = combo.DokuUrl.createEdit(slot).toString() let slotLabel = `${slot}`; for (let formatResult in formatResults) { if (!formatResults.hasOwnProperty(formatResult)) { continue; } outputCounterBySlot++; if (outputCounterBySlot > 1) { slotLabel = ""; } let result = formatResults[formatResult]; // Mode let styledFormatResult; if (formatResult === "i") { styledFormatResult = "Parse Instructions" } else { styledFormatResult = formatResult.charAt(0).toUpperCase() + formatResult.slice(1); } let hit = result["result"]; let checkedBox = ""; if (hit === true) { checkedBox = "checked"; } let hitHtml = ` ` let mtime = combo.Date.createFromIso(result["mtime"]).toSqlTimestampString(); let file = result["file"]; let fileLabel = file.substring(file.indexOf(':') + 1, file.lastIndexOf('.') - 2); let fileUrl = combo.DokuUrl .createFetch(file, 'cache') .toString(); let fileAnchor = `${fileLabel}`; let dependencies = ""; let dependency = result["dependency"]; if (typeof dependency !== 'undefined') { dependencies = dependency.join(", "); } html += ``; } } html += '
SlotOutputCache
Hit
Modification
Time
Cache DepsCache File
${slotLabel}${styledFormatResult}${hitHtml}${mtime}${dependencies}${fileAnchor}

'; } /** * The modal */ cacheModal .setHeader(`Cache Info for the page (${pageId})`) .addBody(html) .addFooterCloseButton() .show(); }); }); } );