Loading conllusvg/Ryoiki.html 0 → 100644 +304 −0 Original line number Diff line number Diff line <!DOCTYPE html><head><meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>Universal Dependencies on 日本靈異記</title> <script src="conllusvgview.js"></script> <script src="conllusvgload.js"></script> <script> var Ryoiki=new Object(); Ryoiki.url="/gitlab/api/v4/projects/Kanbun%2Fud-ja-kanbun/repository/"; Ryoiki.init=function(){ var t=document.getElementById("top").cloneNode(true); t.style.position="static"; t.style.visibility="hidden"; document.body.appendChild(t); Ryoiki.checkURL(); Ryoiki.svg=new Array(); Ryoiki.pre=new Array(); Ryoiki.timer=setTimeout("clearTimeout(Ryoiki.timer);Ryoiki.checkview()",200); Ryoiki.volchange(); } Ryoiki.checkURL=function(){ var h=location.href; var i=h.indexOf("#"); var s; if(0>i) return; if(1>h.length-i) return; h=decodeURIComponent(h.slice(i+1)); i=h.lastIndexOf("/"); if(1<i){ document.getElementById("count").value=h.slice(i+1); h=h.substring(0,i); } s=document.getElementById("vol"); for(i=0;i<s.length;i++){ if(s.options[i].value.indexOf(h)>=0){ s.selectedIndex=i; return; } } } Ryoiki.checkview=function(){ var t,r,b,i,x; Ryoiki.timer=setTimeout("clearTimeout(Ryoiki.timer);Ryoiki.checkview()",200); if(Ryoiki.curr==null) return; if(Ryoiki.svg[Ryoiki.curr]==null||Ryoiki.pre[Ryoiki.curr]==null){ Ryoiki.buildup(Ryoiki.curr); Ryoiki.lastTop=null; return; } if(Ryoiki.svg[Ryoiki.curr].style.position=="absolute"){ Ryoiki.svg[Ryoiki.curr].style.position="static"; Ryoiki.svg[Ryoiki.curr].style.visibility="visible"; } conllusvg.rewrite("pre"+Ryoiki.curr); r=Ryoiki.svg[Ryoiki.curr].getBoundingClientRect(); t=r.top; b=r.bottom; r=document.getElementById("top").getBoundingClientRect().bottom; x=Ryoiki.curr; if(t-r>20){ while(t-r>0){ i=Ryoiki.svg[Ryoiki.curr-1]; if(i==null) break; if(i.style.position=="absolute") break; Ryoiki.curr--; if(Ryoiki.curr==0) break; t=i.getBoundingClientRect().top; } } else if(b<r){ while(b<r){ i=Ryoiki.svg[Ryoiki.curr+1]; if(i==null) break; if(i.style.position=="absolute") break; Ryoiki.curr++; if(Ryoiki.curr==Ryoiki.currmax) break; b=i.getBoundingClientRect().bottom; } } if(Ryoiki.curr!=x){ if(Ryoiki.retrytimes>0){ Ryoiki.retrytimes--; Ryoiki.curr=parseInt(document.getElementById("count").value,10); t=Ryoiki.svg[Ryoiki.curr].getBoundingClientRect().top; if(Math.abs(t-r)>5){ if(document.scrollingElement==null) document.documentElement.scrollTop+=t-r; else document.scrollingElement.scrollTop+=t-r; } } else document.getElementById("count").value=Ryoiki.curr; } else if(Ryoiki.retrytimes>0) Ryoiki.retrytimes--; Ryoiki.lastTop=Ryoiki.svg[Ryoiki.curr].getBoundingClientRect().top; for(i=Ryoiki.curr+1;i<=Ryoiki.currmax;i++){ if(Ryoiki.svg[i]==null||Ryoiki.pre[i]==null){ Ryoiki.buildup(i); break; } if(Ryoiki.svg[i].style.position=="absolute"){ Ryoiki.svg[i].style.position="static"; Ryoiki.svg[i].style.visibility="visible"; } conllusvg.rewrite("pre"+i); r=Ryoiki.svg[i].getBoundingClientRect(); if(r.top-window.innerHeight-1000>0) break; } for(i=Ryoiki.curr-1;i>=0;i--){ if(Ryoiki.svg[i]==null||Ryoiki.pre[i]==null){ Ryoiki.buildup(i); break; } if(Ryoiki.svg[i].style.position=="absolute"){ if(Ryoiki.pre[i].textContent>""){ Ryoiki.svg[i].style.position="static"; Ryoiki.svg[i].style.visibility="visible"; } else break; } conllusvg.rewrite("pre"+i); r=Ryoiki.svg[Ryoiki.curr].getBoundingClientRect().top; if(Math.abs(r-Ryoiki.lastTop)>5){ if(document.scrollingElement==null) document.documentElement.scrollTop+=r-Ryoiki.lastTop; else document.scrollingElement.scrollTop+=r-Ryoiki.lastTop; Ryoiki.lastTop=r; } r=Ryoiki.svg[i].getBoundingClientRect(); if(parseInt(r.bottom,10)<-300) break; } } Ryoiki.buildup=function(x){ var t,i; if(Ryoiki.svg[x]==null){ t=document.createElementNS("http://www.w3.org/2000/svg","svg"); for(i=parseInt(x,10)+1;i<=Ryoiki.currmax;i++){ if(Ryoiki.svg[i]!=null) break; } t.style.position="absolute"; t.style.visibility="hidden"; if(i>Ryoiki.currmax) document.body.appendChild(t); else document.body.insertBefore(t,Ryoiki.svg[i]); Ryoiki.svg[x]=t; t.addEventListener("mousedown",Ryoiki.onmousedown); t.addEventListener("touchstart",Ryoiki.onmousedown); } if(Ryoiki.pre[x]==null){ t=document.createElement("pre"); t.style.display="none"; t.setAttribute("id","pre"+x); document.body.appendChild(t); Ryoiki.pre[x]=t; if(conllusvg.main["pre"+x]==null) conllusvg.view(Ryoiki.svg[x],"pre"+x); i=Ryoiki.volpath+"/"+("000"+x).slice(-3)+".txt"; conllusvg.loadRemote("pre"+x,Ryoiki.url+"files/"+encodeURIComponent(i)+"/raw?ref=master"); } } Ryoiki.volchange=function(){ var s,x; Ryoiki.clearSVG(); for(s in Ryoiki.pre){ if(Ryoiki.pre[s]!=null){ document.body.removeChild(Ryoiki.pre[s]); } Ryoiki.pre[s]=null; } s=document.getElementById("vol"); Ryoiki.volpath=s.options[s.selectedIndex].value; if(Ryoiki.tail==null) Ryoiki.tail=new Array(); if(Ryoiki.tail[Ryoiki.volpath]==null) Ryoiki.gettree(); else Ryoiki.writeSVG(); } Ryoiki.gettree=function(){ var p; if(Ryoiki.request==null){ Ryoiki.request=new XMLHttpRequest(); Ryoiki.request.onload=Ryoiki.ongettree; } if(Ryoiki.tail[Ryoiki.volpath]==null) p=1; else p=Math.floor(parseInt(Ryoiki.tail[Ryoiki.volpath],10)/100)+2; Ryoiki.request.open("GET",Ryoiki.url+"tree?per_page=100&path="+Ryoiki.volpath+"&page="+p); Ryoiki.request.send(); } Ryoiki.ongettree=function(e){ var i,s; if(Ryoiki.request.status==200){ s=Ryoiki.request.responseText; i=s.lastIndexOf('.txt"'); if(i<0) Ryoiki.writeSVG(); else{ Ryoiki.tail[Ryoiki.volpath]=s.substring(i-3,i); Ryoiki.gettree(); } } } Ryoiki.goto=function(){ Ryoiki.retrytimes=3; Ryoiki.writeSVG(); } Ryoiki.writeSVG=function(){ var c=document.getElementById("count"); Ryoiki.clearSVG(); Ryoiki.currmax=parseInt(Ryoiki.tail[Ryoiki.volpath],10); Ryoiki.curr=parseInt(c.value,10); if(Ryoiki.curr<0) Ryoiki.curr=0; if(Ryoiki.curr>Ryoiki.currmax) Ryoiki.curr=Ryoiki.currmax; c.value=Ryoiki.curr; Ryoiki.lastTop=null; } Ryoiki.clearSVG=function(){ var x; Ryoiki.curr=Ryoiki.lastTop=null; if(Ryoiki.svg!=null){ for(x in Ryoiki.svg){ if(Ryoiki.svg[x]!=null){ Ryoiki.svg[x].style.position="absolute"; Ryoiki.svg[x].style.visibility="hidden"; } } } if(document.scrollingElement==null) document.documentElement.scrollTop=0; else document.scrollingElement.scrollTop=0; } Ryoiki.onmousedown=function(e){ var x,y; if(Ryoiki.lastX==null){ Ryoiki.lastX=e.clientX; Ryoiki.lastY=e.clientY; return; } x=e.clientX-Ryoiki.lastX; y=e.clientY-Ryoiki.lastY; if(x*x+y*y>9){ Ryoiki.lastX=e.clientX; Ryoiki.lastY=e.clientY; return; } Ryoiki.lastX=null; x=e.currentTarget; for(y in Ryoiki.svg){ if(Ryoiki.svg[y]==x){ x=Ryoiki.volpath+"/"+("000"+y).slice(-3)+".txt"; window.open("editor-kanbun.html#"+Ryoiki.url+"files/"+encodeURIComponent(x)+"/raw?ref=master"); break; } } } Ryoiki.reload=function(){ var i,r; for(i=Ryoiki.curr;i<=Ryoiki.currmax;i++){ if(Ryoiki.svg[i]==null||Ryoiki.pre[i]==null) return; r=Ryoiki.svg[i].getBoundingClientRect(); if(r.top>window.innerHeight||r.bottom<0) return; r=Ryoiki.volpath+"/"+("000"+i).slice(-3)+".txt"; conllusvg.loadRemote("pre"+i,Ryoiki.url+"files/"+encodeURIComponent(r)+"/raw?ref=master"); } } Ryoiki.gitlab=function(){ var r=Ryoiki.volpath+"/"+("000"+Ryoiki.curr).slice(-3)+".txt"; window.open("/gitlab/Kanbun/ud-ja-kanbun/blob/master/"+r); } </script> <body onload="Ryoiki.init()"> <div id="top" style="position:fixed; top:0px; left:0px; padding:10px; width:100%; background:white"> <font size="+3"><b>日本靈異記</b></font> <select id="vol" onchange="Ryoiki.volchange()"> <option value="gunsho/0407/001" selected>上01 捉雷緣</option> </select> <input type="text" id="count" size=3 value=0 style="text-align:right" onchange="Ryoiki.goto()" /> <input type="button" value="GitLab" onclick="Ryoiki.gitlab()" /> <input type="button" value="Reload" onclick="Ryoiki.reload()" /> </div> </body> Loading
conllusvg/Ryoiki.html 0 → 100644 +304 −0 Original line number Diff line number Diff line <!DOCTYPE html><head><meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>Universal Dependencies on 日本靈異記</title> <script src="conllusvgview.js"></script> <script src="conllusvgload.js"></script> <script> var Ryoiki=new Object(); Ryoiki.url="/gitlab/api/v4/projects/Kanbun%2Fud-ja-kanbun/repository/"; Ryoiki.init=function(){ var t=document.getElementById("top").cloneNode(true); t.style.position="static"; t.style.visibility="hidden"; document.body.appendChild(t); Ryoiki.checkURL(); Ryoiki.svg=new Array(); Ryoiki.pre=new Array(); Ryoiki.timer=setTimeout("clearTimeout(Ryoiki.timer);Ryoiki.checkview()",200); Ryoiki.volchange(); } Ryoiki.checkURL=function(){ var h=location.href; var i=h.indexOf("#"); var s; if(0>i) return; if(1>h.length-i) return; h=decodeURIComponent(h.slice(i+1)); i=h.lastIndexOf("/"); if(1<i){ document.getElementById("count").value=h.slice(i+1); h=h.substring(0,i); } s=document.getElementById("vol"); for(i=0;i<s.length;i++){ if(s.options[i].value.indexOf(h)>=0){ s.selectedIndex=i; return; } } } Ryoiki.checkview=function(){ var t,r,b,i,x; Ryoiki.timer=setTimeout("clearTimeout(Ryoiki.timer);Ryoiki.checkview()",200); if(Ryoiki.curr==null) return; if(Ryoiki.svg[Ryoiki.curr]==null||Ryoiki.pre[Ryoiki.curr]==null){ Ryoiki.buildup(Ryoiki.curr); Ryoiki.lastTop=null; return; } if(Ryoiki.svg[Ryoiki.curr].style.position=="absolute"){ Ryoiki.svg[Ryoiki.curr].style.position="static"; Ryoiki.svg[Ryoiki.curr].style.visibility="visible"; } conllusvg.rewrite("pre"+Ryoiki.curr); r=Ryoiki.svg[Ryoiki.curr].getBoundingClientRect(); t=r.top; b=r.bottom; r=document.getElementById("top").getBoundingClientRect().bottom; x=Ryoiki.curr; if(t-r>20){ while(t-r>0){ i=Ryoiki.svg[Ryoiki.curr-1]; if(i==null) break; if(i.style.position=="absolute") break; Ryoiki.curr--; if(Ryoiki.curr==0) break; t=i.getBoundingClientRect().top; } } else if(b<r){ while(b<r){ i=Ryoiki.svg[Ryoiki.curr+1]; if(i==null) break; if(i.style.position=="absolute") break; Ryoiki.curr++; if(Ryoiki.curr==Ryoiki.currmax) break; b=i.getBoundingClientRect().bottom; } } if(Ryoiki.curr!=x){ if(Ryoiki.retrytimes>0){ Ryoiki.retrytimes--; Ryoiki.curr=parseInt(document.getElementById("count").value,10); t=Ryoiki.svg[Ryoiki.curr].getBoundingClientRect().top; if(Math.abs(t-r)>5){ if(document.scrollingElement==null) document.documentElement.scrollTop+=t-r; else document.scrollingElement.scrollTop+=t-r; } } else document.getElementById("count").value=Ryoiki.curr; } else if(Ryoiki.retrytimes>0) Ryoiki.retrytimes--; Ryoiki.lastTop=Ryoiki.svg[Ryoiki.curr].getBoundingClientRect().top; for(i=Ryoiki.curr+1;i<=Ryoiki.currmax;i++){ if(Ryoiki.svg[i]==null||Ryoiki.pre[i]==null){ Ryoiki.buildup(i); break; } if(Ryoiki.svg[i].style.position=="absolute"){ Ryoiki.svg[i].style.position="static"; Ryoiki.svg[i].style.visibility="visible"; } conllusvg.rewrite("pre"+i); r=Ryoiki.svg[i].getBoundingClientRect(); if(r.top-window.innerHeight-1000>0) break; } for(i=Ryoiki.curr-1;i>=0;i--){ if(Ryoiki.svg[i]==null||Ryoiki.pre[i]==null){ Ryoiki.buildup(i); break; } if(Ryoiki.svg[i].style.position=="absolute"){ if(Ryoiki.pre[i].textContent>""){ Ryoiki.svg[i].style.position="static"; Ryoiki.svg[i].style.visibility="visible"; } else break; } conllusvg.rewrite("pre"+i); r=Ryoiki.svg[Ryoiki.curr].getBoundingClientRect().top; if(Math.abs(r-Ryoiki.lastTop)>5){ if(document.scrollingElement==null) document.documentElement.scrollTop+=r-Ryoiki.lastTop; else document.scrollingElement.scrollTop+=r-Ryoiki.lastTop; Ryoiki.lastTop=r; } r=Ryoiki.svg[i].getBoundingClientRect(); if(parseInt(r.bottom,10)<-300) break; } } Ryoiki.buildup=function(x){ var t,i; if(Ryoiki.svg[x]==null){ t=document.createElementNS("http://www.w3.org/2000/svg","svg"); for(i=parseInt(x,10)+1;i<=Ryoiki.currmax;i++){ if(Ryoiki.svg[i]!=null) break; } t.style.position="absolute"; t.style.visibility="hidden"; if(i>Ryoiki.currmax) document.body.appendChild(t); else document.body.insertBefore(t,Ryoiki.svg[i]); Ryoiki.svg[x]=t; t.addEventListener("mousedown",Ryoiki.onmousedown); t.addEventListener("touchstart",Ryoiki.onmousedown); } if(Ryoiki.pre[x]==null){ t=document.createElement("pre"); t.style.display="none"; t.setAttribute("id","pre"+x); document.body.appendChild(t); Ryoiki.pre[x]=t; if(conllusvg.main["pre"+x]==null) conllusvg.view(Ryoiki.svg[x],"pre"+x); i=Ryoiki.volpath+"/"+("000"+x).slice(-3)+".txt"; conllusvg.loadRemote("pre"+x,Ryoiki.url+"files/"+encodeURIComponent(i)+"/raw?ref=master"); } } Ryoiki.volchange=function(){ var s,x; Ryoiki.clearSVG(); for(s in Ryoiki.pre){ if(Ryoiki.pre[s]!=null){ document.body.removeChild(Ryoiki.pre[s]); } Ryoiki.pre[s]=null; } s=document.getElementById("vol"); Ryoiki.volpath=s.options[s.selectedIndex].value; if(Ryoiki.tail==null) Ryoiki.tail=new Array(); if(Ryoiki.tail[Ryoiki.volpath]==null) Ryoiki.gettree(); else Ryoiki.writeSVG(); } Ryoiki.gettree=function(){ var p; if(Ryoiki.request==null){ Ryoiki.request=new XMLHttpRequest(); Ryoiki.request.onload=Ryoiki.ongettree; } if(Ryoiki.tail[Ryoiki.volpath]==null) p=1; else p=Math.floor(parseInt(Ryoiki.tail[Ryoiki.volpath],10)/100)+2; Ryoiki.request.open("GET",Ryoiki.url+"tree?per_page=100&path="+Ryoiki.volpath+"&page="+p); Ryoiki.request.send(); } Ryoiki.ongettree=function(e){ var i,s; if(Ryoiki.request.status==200){ s=Ryoiki.request.responseText; i=s.lastIndexOf('.txt"'); if(i<0) Ryoiki.writeSVG(); else{ Ryoiki.tail[Ryoiki.volpath]=s.substring(i-3,i); Ryoiki.gettree(); } } } Ryoiki.goto=function(){ Ryoiki.retrytimes=3; Ryoiki.writeSVG(); } Ryoiki.writeSVG=function(){ var c=document.getElementById("count"); Ryoiki.clearSVG(); Ryoiki.currmax=parseInt(Ryoiki.tail[Ryoiki.volpath],10); Ryoiki.curr=parseInt(c.value,10); if(Ryoiki.curr<0) Ryoiki.curr=0; if(Ryoiki.curr>Ryoiki.currmax) Ryoiki.curr=Ryoiki.currmax; c.value=Ryoiki.curr; Ryoiki.lastTop=null; } Ryoiki.clearSVG=function(){ var x; Ryoiki.curr=Ryoiki.lastTop=null; if(Ryoiki.svg!=null){ for(x in Ryoiki.svg){ if(Ryoiki.svg[x]!=null){ Ryoiki.svg[x].style.position="absolute"; Ryoiki.svg[x].style.visibility="hidden"; } } } if(document.scrollingElement==null) document.documentElement.scrollTop=0; else document.scrollingElement.scrollTop=0; } Ryoiki.onmousedown=function(e){ var x,y; if(Ryoiki.lastX==null){ Ryoiki.lastX=e.clientX; Ryoiki.lastY=e.clientY; return; } x=e.clientX-Ryoiki.lastX; y=e.clientY-Ryoiki.lastY; if(x*x+y*y>9){ Ryoiki.lastX=e.clientX; Ryoiki.lastY=e.clientY; return; } Ryoiki.lastX=null; x=e.currentTarget; for(y in Ryoiki.svg){ if(Ryoiki.svg[y]==x){ x=Ryoiki.volpath+"/"+("000"+y).slice(-3)+".txt"; window.open("editor-kanbun.html#"+Ryoiki.url+"files/"+encodeURIComponent(x)+"/raw?ref=master"); break; } } } Ryoiki.reload=function(){ var i,r; for(i=Ryoiki.curr;i<=Ryoiki.currmax;i++){ if(Ryoiki.svg[i]==null||Ryoiki.pre[i]==null) return; r=Ryoiki.svg[i].getBoundingClientRect(); if(r.top>window.innerHeight||r.bottom<0) return; r=Ryoiki.volpath+"/"+("000"+i).slice(-3)+".txt"; conllusvg.loadRemote("pre"+i,Ryoiki.url+"files/"+encodeURIComponent(r)+"/raw?ref=master"); } } Ryoiki.gitlab=function(){ var r=Ryoiki.volpath+"/"+("000"+Ryoiki.curr).slice(-3)+".txt"; window.open("/gitlab/Kanbun/ud-ja-kanbun/blob/master/"+r); } </script> <body onload="Ryoiki.init()"> <div id="top" style="position:fixed; top:0px; left:0px; padding:10px; width:100%; background:white"> <font size="+3"><b>日本靈異記</b></font> <select id="vol" onchange="Ryoiki.volchange()"> <option value="gunsho/0407/001" selected>上01 捉雷緣</option> </select> <input type="text" id="count" size=3 value=0 style="text-align:right" onchange="Ryoiki.goto()" /> <input type="button" value="GitLab" onclick="Ryoiki.gitlab()" /> <input type="button" value="Reload" onclick="Ryoiki.reload()" /> </div> </body>