mirror of https://github.com/logos-co/roadmap.git
9 lines
1.4 KiB
JavaScript
9 lines
1.4 KiB
JavaScript
function htmlToElement(a){const b=document.createElement("template");return a=a.trim(),b.innerHTML=a,b.content.firstChild}function initPopover(a,b,c){const d=a.replace(window.location.origin,"");fetchData.then(({content:a})=>{const e=[...document.getElementsByClassName("internal-link")];e.filter(a=>a.dataset.src||a.dataset.idx&&b).forEach(e=>{var b;if(e.dataset.ctx){const c=a[e.dataset.src],d=`<div class="popover">
|
|
<h3>${c.title}</h3>
|
|
<p>${highlight(removeMarkdown(c.content),e.dataset.ctx)}...</p>
|
|
<p class="meta">${new Date(c.lastmodified).toLocaleDateString()}</p>
|
|
</div>`;b=htmlToElement(d)}else{const c=a[e.dataset.src.replace(/\/$/g,"").replace(d,"")];if(c){const a=`<div class="popover">
|
|
<h3>${c.title}</h3>
|
|
<p>${removeMarkdown(c.content).split(" ",20).join(" ")}...</p>
|
|
<p class="meta">${new Date(c.lastmodified).toLocaleDateString()}</p>
|
|
</div>`;b=htmlToElement(a)}}b&&(e.appendChild(b),c&&renderMathInElement(b,{delimiters:[{left:'$$',right:'$$',display:!1},{left:'$',right:'$',display:!1},{left:'\\(',right:'\\)',display:!1},{left:'\\[',right:'\\]',display:!1}],throwOnError:!1}),e.addEventListener("mouseover",()=>{window.FloatingUIDOM.computePosition(e,b,{middleware:[window.FloatingUIDOM.offset(10),window.FloatingUIDOM.inline(),window.FloatingUIDOM.shift()]}).then(({x:a,y:c})=>{Object.assign(b.style,{left:`${a}px`,top:`${c}px`})}),b.classList.add("visible")}),e.addEventListener("mouseout",()=>{b.classList.remove("visible")}))})})} |