diff --git a/doc/static/markdown_spa.js b/doc/static/markdown_spa.js index c61c8ba..9fe7299 100644 --- a/doc/static/markdown_spa.js +++ b/doc/static/markdown_spa.js @@ -1,47 +1,44 @@ -if (typeof preFetch !== 'function') { function preFetch() {} } -if (typeof postFetch !== 'function') { function postFetch() {} } - async function updatePage(path) { - preFetch(); + preFetch(); - if (typeof updateWithJSON === 'function') { - updateWithJSON(await fetch(path+'index.json').then(r => r.json())); - } else { - let text = await fetch(path).then(r => r.text()); - document.documentElement.innerHTML = text; - } + if (typeof updateWithJSON === "function") { + updateWithJSON(await fetch(path + "index.json").then((r) => r.json())); + } else { + let text = await fetch(path).then((r) => r.text()); + document.documentElement.innerHTML = text; + } - postFetch(); + postFetch(); } postFetch(); let curPath = window.location.pathname; -window.addEventListener('popstate', async _ => { - if (window.location.pathname == curPath) { - return; - } +window.addEventListener("popstate", async (_) => { + if (window.location.pathname == curPath) { + return; + } - curPath = window.location.pathname; - await updatePage(window.location.href); + curPath = window.location.pathname; + await updatePage(window.location.href); }); -window.addEventListener('click', e => { - let targetAnchor = e.target.closest('a'); - if (!targetAnchor || !targetAnchor.hasAttribute("href")) { - return; - } +window.addEventListener("click", (e) => { + let targetAnchor = e.target.closest("a"); + if (!targetAnchor || !targetAnchor.hasAttribute("href")) { + return; + } - href = (targetAnchor) ? targetAnchor.href : e.target.href; - e.preventDefault(); + href = targetAnchor ? targetAnchor.href : e.target.href; + e.preventDefault(); - if (href == window.location.href) { - return; - } + if (href == window.location.href) { + return; + } - if (href.startsWith(window.location.origin)) { - e.preventDefault(); - updatePage(href); - window.history.pushState({}, '', href); - } -}) + if (href.startsWith(window.location.origin)) { + e.preventDefault(); + updatePage(href); + window.history.pushState({}, "", href); + } +}); diff --git a/doc/static/script.js b/doc/static/script.js index 73e0aa5..6467b73 100644 --- a/doc/static/script.js +++ b/doc/static/script.js @@ -1,28 +1,31 @@ -let loader = document.getElementById('loader'); -let input = document.getElementById('show-nav') +let loader = document.getElementById("loader"); +let input = document.getElementById("show-nav"); function preFetch() { - loader.classList.add('active'); + loader.classList.add("active"); } function updateWithJSON(json) { - document.title = `Markdown SPA - ${json.name}`; - document.querySelector('meta[name="description"]').content = json.description; - document.querySelector('#content').innerHTML = `