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