@xiee/utils
Advanced tools
Comparing version 1.12.14 to 1.12.15
@@ -90,3 +90,3 @@ (function(d) { | ||
let f = s.querySelector('section.footnotes'); | ||
if (!f) { | ||
if (!f || f.contains(li)) { | ||
f = newEl('section', 'footnotes'); footer.before(f); | ||
@@ -93,0 +93,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(e){let t=e.body;const n=":scope > h2";function o(e,n=1){if(t.querySelectorAll(e).length>=n)return!0;for(let o=0;o<t.children.length;o++)if(t.children[o].querySelectorAll(e).length>=n){t=t.children[o];break}return!1}function r(t,n){const o=e.createElement(t);return n&&(o.className=n),o}if(!o(":scope > hr:not([class])",3)&&"BODY"===t.tagName){if(!o(n)&&"BODY"===t.tagName)return;t.querySelectorAll(n).forEach((e=>e.before(r("hr"))))}function i(e){return""===e?.innerText?e:r("div","slide")}function s(e){return"HR"===e.tagName&&0===e.attributes.length}t.classList.add("slide-container"),[".frontmatter","#TOC"].forEach((t=>{const n=e.body.querySelector(t);if(n)if(".frontmatter"===t)n.classList.add("slide");else{const e=i();n.before(e),e.append(n)}}));let l=t.firstElementChild;if(s(l)&&l.remove(),l=t.firstElementChild,!l)return;let c=i();for(l.before(c);;){let e=c.nextSibling;if(!e)break;s(e)?(c=i(c),e.before(c),e.remove()):e.classList?.contains("slide")?(c=i(c),e.after(c)):c.append(e)}function a(e,t){const n=r("div");n.innerHTML=`<div ${t}></div>`;const o=n.firstElementChild.attributes;for(const t of o)e.setAttribute(t.name,t.value);n.remove()}function d(e){setTimeout((()=>e?.scrollIntoView()),100)}const f=e.documentElement,u=e.body.classList,h=e.querySelectorAll("div.slide"),m=h.length,p=e.querySelector("span.timer"),y=e.querySelector(".footnotes");h.forEach(((e,t)=>{const n=r("div","header"),o=r("div","main"),i=r("div","footer");o.append(...e.childNodes),e.append(o),e.insertAdjacentElement("afterbegin",n),e.insertAdjacentElement("beforeend",i),y&&e.querySelectorAll('.footnote-ref > a[href^="#fn"]').forEach((t=>{const n=y.querySelector("li"+t.getAttribute("href"));if(!n)return;let o=e.querySelector("section.footnotes");o||(o=r("section","footnotes"),i.before(o)),o.append(n),n.firstElementChild?.insertAdjacentHTML("afterbegin",`[${t.innerHTML}] `),n.outerHTML=n.innerHTML})),i.append(p?p.cloneNode():r("span","timer"));const s=r("span","page-number");s.innerText=t+1+"/"+m,s.onclick=e=>location.hash=t+1,i.append(s);for(const t of o.childNodes){if(t.nodeType!==Node.COMMENT_NODE)continue;let n=t.textContent;if(!/^#/.test(n))continue;n=n.replace(/^#/,"");const o=/[\s\n]class="([^"]+)"/,r=n.match(o);r&&(n=n.replace(o,"").trim(),e.className+=" "+r[1]),n&&a(e,n);break}e.addEventListener("click",(e=>{(e.altKey||e.ctrlKey)&&(q(e),d(e.target))}))})),[...e.querySelectorAll("a.footnote-backref"),y,p].forEach((e=>e?.remove()));const g=e.querySelectorAll("span.timer"),b=1e3*g[0].dataset.total;let v;function E(){v=new Date,setInterval(S,1e3)}function S(){if(!u.contains("slide-mode"))return;let e=new Date-v;b&&(e=b-e);const t=new Date(Math.abs(e)).toISOString().substr(11,8).replace(/^00:/,"");g.forEach((n=>{n.innerText=t,e<0&&(n.style.opacity=Math.ceiling(e/1e3)%2)}))}function q(e){u.toggle("overview")?u.remove("slide-mode"):N(e)}e.addEventListener("keyup",(t=>{t.target===e.body&&("f"===t.key&&f.requestFullscreen(),"o"===t.key&&q(t),"m"===t.key&&u.toggle("mirrored"),sessionStorage.setItem("body-class",e.body.className))})),e.onfullscreenchange=t=>{e.fullscreenElement&&(!v&&E(),N(t))},g.forEach((e=>e.addEventListener("click",(e=>E()))));let L=-1;function T(){if(L>=0)return L;const e=r("div","slide");return t.querySelector(".slide:last-of-type").after(e),L=e.offsetHeight,e.remove(),L}const w=r("style");w.setAttribute("type","text/css"),e.head.append(w),w.innerHTML=`:root{--slide-ratio:${screen.height/screen.width}}`;const A=+getComputedStyle(f).getPropertyValue("--slide-ratio");function N(t){if("load"===t.type&&d(h[location.hash.replace(/^#/,"")-1]),u.contains("overview"))return;let n=window.innerHeight,o=n/900,i=n/window.innerWidth,s=e.fullscreenElement;u.toggle("slide-mode",s||i<=A)&&!s&&f.scrollWidth>f.offsetWidth&&u.remove("slide-mode"),w.innerHTML=`:root{--slide-ratio:${A};--slide-scale:${o};--slide-top:${(o-1)/2*e.body.scrollHeight+"px"};}`,!e.querySelector(".spacer.fade")&&u.contains("slide-mode")&&h.forEach((e=>{const t=r("div","spacer fade"),n=e.offsetHeight,i=T();e.append(t),n<=i||(t.style.height=(i-n%i)*o+"px")}))}["load","resize"].forEach((e=>window.addEventListener(e,N)));const H=sessionStorage.getItem("body-class");H&&(e.body.className+=" "+H)}(document); | ||
!function(e){let t=e.body;const n=":scope > h2";function o(e,n=1){if(t.querySelectorAll(e).length>=n)return!0;for(let o=0;o<t.children.length;o++)if(t.children[o].querySelectorAll(e).length>=n){t=t.children[o];break}return!1}function r(t,n){const o=e.createElement(t);return n&&(o.className=n),o}if(!o(":scope > hr:not([class])",3)&&"BODY"===t.tagName){if(!o(n)&&"BODY"===t.tagName)return;t.querySelectorAll(n).forEach((e=>e.before(r("hr"))))}function i(e){return""===e?.innerText?e:r("div","slide")}function s(e){return"HR"===e.tagName&&0===e.attributes.length}t.classList.add("slide-container"),[".frontmatter","#TOC"].forEach((t=>{const n=e.body.querySelector(t);if(n)if(".frontmatter"===t)n.classList.add("slide");else{const e=i();n.before(e),e.append(n)}}));let l=t.firstElementChild;if(s(l)&&l.remove(),l=t.firstElementChild,!l)return;let c=i();for(l.before(c);;){let e=c.nextSibling;if(!e)break;s(e)?(c=i(c),e.before(c),e.remove()):e.classList?.contains("slide")?(c=i(c),e.after(c)):c.append(e)}function a(e,t){const n=r("div");n.innerHTML=`<div ${t}></div>`;const o=n.firstElementChild.attributes;for(const t of o)e.setAttribute(t.name,t.value);n.remove()}function d(e){setTimeout((()=>e?.scrollIntoView()),100)}const f=e.documentElement,u=e.body.classList,h=e.querySelectorAll("div.slide"),m=h.length,p=e.querySelector("span.timer"),y=e.querySelector(".footnotes");h.forEach(((e,t)=>{const n=r("div","header"),o=r("div","main"),i=r("div","footer");o.append(...e.childNodes),e.append(o),e.insertAdjacentElement("afterbegin",n),e.insertAdjacentElement("beforeend",i),y&&e.querySelectorAll('.footnote-ref > a[href^="#fn"]').forEach((t=>{const n=y.querySelector("li"+t.getAttribute("href"));if(!n)return;let o=e.querySelector("section.footnotes");o&&!o.contains(n)||(o=r("section","footnotes"),i.before(o)),o.append(n),n.firstElementChild?.insertAdjacentHTML("afterbegin",`[${t.innerHTML}] `),n.outerHTML=n.innerHTML})),i.append(p?p.cloneNode():r("span","timer"));const s=r("span","page-number");s.innerText=t+1+"/"+m,s.onclick=e=>location.hash=t+1,i.append(s);for(const t of o.childNodes){if(t.nodeType!==Node.COMMENT_NODE)continue;let n=t.textContent;if(!/^#/.test(n))continue;n=n.replace(/^#/,"");const o=/[\s\n]class="([^"]+)"/,r=n.match(o);r&&(n=n.replace(o,"").trim(),e.className+=" "+r[1]),n&&a(e,n);break}e.addEventListener("click",(e=>{(e.altKey||e.ctrlKey)&&(q(e),d(e.target))}))})),[...e.querySelectorAll("a.footnote-backref"),y,p].forEach((e=>e?.remove()));const g=e.querySelectorAll("span.timer"),b=1e3*g[0].dataset.total;let v;function E(){v=new Date,setInterval(S,1e3)}function S(){if(!u.contains("slide-mode"))return;let e=new Date-v;b&&(e=b-e);const t=new Date(Math.abs(e)).toISOString().substr(11,8).replace(/^00:/,"");g.forEach((n=>{n.innerText=t,e<0&&(n.style.opacity=Math.ceiling(e/1e3)%2)}))}function q(e){u.toggle("overview")?u.remove("slide-mode"):N(e)}e.addEventListener("keyup",(t=>{t.target===e.body&&("f"===t.key&&f.requestFullscreen(),"o"===t.key&&q(t),"m"===t.key&&u.toggle("mirrored"),sessionStorage.setItem("body-class",e.body.className))})),e.onfullscreenchange=t=>{e.fullscreenElement&&(!v&&E(),N(t))},g.forEach((e=>e.addEventListener("click",(e=>E()))));let L=-1;function T(){if(L>=0)return L;const e=r("div","slide");return t.querySelector(".slide:last-of-type").after(e),L=e.offsetHeight,e.remove(),L}const w=r("style");w.setAttribute("type","text/css"),e.head.append(w),w.innerHTML=`:root{--slide-ratio:${screen.height/screen.width}}`;const A=+getComputedStyle(f).getPropertyValue("--slide-ratio");function N(t){if("load"===t.type&&d(h[location.hash.replace(/^#/,"")-1]),u.contains("overview"))return;let n=window.innerHeight,o=n/900,i=n/window.innerWidth,s=e.fullscreenElement;u.toggle("slide-mode",s||i<=A)&&!s&&f.scrollWidth>f.offsetWidth&&u.remove("slide-mode"),w.innerHTML=`:root{--slide-ratio:${A};--slide-scale:${o};--slide-top:${(o-1)/2*e.body.scrollHeight+"px"};}`,!e.querySelector(".spacer.fade")&&u.contains("slide-mode")&&h.forEach((e=>{const t=r("div","spacer fade"),n=e.offsetHeight,i=T();e.append(t),n<=i||(t.style.height=(i-n%i)*o+"px")}))}["load","resize"].forEach((e=>window.addEventListener(e,N)));const H=sessionStorage.getItem("body-class");H&&(e.body.className+=" "+H)}(document); |
{ | ||
"name": "@xiee/utils", | ||
"version": "1.12.14", | ||
"version": "1.12.15", | ||
"description": "Miscellaneous tools and utilities to manipulate HTML pages", | ||
@@ -5,0 +5,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
114478