Skip to content
Snippets Groups Projects
Commit c737209c authored by Koichi Yasuoka's avatar Koichi Yasuoka
Browse files

center-exam.html added

parent cd7f9ff3
No related branches found
No related tags found
No related merge requests found
<!DOCTYPE html><head><meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Universal Dependencies on 漢文 of 大学入試センター試験</title>
<script src="conllusvgview.js"></script>
<script src="conllusvgload.js"></script>
<script>
var CenterExam=new Object();
CenterExam.url="/gitlab/api/v4/projects/Kanbun%2Fud-kanbun/repository/";
CenterExam.init=function(){
var t=document.getElementById("top").cloneNode(true);
t.style.position="static";
t.style.visibility="hidden";
document.body.appendChild(t);
CenterExam.svg=new Array();
CenterExam.pre=new Array();
CenterExam.timer=setTimeout("clearTimeout(CenterExam.timer);CenterExam.checkview()",200);
CenterExam.volchange();
}
CenterExam.checkview=function(){
var t,r,b,i,x;
CenterExam.timer=setTimeout("clearTimeout(CenterExam.timer);CenterExam.checkview()",200);
if(CenterExam.curr==null)
return;
if(CenterExam.svg[CenterExam.curr]==null||CenterExam.pre[CenterExam.curr]==null){
CenterExam.buildup(CenterExam.curr);
CenterExam.lastTop=null;
return;
}
if(CenterExam.svg[CenterExam.curr].style.position=="absolute"){
CenterExam.svg[CenterExam.curr].style.position="static";
CenterExam.svg[CenterExam.curr].style.visibility="visible";
}
conllusvg.rewrite("pre"+CenterExam.curr);
r=CenterExam.svg[CenterExam.curr].getBoundingClientRect();
t=r.top;
b=r.bottom;
r=document.getElementById("top").getBoundingClientRect().bottom;
x=CenterExam.curr;
if(t-r>20){
while(t-r>0){
i=CenterExam.svg[CenterExam.curr-1];
if(i==null)
break;
if(i.style.position=="absolute")
break;
CenterExam.curr--;
if(CenterExam.curr==1)
break;
t=i.getBoundingClientRect().top;
}
}
else if(b<r){
while(b<r){
i=CenterExam.svg[CenterExam.curr+1];
if(i==null)
break;
if(i.style.position=="absolute")
break;
CenterExam.curr++;
if(CenterExam.curr==CenterExam.currmax)
break;
b=i.getBoundingClientRect().bottom;
}
}
CenterExam.lastTop=CenterExam.svg[CenterExam.curr].getBoundingClientRect().top;
if(CenterExam.curr!=x)
document.getElementById("count").value=CenterExam.curr;
for(i=CenterExam.curr+1;i<=CenterExam.currmax;i++){
if(CenterExam.svg[i]==null||CenterExam.pre[i]==null){
CenterExam.buildup(i);
break;
}
if(CenterExam.svg[i].style.position=="absolute"){
CenterExam.svg[i].style.position="static";
CenterExam.svg[i].style.visibility="visible";
}
conllusvg.rewrite("pre"+i);
r=CenterExam.svg[i].getBoundingClientRect();
if(r.top-window.innerHeight-1000>0)
break;
}
for(i=CenterExam.curr-1;i>0;i--){
if(CenterExam.svg[i]==null||CenterExam.pre[i]==null){
CenterExam.buildup(i);
break;
}
if(CenterExam.svg[i].style.position=="absolute"){
if(CenterExam.pre[i].textContent>""){
CenterExam.svg[i].style.position="static";
CenterExam.svg[i].style.visibility="visible";
}
else
break;
}
conllusvg.rewrite("pre"+i);
r=CenterExam.svg[CenterExam.curr].getBoundingClientRect().top;
if(Math.abs(r-CenterExam.lastTop)>5){
if(document.scrollingElement==null)
document.documentElement.scrollTop+=r-CenterExam.lastTop;
else
document.scrollingElement.scrollTop+=r-CenterExam.lastTop;
CenterExam.lastTop=r;
}
r=CenterExam.svg[i].getBoundingClientRect();
if(parseInt(r.bottom,10)<-300)
break;
}
}
CenterExam.buildup=function(x){
var t,i;
if(CenterExam.svg[x]==null){
t=document.createElementNS("http://www.w3.org/2000/svg","svg");
for(i=parseInt(x,10)+1;i<=CenterExam.currmax;i++){
if(CenterExam.svg[i]!=null)
break;
}
t.style.position="absolute";
t.style.visibility="hidden";
if(i>CenterExam.currmax)
document.body.appendChild(t);
else
document.body.insertBefore(t,CenterExam.svg[i]);
CenterExam.svg[x]=t;
t.addEventListener("mousedown",CenterExam.onmousedown);
t.addEventListener("touchstart",CenterExam.onmousedown);
}
if(CenterExam.pre[x]==null){
t=document.createElement("pre");
t.style.display="none";
t.setAttribute("id","pre"+x);
document.body.appendChild(t);
CenterExam.pre[x]=t;
if(conllusvg.main["pre"+x]==null)
conllusvg.view(CenterExam.svg[x],"pre"+x);
i=CenterExam.volpath+"/"+("000"+x).slice(-3)+".txt";
conllusvg.loadRemote("pre"+x,CenterExam.url+"files/"+encodeURIComponent(i)+"/raw?ref=master");
}
}
CenterExam.volchange=function(){
var s,x;
CenterExam.clearSVG();
for(s in CenterExam.pre){
if(CenterExam.pre[s]!=null){
document.body.removeChild(CenterExam.pre[s]);
}
CenterExam.pre[s]=null;
}
s=document.getElementById("vol");
CenterExam.volpath=s.options[s.selectedIndex].value;
if(CenterExam.tail==null)
CenterExam.tail=new Array();
if(CenterExam.tail[CenterExam.volpath]==null)
CenterExam.gettree();
else
CenterExam.writeSVG();
}
CenterExam.gettree=function(){
var p;
if(CenterExam.request==null){
CenterExam.request=new XMLHttpRequest();
CenterExam.request.onload=CenterExam.ongettree;
}
if(CenterExam.tail[CenterExam.volpath]==null)
p=1;
else
p=Math.floor(parseInt(CenterExam.tail[CenterExam.volpath],10)/100)+2;
CenterExam.request.open("GET",CenterExam.url+"tree?per_page=100&path="+CenterExam.volpath+"&page="+p);
CenterExam.request.send();
}
CenterExam.ongettree=function(e){
var i,s;
if(CenterExam.request.status==200){
s=CenterExam.request.responseText;
i=s.lastIndexOf('.txt"');
if(i<0)
CenterExam.writeSVG();
else{
CenterExam.tail[CenterExam.volpath]=s.substring(i-3,i);
CenterExam.gettree();
}
}
}
CenterExam.writeSVG=function(){
var c=document.getElementById("count");
CenterExam.clearSVG();
CenterExam.currmax=parseInt(CenterExam.tail[CenterExam.volpath],10);
CenterExam.curr=parseInt(c.value,10);
if(CenterExam.curr<1)
CenterExam.curr=1;
if(CenterExam.curr>CenterExam.currmax)
CenterExam.curr=CenterExam.currmax;
c.value=CenterExam.curr;
CenterExam.lastTop=null;
}
CenterExam.clearSVG=function(){
var x;
CenterExam.curr=CenterExam.lastTop=null;
if(CenterExam.svg!=null){
for(x in CenterExam.svg){
if(CenterExam.svg[x]!=null){
CenterExam.svg[x].style.position="absolute";
CenterExam.svg[x].style.visibility="hidden";
}
}
}
if(document.scrollingElement==null)
document.documentElement.scrollTop=0;
else
document.scrollingElement.scrollTop=0;
}
CenterExam.onmousedown=function(e){
var x,y;
if(CenterExam.lastX==null){
CenterExam.lastX=e.clientX;
CenterExam.lastY=e.clientY;
return;
}
x=e.clientX-CenterExam.lastX;
y=e.clientY-CenterExam.lastY;
if(x*x+y*y>9){
CenterExam.lastX=e.clientX;
CenterExam.lastY=e.clientY;
return;
}
CenterExam.lastX=null;
x=e.currentTarget;
for(y in CenterExam.svg){
if(CenterExam.svg[y]==x){
x=CenterExam.volpath+"/"+("000"+y).slice(-3)+".txt";
window.open("editor-kanbun.html#"+CenterExam.url+"files/"+encodeURIComponent(x)+"/raw?ref=master");
break;
}
}
}
CenterExam.reload=function(){
var i,r;
for(i=CenterExam.curr;i<=CenterExam.currmax;i++){
if(CenterExam.svg[i]==null||CenterExam.pre[i]==null)
return;
r=CenterExam.svg[i].getBoundingClientRect();
if(r.top>window.innerHeight||r.bottom<0)
return;
r=CenterExam.volpath+"/"+("000"+i).slice(-3)+".txt";
conllusvg.loadRemote("pre"+i,CenterExam.url+"files/"+encodeURIComponent(r)+"/raw?ref=master");
}
}
CenterExam.gitlab=function(){
var r=CenterExam.volpath+"/"+("000"+CenterExam.curr).slice(-3)+".txt";
window.open("/gitlab/Kanbun/ud-kanbun/blob/master/"+r);
}
</script>
<body onload="CenterExam.init()">
<div id="top" style="position:fixed; top:0px; left:0px; padding:10px; width:100%; background:white">
<font size="+3"><b>大学入試センター試験『国語』漢文</b></font><br>
<select id="vol" onchange="CenterExam.volchange()">
<option value="center-exam/2019">2019年</option>
<option value="center-exam/2018">2018年</option>
<option value="center-exam/2017">2017年</option>
<option value="center-exam/2016">2016年</option>
<option value="center-exam/2015">2015年</option>
</select>
<input type="text" id="count" size=3 value=0 style="text-align:right" onchange="CenterExam.writeSVG()" />
<input type="button" value="GitLab" onclick="CenterExam.gitlab()" />
<input type="button" value="Reload" onclick="CenterExam.reload()" />
</div>
</body>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment