aboutsummaryrefslogtreecommitdiffhomepage
path: root/static.files/scrape-examples-ef1e698c1d417c0c.js
diff options
context:
space:
mode:
authorjohannst <johannst@users.noreply.github.com>2023-11-15 21:40:27 +0000
committerjohannst <johannst@users.noreply.github.com>2023-11-15 21:40:27 +0000
commit091d408a87d0f73f1c4e0166849ca9a566f005e0 (patch)
tree894908b3a5fd80c94bc33e832d4168d73b4f2ba1 /static.files/scrape-examples-ef1e698c1d417c0c.js
parentc44661b4d904f8be227faef8f84ddb22934a01e8 (diff)
downloadmini-kvm-rs-gh-pages.tar.gz
mini-kvm-rs-gh-pages.zip
deploy: f52d556e0e1bf2350b3b42cff198550a267ceb0bgh-pages
Diffstat (limited to 'static.files/scrape-examples-ef1e698c1d417c0c.js')
-rw-r--r--static.files/scrape-examples-ef1e698c1d417c0c.js1
1 files changed, 1 insertions, 0 deletions
diff --git a/static.files/scrape-examples-ef1e698c1d417c0c.js b/static.files/scrape-examples-ef1e698c1d417c0c.js
new file mode 100644
index 0000000..ba830e3
--- /dev/null
+++ b/static.files/scrape-examples-ef1e698c1d417c0c.js
@@ -0,0 +1 @@
+"use strict";(function(){const DEFAULT_MAX_LINES=5;const HIDDEN_MAX_LINES=10;function scrollToLoc(elt,loc,isHidden){const lines=elt.querySelector(".src-line-numbers");let scrollOffset;const maxLines=isHidden?HIDDEN_MAX_LINES:DEFAULT_MAX_LINES;if(loc[1]-loc[0]>maxLines){const line=Math.max(0,loc[0]-1);scrollOffset=lines.children[line].offsetTop}else{const wrapper=elt.querySelector(".code-wrapper");const halfHeight=wrapper.offsetHeight/2;const offsetTop=lines.children[loc[0]].offsetTop;const lastLine=lines.children[loc[1]];const offsetBot=lastLine.offsetTop+lastLine.offsetHeight;const offsetMid=(offsetTop+offsetBot)/2;scrollOffset=offsetMid-halfHeight}lines.scrollTo(0,scrollOffset);elt.querySelector(".rust").scrollTo(0,scrollOffset)}function updateScrapedExample(example,isHidden){const locs=JSON.parse(example.attributes.getNamedItem("data-locs").textContent);let locIndex=0;const highlights=Array.prototype.slice.call(example.querySelectorAll(".highlight"));const link=example.querySelector(".scraped-example-title a");if(locs.length>1){const onChangeLoc=changeIndex=>{removeClass(highlights[locIndex],"focus");changeIndex();scrollToLoc(example,locs[locIndex][0],isHidden);addClass(highlights[locIndex],"focus");const url=locs[locIndex][1];const title=locs[locIndex][2];link.href=url;link.innerHTML=title};example.querySelector(".prev").addEventListener("click",()=>{onChangeLoc(()=>{locIndex=(locIndex-1+locs.length)%locs.length})});example.querySelector(".next").addEventListener("click",()=>{onChangeLoc(()=>{locIndex=(locIndex+1)%locs.length})})}const expandButton=example.querySelector(".expand");if(expandButton){expandButton.addEventListener("click",()=>{if(hasClass(example,"expanded")){removeClass(example,"expanded");scrollToLoc(example,locs[0][0],isHidden)}else{addClass(example,"expanded")}})}scrollToLoc(example,locs[0][0],isHidden)}const firstExamples=document.querySelectorAll(".scraped-example-list > .scraped-example");onEachLazy(firstExamples,el=>updateScrapedExample(el,false));onEachLazy(document.querySelectorAll(".more-examples-toggle"),toggle=>{onEachLazy(toggle.querySelectorAll(".toggle-line, .hide-more"),button=>{button.addEventListener("click",()=>{toggle.open=false})});const moreExamples=toggle.querySelectorAll(".scraped-example");toggle.querySelector("summary").addEventListener("click",()=>{setTimeout(()=>{onEachLazy(moreExamples,el=>updateScrapedExample(el,true))})},{once:true})})})() \ No newline at end of file