PageSourceSearch

https://nakashimas.github.io/other/js/line.min.js

js nakashimas.github.io collected 2026-10-03 09:39:24 UTC 6,920 bytes, 43 lines download raw bytes

1let isNavigationCollapsed=true;let currentPageNumber=1;const sleep=(second)=>new Promise(resolve=>setTimeout(resolve,second*1000))
2function tan(w,h){return h/w;}
3function applyPage(page,lambda){for(var i of page.getElementsByClassName("line")){lambda(i);}
4for(var i of getHeader().getElementsByClassName("line")){lambda(i);}
5for(var i of getFooter().getElementsByClassName("line")){lambda(i);}}
6function popClassLike(target,regex){const targetClassList=target.className;const myRegExp=new RegExp(regex,'g');const myMatched=targetClassList.match(myRegExp)||[];for(let n=0;n<myMatched.length;n++){target.classList.remove(myMatched[n]);}
7return myMatched;}
8function popLength(target){return popClassLike(target,/\blength-\S+/);}
9function popLengthOverwrite(target){return popClassLike(target,/\blength-overwrite-\S+/);}
10function popLengthAll(){applyPage(getCurrentPage(),(i)=>{popLength(i)});}
11function popLengthOverwriteAll(){applyPage(getCurrentPage(),(i)=>{popLengthOverwrite(i)});}
12function setPage(pageNumber){document.getElementById("main").dataset.pageNumber=pageNumber;}
13function setLength(elm,lengthNum){popLength(elm);elm.classList.add("length-"+lengthNum);}
14function setLengthOverwrite(elm,lengthNum){popLengthOverwrite(elm);elm.classList.add("length-overwrite-"+lengthNum);}
15function setLengthAll(lengthNum){applyPage(getCurrentPage(),(i)=>{setLength(i,lengthNum)});}
16function setLengthOverwriteAll(lengthNum){applyPage(getCurrentPage(),(i)=>{setLengthOverwrite(i,lengthNum)});}
17function setDisplay(page,isDisplay){const lines=page.getElementsByClassName("line");const dpy=isDisplay?"visible":"hidden";for(let i=0;i<lines.length;i++){lines[i].style.visibility=dpy;}}
18function getPage(pageNumber){return document.getElementById("page-"+pageNumber);}
19function getCurrentPage(){return getPage(document.getElementById("main").dataset.pageNumber);}
20function getHeader(){return document.getElementById("header");}
21function getFooter(){return document.getElementById("footer");}
22function getMain(){return document.getElementById("main");}
23function toggleHiddenAll(){applyPage(getCurrentPage(),(i)=>{i.classList.toggle("line-hidden")});}
24function toggleShow(elm){if(!isNavigationCollapsed){onNavigationButton();}
25toggleHiddenAll();popLengthOverwriteAll();elm.classList.toggle("line-hidden");elm.classList.toggle("line-show");if(getMain().getAttribute("is-open")=="true"){getMain().setAttribute("is-open","false");}else{getMain().setAttribute("is-open","true");}}
26function removeHiddenAll(){applyPage(getCurrentPage(),(i)=>{i.classList.remove("line-hidden")});}
27function removeShowAll(){applyPage(getCurrentPage(),(i)=>{i.classList.remove("line-show")});}
28function resetNavigationSize(){let navH=document.getElementById("navigation-button").getBoundingClientRect().height;let navW=document.getElementById("navigation-button").getBoundingClientRect().width;let navTan=navH/navW;document.documentElement.style.setProperty("--navigation-deg",(Math.atan(navTan)*180/Math.PI)+"deg");document.documentElement.style.setProperty("--navigation-width",Math.sqrt((navH*navH)+(navW*navW))+"px");}
29function resetNavigationLength(navigationLengthData){setLength(document.getElementById("line-top-2"),navigationLengthData.charAt(0));setLength(document.getElementById("line-top-3"),navigationLengthData.charAt(1));setLength(document.getElementById("line-top-4"),navigationLengthData.charAt(2));setLength(document.getElementById("line-bottom-1"),navigationLengthData.charAt(3));setLength(document.getElementById("line-bottom-2"),navigationLengthData.charAt(4));setLength(document.getElementById("line-bottom-3"),navigationLengthData.charAt(5));}
30function resetContentLength(contentLengthData){const lines=getCurrentPage().children;for(let i=0;i<lines.length;i++){setLength(lines[i],contentLengthData.charAt(i))}}
31async function resetPage(){let elt=getCurrentPage();if(elt==null){setPage("1");elt=getCurrentPage();}
32setDisplay(elt,true);resetNavigationLength(elt.dataset.navigationLength);resetContentLength(elt.dataset.contentLength);await sleep(0.2);toggleHiddenAll();}
33function closeNavigation(){popLengthOverwriteAll();document.getElementById("navigation-button").classList.add("navigation-button-collapsed");isNavigationCollapsed=true;getMain().setAttribute("is-open","false");}
34function openNavigation(){setLengthOverwriteAll("1");for(var i of document.getElementById("navigation-items").getElementsByClassName("line")){setLengthOverwrite(i,"6");}
35document.getElementById("navigation-button").classList.remove("navigation-button-collapsed");isNavigationCollapsed=false;getMain().setAttribute("is-open","true");}
36function onWindowResize(){const bottomElements=document.getElementById("footer").getElementsByClassName("line-bottom");const bottomElement=bottomElements[bottomElements.length-1];const bottomRect=bottomElement.getBoundingClientRect();document.documentElement.style.setProperty("--vh",bottomRect.bottom+"px");resetNavigationSize();}
37function onNavigationButton(){resetNavigationSize();if(isNavigationCollapsed){openNavigation();}else{closeNavigation();}}
38async function togglePortfolio(){await changePage("99");await sleep(0.4);toggleHiddenAll();}
39async function changePage(pageNumber){const elt=getCurrentPage();closeNavigation();toggleHiddenAll();await sleep(0.2);setDisplay(elt,false);await sleep(0.2);setPage(pageNumber);await resetPage();}
40async function nextPage(){const pageNumber=parseInt(document.getElementById("main").dataset.pageNumber);if(pageNumber+1>=100){await changePage("1");}else{await changePage(pageNumber+1);}}
41async function prevPage(){const pageNumber=parseInt(document.getElementById("main").dataset.pageNumber);if(pageNumber-1<=0){await changePage("1");}else{await changePage(pageNumber-1);}}
42window.addEventListener('load',async function(){const searchParams=new URLSearchParams(window.location.search);await resetPage();onWindowResize();if(!localStorage.getItem('privacy_concent')){localStorage.setItem('privacy_concent','true');await changePage(98);}else if(searchParams.has('page')){const page=searchParams.get('page');
42if(page=='99'){await changePage(page);}else if(page=='98'){await changePage(page);}else if(page=='0'){if(searchParams.has('content')){const num=searchParams.get('content');switch(num){case '0':toggleShow(document.getElementById('line-top-2'));break;case '1':toggleShow(document.getElementById('line-top-3'));break;case '2':toggleShow(document.getElementById('line-top-4'));break;case '3':toggleShow(document.getElementById('line-bottom-1'));break;case '4':toggleShow(document.getElementById('line-bottom-2'));break;case '5':toggleShow(document.getElementById('line-bottom-3'));break;}}}else{await changePage(page);if(searchParams.has('content')){const lines=getCurrentPage().children;const num=parseInt(searchParams.get('content'))-1;if(lines.length>num){await toggleShow(lines[num]);}}}}})
43window.addEventListener('resize',function(){closeNavigation();onWindowResize();})

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.