diff --git a/conllusvg/Goseibai.html b/conllusvg/Goseibai.html new file mode 100644 index 0000000000000000000000000000000000000000..c0bc1c2e881805e92944581b00db1da2305932f6 --- /dev/null +++ b/conllusvg/Goseibai.html @@ -0,0 +1,304 @@ +<!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 Goseibai=new Object(); +Goseibai.url="/gitlab/api/v4/projects/Kanbun%2Fud-ja-kanbun/repository/"; +Goseibai.init=function(){ + var t=document.getElementById("top").cloneNode(true); + t.style.position="static"; + t.style.visibility="hidden"; + document.body.appendChild(t); + Goseibai.checkURL(); + Goseibai.svg=new Array(); + Goseibai.pre=new Array(); + Goseibai.timer=setTimeout("clearTimeout(Goseibai.timer);Goseibai.checkview()",200); + Goseibai.volchange(); +} +Goseibai.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; + } + } +} +Goseibai.checkview=function(){ + var t,r,b,i,x; + Goseibai.timer=setTimeout("clearTimeout(Goseibai.timer);Goseibai.checkview()",200); + if(Goseibai.curr==null) + return; + if(Goseibai.svg[Goseibai.curr]==null||Goseibai.pre[Goseibai.curr]==null){ + Goseibai.buildup(Goseibai.curr); + Goseibai.lastTop=null; + return; + } + if(Goseibai.svg[Goseibai.curr].style.position=="absolute"){ + Goseibai.svg[Goseibai.curr].style.position="static"; + Goseibai.svg[Goseibai.curr].style.visibility="visible"; + } + conllusvg.rewrite("pre"+Goseibai.curr); + r=Goseibai.svg[Goseibai.curr].getBoundingClientRect(); + t=r.top; + b=r.bottom; + r=document.getElementById("top").getBoundingClientRect().bottom; + x=Goseibai.curr; + if(t-r>20){ + while(t-r>0){ + i=Goseibai.svg[Goseibai.curr-1]; + if(i==null) + break; + if(i.style.position=="absolute") + break; + Goseibai.curr--; + if(Goseibai.curr==0) + break; + t=i.getBoundingClientRect().top; + } + } + else if(b<r){ + while(b<r){ + i=Goseibai.svg[Goseibai.curr+1]; + if(i==null) + break; + if(i.style.position=="absolute") + break; + Goseibai.curr++; + if(Goseibai.curr==Goseibai.currmax) + break; + b=i.getBoundingClientRect().bottom; + } + } + if(Goseibai.curr!=x){ + if(Goseibai.retrytimes>0){ + Goseibai.retrytimes--; + Goseibai.curr=parseInt(document.getElementById("count").value,10); + t=Goseibai.svg[Goseibai.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=Goseibai.curr; + } + else if(Goseibai.retrytimes>0) + Goseibai.retrytimes--; + Goseibai.lastTop=Goseibai.svg[Goseibai.curr].getBoundingClientRect().top; + for(i=Goseibai.curr+1;i<=Goseibai.currmax;i++){ + if(Goseibai.svg[i]==null||Goseibai.pre[i]==null){ + Goseibai.buildup(i); + break; + } + if(Goseibai.svg[i].style.position=="absolute"){ + Goseibai.svg[i].style.position="static"; + Goseibai.svg[i].style.visibility="visible"; + } + conllusvg.rewrite("pre"+i); + r=Goseibai.svg[i].getBoundingClientRect(); + if(r.top-window.innerHeight-1000>0) + break; + } + for(i=Goseibai.curr-1;i>=0;i--){ + if(Goseibai.svg[i]==null||Goseibai.pre[i]==null){ + Goseibai.buildup(i); + break; + } + if(Goseibai.svg[i].style.position=="absolute"){ + if(Goseibai.pre[i].textContent>""){ + Goseibai.svg[i].style.position="static"; + Goseibai.svg[i].style.visibility="visible"; + } + else + break; + } + conllusvg.rewrite("pre"+i); + r=Goseibai.svg[Goseibai.curr].getBoundingClientRect().top; + if(Math.abs(r-Goseibai.lastTop)>5){ + if(document.scrollingElement==null) + document.documentElement.scrollTop+=r-Goseibai.lastTop; + else + document.scrollingElement.scrollTop+=r-Goseibai.lastTop; + Goseibai.lastTop=r; + } + r=Goseibai.svg[i].getBoundingClientRect(); + if(parseInt(r.bottom,10)<-300) + break; + } +} +Goseibai.buildup=function(x){ + var t,i; + if(Goseibai.svg[x]==null){ + t=document.createElementNS("http://www.w3.org/2000/svg","svg"); + for(i=parseInt(x,10)+1;i<=Goseibai.currmax;i++){ + if(Goseibai.svg[i]!=null) + break; + } + t.style.position="absolute"; + t.style.visibility="hidden"; + if(i>Goseibai.currmax) + document.body.appendChild(t); + else + document.body.insertBefore(t,Goseibai.svg[i]); + Goseibai.svg[x]=t; + t.addEventListener("mousedown",Goseibai.onmousedown); + t.addEventListener("touchstart",Goseibai.onmousedown); + } + if(Goseibai.pre[x]==null){ + t=document.createElement("pre"); + t.style.display="none"; + t.setAttribute("id","pre"+x); + document.body.appendChild(t); + Goseibai.pre[x]=t; + if(conllusvg.main["pre"+x]==null) + conllusvg.view(Goseibai.svg[x],"pre"+x); + i=Goseibai.volpath+"/"+("000"+x).slice(-3)+".txt"; + conllusvg.loadRemote("pre"+x,Goseibai.url+"files/"+encodeURIComponent(i)+"/raw?ref=master"); + } +} +Goseibai.volchange=function(){ + var s,x; + Goseibai.clearSVG(); + for(s in Goseibai.pre){ + if(Goseibai.pre[s]!=null){ + document.body.removeChild(Goseibai.pre[s]); + } + Goseibai.pre[s]=null; + } + s=document.getElementById("vol"); + Goseibai.volpath=s.options[s.selectedIndex].value; + if(Goseibai.tail==null) + Goseibai.tail=new Array(); + if(Goseibai.tail[Goseibai.volpath]==null) + Goseibai.gettree(); + else + Goseibai.writeSVG(); +} +Goseibai.gettree=function(){ + var p; + if(Goseibai.request==null){ + Goseibai.request=new XMLHttpRequest(); + Goseibai.request.onload=Goseibai.ongettree; + } + if(Goseibai.tail[Goseibai.volpath]==null) + p=1; + else + p=Math.floor(parseInt(Goseibai.tail[Goseibai.volpath],10)/100)+2; + Goseibai.request.open("GET",Goseibai.url+"tree?per_page=100&path="+Goseibai.volpath+"&page="+p); + Goseibai.request.send(); +} +Goseibai.ongettree=function(e){ + var i,s; + if(Goseibai.request.status==200){ + s=Goseibai.request.responseText; + i=s.lastIndexOf('.txt"'); + if(i<0) + Goseibai.writeSVG(); + else{ + Goseibai.tail[Goseibai.volpath]=s.substring(i-3,i); + Goseibai.gettree(); + } + } +} +Goseibai.goto=function(){ + Goseibai.retrytimes=3; + Goseibai.writeSVG(); +} +Goseibai.writeSVG=function(){ + var c=document.getElementById("count"); + Goseibai.clearSVG(); + Goseibai.currmax=parseInt(Goseibai.tail[Goseibai.volpath],10); + Goseibai.curr=parseInt(c.value,10); + if(Goseibai.curr<0) + Goseibai.curr=0; + if(Goseibai.curr>Goseibai.currmax) + Goseibai.curr=Goseibai.currmax; + c.value=Goseibai.curr; + Goseibai.lastTop=null; +} +Goseibai.clearSVG=function(){ + var x; + Goseibai.curr=Goseibai.lastTop=null; + if(Goseibai.svg!=null){ + for(x in Goseibai.svg){ + if(Goseibai.svg[x]!=null){ + Goseibai.svg[x].style.position="absolute"; + Goseibai.svg[x].style.visibility="hidden"; + } + } + } + if(document.scrollingElement==null) + document.documentElement.scrollTop=0; + else + document.scrollingElement.scrollTop=0; +} +Goseibai.onmousedown=function(e){ + var x,y; + if(Goseibai.lastX==null){ + Goseibai.lastX=e.clientX; + Goseibai.lastY=e.clientY; + return; + } + x=e.clientX-Goseibai.lastX; + y=e.clientY-Goseibai.lastY; + if(x*x+y*y>9){ + Goseibai.lastX=e.clientX; + Goseibai.lastY=e.clientY; + return; + } + Goseibai.lastX=null; + x=e.currentTarget; + for(y in Goseibai.svg){ + if(Goseibai.svg[y]==x){ + x=Goseibai.volpath+"/"+("000"+y).slice(-3)+".txt"; + window.open("editor-kanbun.html#"+Goseibai.url+"files/"+encodeURIComponent(x)+"/raw?ref=master"); + break; + } + } +} +Goseibai.reload=function(){ + var i,r; + for(i=Goseibai.curr;i<=Goseibai.currmax;i++){ + if(Goseibai.svg[i]==null||Goseibai.pre[i]==null) + return; + r=Goseibai.svg[i].getBoundingClientRect(); + if(r.top>window.innerHeight||r.bottom<0) + return; + r=Goseibai.volpath+"/"+("000"+i).slice(-3)+".txt"; + conllusvg.loadRemote("pre"+i,Goseibai.url+"files/"+encodeURIComponent(r)+"/raw?ref=master"); + } +} +Goseibai.gitlab=function(){ + var r=Goseibai.volpath+"/"+("000"+Goseibai.curr).slice(-3)+".txt"; + window.open("/gitlab/Kanbun/ud-ja-kanbun/blob/master/"+r); +} +</script> +<body onload="Goseibai.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="Goseibai.volchange()"> +<option value="gunsho/0400/001" selected>001 蜿ッ菫ョ逅�ィ咏、セ蟆育・ュ逾莠�</option> +</select> +<input type="text" id="count" size=3 value=0 style="text-align:right" onchange="Goseibai.goto()" /> +<input type="button" value="GitLab" onclick="Goseibai.gitlab()" /> +<input type="button" value="Reload" onclick="Goseibai.reload()" /> +</div> +</body>