Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!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;
}
}
t=Liji.svg[Liji.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=Liji.curr;
}
else if(Liji.retrytimes>0)
Liji.retrytimes--;
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
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.goto=function(){
Liji.retrytimes=3;
Liji.writeSVG();
}
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
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/001">曲禮上</option>
<option value="kanripo/kR1d0052/002">曲禮下</option>
<option value="kanripo/kR1d0052/003">檀弓上</option>
<option value="kanripo/kR1d0052/004">檀弓下</option>
<option value="kanripo/kR1d0052/005">王制</option>
<option value="kanripo/kR1d0052/006">月令</option>
<option value="kanripo/kR1d0052/007">曾子問</option>
<option value="kanripo/kR1d0052/008">文王世子</option>
<option value="kanripo/kR1d0052/009">禮運</option>
<option value="kanripo/kR1d0052/010">禮器</option>
<option value="kanripo/kR1d0052/011">郊特牲</option>
<option value="kanripo/kR1d0052/012">內則</option>
<option value="kanripo/kR1d0052/013">玉藻</option>
<option value="kanripo/kR1d0052/014">明堂位</option>
<option value="kanripo/kR1d0052/015">喪服小記</option>
<option value="kanripo/kR1d0052/016">大傳</option>
<option value="kanripo/kR1d0052/017">少儀</option>
<option value="kanripo/kR1d0052/018">學記</option>
<option value="kanripo/kR1d0052/019">樂記</option>
<option value="kanripo/kR1d0052/027">經解</option>
<option value="kanripo/kR1d0052/028">哀公問</option>
<option value="kanripo/kR1d0052/029">仲尼燕居</option>
<option value="kanripo/kR1d0052/030">孔子閒居</option>
<option value="kanripo/kR1d0052/031">坊記</option>
<option value="kanripo/kR1d0052/033">表記</option>
<option value="kanripo/kR1d0052/034">緇衣</option>
<option value="kanripo/kR1d0052/035">奔喪</option>
<option value="kanripo/kR1d0052/036">問喪</option>
<option value="kanripo/kR1d0052/037">服問</option>
<option value="kanripo/kR1d0052/038">間傳</option>
<option value="kanripo/kR1d0052/039">三年問</option>
<option value="kanripo/kR1d0052/040">深衣</option>
<option value="kanripo/kR1d0052/041">投壺</option>
<option value="kanripo/kR1d0052/042">儒行</option>
<option value="kanripo/kR1d0052/043" selected>大學</option>
<option value="kanripo/kR1d0052/044">冠義</option>
<option value="kanripo/kR1d0052/045">昏義</option>
<option value="kanripo/kR1d0052/046">鄉飲酒義</option>
<option value="kanripo/kR1d0052/047">射義</option>
<option value="kanripo/kR1d0052/048">燕義</option>
<option value="kanripo/kR1d0052/049">聘義</option>
<option value="kanripo/kR1d0052/050">喪服四制</option>
<input type="text" id="count" size=3 value=0 style="text-align:right" onchange="Liji.goto()" />
<input type="button" value="GitLab" onclick="Liji.gitlab()" />
<input type="button" value="Reload" onclick="Liji.reload()" />
</div>
</body>