Commit ab673159 authored by Koichi Yasuoka's avatar Koichi Yasuoka
Browse files

狄島夜話記

parent 96455087
Loading
Loading
Loading
Loading
+257 −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コーパス</title>
<script src="conllusvgview.js"></script>
<script src="conllusvgload.js"></script>
<script>
Ezogashima=new Object();
Ezogashima.apiURL="/gitlab/api/v4/projects/Kanbun%2Fud-ja-kanbun/repository/";
Ezogashima.volpath="sendai/07H/ezo";
Ezogashima.init=function(){
  var t=document.getElementById("top").cloneNode(true);
  t.style.position="static";
  t.style.visibility="hidden";
  document.body.appendChild(t);
  Ezogashima.svg=new Array();
  Ezogashima.pre=new Array();
  Ezogashima.timer=setTimeout("clearTimeout(Ezogashima.timer);Ezogashima.checkview()",200);
  Ezogashima.volchange();
}
Ezogashima.checkview=function(){
  var t,r,b,i;
  Ezogashima.timer=setTimeout("clearTimeout(Ezogashima.timer);Ezogashima.checkview()",200);
  if(Ezogashima.curr==null)
    return;
  if(Ezogashima.svg[Ezogashima.curr]==null||Ezogashima.pre[Ezogashima.curr]==null){
    Ezogashima.buildup(Ezogashima.curr);
    return;
  }
  if(Ezogashima.svg[Ezogashima.curr].style.position=="absolute"){
    if(Ezogashima.pre[Ezogashima.curr].textContent>""){
      Ezogashima.svg[Ezogashima.curr].style.position="static";
      Ezogashima.svg[Ezogashima.curr].style.visibility="visible";
    }
  }
  Ezogashima.lemmatranslit(Ezogashima.curr);
  conllusvg.rewrite("pre"+Ezogashima.curr);
  r=Ezogashima.svg[Ezogashima.curr].getBoundingClientRect();
  t=r.top;
  b=r.bottom;
  r=document.getElementById("top").getBoundingClientRect().bottom;
  if(t-r>20){
    while(t-r>0){
      i=Ezogashima.svg[Ezogashima.curr-1];
      if(i==null)
        break;
      if(i.style.position=="absolute")
        break;
      Ezogashima.curr--;
      if(Ezogashima.curr==0)
        break;
      t=i.getBoundingClientRect().top;
    }
  }
  else if(b<r){
    while(b<r){
      i=Ezogashima.svg[Ezogashima.curr+1];
      if(i==null)
        break;
      if(i.style.position=="absolute")
        break;
      Ezogashima.curr++;
      if(Ezogashima.curr==Ezogashima.currmax)
        break;
      b=i.getBoundingClientRect().bottom;
    }
  }
  Ezogashima.lastTop=Ezogashima.svg[Ezogashima.curr].getBoundingClientRect().top;
  for(i=Ezogashima.curr+1;i<=Ezogashima.currmax;i++){
    if(Ezogashima.svg[i]==null||Ezogashima.pre[i]==null){
      Ezogashima.buildup(i);
      break;
    }
    if(Ezogashima.svg[i].style.position=="absolute"){
      if(Ezogashima.pre[i].textContent>""){
        Ezogashima.svg[i].style.position="static";
        Ezogashima.svg[i].style.visibility="visible";
      }
    }
    Ezogashima.lemmatranslit(i);
    conllusvg.rewrite("pre"+i);
    r=Ezogashima.svg[i].getBoundingClientRect();
    if(r.top-window.innerHeight-1000>0)
      break;
  }
}
Ezogashima.buildup=function(x){
  var t,i;
  if(Ezogashima.svg[x]==null){
    t=document.createElementNS("http://www.w3.org/2000/svg","svg");
    for(i=parseInt(x,10)+1;i<=Ezogashima.currmax;i++){
      if(Ezogashima.svg[i]!=null)
        break;
    }
    t.style.position="absolute";
    t.style.visibility="hidden";
    if(i>Ezogashima.currmax)
      document.body.appendChild(t);
    else
      document.body.insertBefore(t,Ezogashima.svg[i]);
    Ezogashima.svg[x]=t;
    t.addEventListener("mousedown",Ezogashima.onmousedown);
    t.addEventListener("touchstart",Ezogashima.onmousedown);
  }
  if(Ezogashima.pre[x]==null){
    t=document.createElement("pre");
    t.style.display="none";
    t.setAttribute("id","pre"+x);
    document.body.appendChild(t);
    Ezogashima.pre[x]=t;
    if(conllusvg.main["pre"+x]==null)
      conllusvg.view(Ezogashima.svg[x],"pre"+x);
    conllusvg.loadRemote("pre"+x,Ezogashima.apiURL+"files/"+encodeURIComponent(Ezogashima.volpath+"/"+Ezogashima.txt[x])+"/raw?ref=master");
  }
}
Ezogashima.lemmatranslit=function(x){
  var s,t,i;
  if(Ezogashima.pre[x]==null)
    return;
  if(Ezogashima.pre[x].textContent.indexOf("Translit=")>0)
    return;
  s=Ezogashima.pre[x].textContent.split("\n");
  for(i=0;i<s.length;i++){
    t=s[i].split("\t");
    if(t.length==10){
      if(t[2]!="_"&&t[1]!=t[2]){
        if(t[9]=="_")
          t[9]="Translit="+t[2];
        else if(t[9].indexOf("Translit=")<0)
          t[9]=t[9]+"|Translit="+t[2];
        s[i]=t.join("\t");
      }
    }
  }
  conllusvg.loadText("pre"+x,s.join("\n"));
}
Ezogashima.volchange=function(){
  var s;
  Ezogashima.clearSVG();
  for(s in Ezogashima.pre){
    if(Ezogashima.pre[s]!=null)
      document.body.removeChild(Ezogashima.pre[s]);
    Ezogashima.pre[s]=null;
  }
  if(Ezogashima.dirTree==null)
    Ezogashima.gettree(1);
  else
    Ezogashima.writeSVG();
}
Ezogashima.gettree=function(p){
  if(Ezogashima.request==null){
    Ezogashima.request=new XMLHttpRequest();
    Ezogashima.request.onload=Ezogashima.ongettree;
  }
  Ezogashima.gettreepage=p;
  Ezogashima.request.open("GET",Ezogashima.apiURL+"tree?per_page=100&path="+Ezogashima.volpath+"&page="+p);
  Ezogashima.request.send();
}
Ezogashima.ongettree=function(e){
  var s;
  if(Ezogashima.request.status==200){
    s=Ezogashima.request.responseText;
    if(Ezogashima.gettreepage==1)
      Ezogashima.dirTree=s;
    else
      Ezogashima.dirTree+=s;
    if(s.indexOf(".txt")<0)
      Ezogashima.writeSVG();
    else
      Ezogashima.gettree(Ezogashima.gettreepage+1);
  }
}
Ezogashima.txtsort=function(x,y){
  if(x<y)
    return -1;
  if(x>y)
    return 1;
  return 0;
}
Ezogashima.writeSVG=function(){
  var r,x,i,j;
  Ezogashima.clearSVG();
  r=new RegExp("[0-9]+-[0-9]+[a-z]?.txt","g");
  x=Ezogashima.dirTree.match(r);
  x.sort(Ezogashima.txtsort);
  Ezogashima.txt=new Array()
  Ezogashima.txt[0]=x[0];
  for(i=j=1;i<x.length;i++){
    if(x[i-1]!=x[i]){
      Ezogashima.txt[j]=x[i];
      j++;
    }
  }
  Ezogashima.currmax=Ezogashima.txt.length-1;
  Ezogashima.curr=0;
  Ezogashima.lastTop=null;
}
Ezogashima.clearSVG=function(){
  var x;
  Ezogashima.curr=Ezogashima.lastTop=null;
  if(Ezogashima.svg!=null){
    for(x in Ezogashima.svg){
      if(Ezogashima.svg[x]!=null){
        Ezogashima.svg[x].style.position="absolute";
        Ezogashima.svg[x].style.visibility="hidden";
      }
    }
  }
  if(document.scrollingElement==null)
    document.documentElement.scrollTop=0;
  else
    document.scrollingElement.scrollTop=0;
}
Ezogashima.onmousedown=function(e){
  var x,y;
  if(Ezogashima.lastX==null){
    Ezogashima.lastX=e.clientX;
    Ezogashima.lastY=e.clientY;
    return;
  }
  x=e.clientX-Ezogashima.lastX;
  y=e.clientY-Ezogashima.lastY;
  if(x*x+y*y>9){
    Ezogashima.lastX=e.clientX;
    Ezogashima.lastY=e.clientY;
    return;
  }
  Ezogashima.lastX=null;
  x=e.currentTarget;
  for(y in Ezogashima.svg){
    if(Ezogashima.svg[y]==x){
      window.open("editor-kanbun.html#"+Ezogashima.apiURL+"files/"+encodeURIComponent(Ezogashima.volpath+"/"+Ezogashima.txt[y])+"/raw?ref=master");
      break;
    }
  }
}
Ezogashima.reload=function(){
  var i,r;
  for(i=Ezogashima.curr;i<=Ezogashima.currmax;i++){
    if(Ezogashima.svg[i]==null||Ezogashima.pre[i]==null)
      return;
    r=Ezogashima.svg[i].getBoundingClientRect();
    if(r.top>window.innerHeight||r.bottom<0)
      return;
    conllusvg.loadRemote("pre"+i,Ezogashima.apiURL+"files/"+encodeURIComponent(Ezogashima.volpath+"/"+Ezogashima.txt[i])+"/raw?ref=master");
  }
}
Ezogashima.gitlab=function(){
  window.open("/gitlab/Kanbun/ud-ja-kanbun/blob/master/"+Ezogashima.volpath+"/"+Ezogashima.txt[Ezogashima.curr]);
}
</script>
<body onload="Ezogashima.init()">
<div id="top" style="position:fixed; top:0px; left:0px; padding:10px; width:100%; background:white">
<font size="+3"><b>狄島夜話記</b></font>
<input type="button" value="GitLab" onclick="Ezogashima.gitlab()" />
<input type="button" value="Reload" onclick="Ezogashima.reload()" />
</div>
</body>

conllusvg/Matsushima.html

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