-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
280 lines (270 loc) · 13 KB
/
index.html
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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
198
199
200
201
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
275
276
277
278
279
280
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="css/CETEIcean.css">
<script src="js/CETEI.js"></script>
</head>
<body>
<h1>Preview TEI edition</h1>
<h2>Select a TEI File</h1>
<input type="file" id="fileInput" accept=".xml" />
<button id="loadFileButton">Load File</button>
<div id="loadingMessage">Please wait, loading file...</div>
<h2>Edition</h2>
<div id="output"></div>
<script>
let c = new CETEI();
let behaviors = {
"tei": {
"teiHeader": null,
"witness": [
["[source]", [""," (Abschrift von <a href=\"$@source\">$@source</a>)"]],
["_", [""]]
],
"witStart": [
"↧",""
],
"witEnd": [
"↥",""
],
"lacunaStart": [
"⇣",""
],
"lacunaEnd": [
"⇡",""
],
"lem": [
["[resp][type=deletion]", [""," <small>del. $@resp</small>"]],
["[source][type=deletion]", [""," <small>del. $@source</small>"]],
["[wit]", [""," <small>$@wit</small>"]],
["[resp]", [""," <small>$@resp</small>"]],
["[source]", [""," <small>$@source</small>"]],
["_", [""]]
],
"rdg": [
["[wit][type=omission][cause=homoioteleuton][varSeq][hand]", ["","om. <small>$@wit($@varSeq)<sup>$@hand</sup> (homoioteleuton)</small>"]],
["[wit][type=omission][cause=homoiarkton][varSeq][hand]", ["","om. <small>$@wit($@varSeq)<sup>$@hand</sup> (homoiarkton)</small>"]],
["[wit][type=omission][cause=saut_du_meme][varSeq][hand]", ["","om. <small>$@wit($@varSeq)<sup>$@hand</sup> (saut du même)</small>"]],
["[wit][type=addition][cause=dittography][varSeq][hand]", ["","<small>add. $@wit($@varSeq)<sup>$@hand</sup> (dittography)</small>"]],
["[wit][type=omission][cause=homoioteleuton][varSeq]", ["","om. <small>$@wit($@varSeq) (homoioteleuton)</small>"]],
["[wit][type=omission][cause=homoiarkton][varSeq]", ["","om. <small>$@wit($@varSeq) (homoiarkton)</small>"]],
["[wit][type=omission][cause=saut_du_meme][varSeq]", ["","om. <small>$@wit($@varSeq) (saut du même)</small>"]],
["[wit][type=addition][cause=dittography][varSeq]", ["","<small>add. $@wit($@varSeq) (dittography)</small>"]],
["[wit][type=omission][cause=homoioteleuton]", ["","om. <small>$@wit (homoioteleuton)</small>"]],
["[wit][type=omission][cause=homoiarkton]", ["","om. <small>$@wit (homoiarkton)</small>"]],
["[wit][type=omission][cause=saut_du_meme]", ["","om. <small>$@wit (saut du même)</small>"]],
["[wit][type=addition][cause=dittography]", ["","<small>add. $@wit (dittography)</small>"]],
["[wit][type=omission][varSeq][hand]", ["","om. <small>$@wit($@varSeq)<sup>$@hand</sup></small>"]],
["[wit][type=addition][varSeq][hand]", [""," <small>add. $@wit($@varSeq)<sup>$@hand</sup></small>"]],
["[wit][type=transposition][varSeq][hand]", [""," <small>trans. $@wit($@varSeq)<sup>$@hand</sup></small>"]],
["[wit][type=illegible][varSeq][hand]", [""," <small>$@wit($@varSeq)<sup>$@hand</sup> (illegible)</small>"]],
["[wit][type=damage][varSeq][hand]", [""," <small>$@wit($@varSeq)<sup>$@hand</sup> (damage)</small>"]],
["[wit][type=fenestra][varSeq][hand]", [""," <small>$@wit($@varSeq)<sup>$@hand</sup> (fenestra)</small>"]],
["[wit][type=deletion][varSeq][hand]", ["","del. <small>$@wit($@varSeq)<sup>$@hand</sup></small>"]],
["[wit][type=omission][varSeq]", ["","om. <small>$@wit($@varSeq)</small>"]],
["[wit][type=addition][varSeq]", [""," <small>add. $@wit($@varSeq)</small>"]],
["[wit][type=transposition][varSeq]", [""," <small>trans. $@wit($@varSeq)</small>"]],
["[wit][type=illegible][varSeq]", [""," <small>$@wit($@varSeq) (illegible)</small>"]],
["[wit][type=damage][varSeq]", [""," <small>$@wit($@varSeq) (damage)</small>"]],
["[wit][type=fenestra][varSeq]", [""," <small>$@wit($@varSeq) (fenestra)</small>"]],
["[wit][type=deletion][varSeq]", ["","del. <small>$@wit($@varSeq)</small>"]],
["[wit][type=omission]", ["","om. <small>$@wit</small>"]],
["[wit][type=addition]", [""," <small>add. $@wit</small>"]],
["[wit][type=transposition]", [""," <small>trans. $@wit</small>"]],
["[wit][type=illegible]", [""," <small>$@wit (illegible)</small>"]],
["[wit][type=damage]", [""," <small>$@wit (damage)</small>"]],
["[wit][type=fenestra]", [""," <small>$@wit (fenestra)</small>"]],
["[wit][type=deletion]", ["","del. <small>$@wit</small>"]],
["[wit][cause=orthographic]", [""," <small>$@wit (orthographic)</small>"]],
["[wit][cause=homoioteleuton]", [""," <small>$@wit (homioteleuton)</small>"]],
["[wit][cause=homoiarkton]", [""," <small>$@wit (homoiarkton)</small>"]],
["[wit][cause=saut_du_meme]", [""," <small>$@wit (saut du même)</small>"]],
["[wit][cause=dittography]", [""," <small>$@wit (dittography)</small>"]],
["[resp][type=transposition]", [""," trans. <small>$@resp</small>"]],
["[source][type=transposition]", [""," trans. <small>$@source</small>"]],
["[resp][type=deletion]", [""," del. <small>$@resp</small>"]],
["[source][type=deletion]", [""," del. <small>$@source</small>"]],
["[wit][varSeq][hand]", [""," <small>$@wit($@varSeq)<sup>$@hand</sup></small>"]],
["[wit][varSeq]", [""," <small>$@wit($@varSeq)</small>"]],
["[wit]", [""," <small>$@wit</small>"]],
["[resp]", [""," <small>$@resp</small>"]],
["[source]", [""," <small>$@source</small>"]],
["_", [""]]
],
"milestone": [
["[edRef]", ["($@n $@edRef",")"]],
],
"cb": [
["[n]", ["[col. $@n]"]],
["_", ["[col.]"]]
],
"pb": [
["tei-div[type=praefatio] tei-pb[n]",["[$@n]"]],
["[facs]", ["<a href=\"$rw@facs\" target=\"_blank\">[$@n]","</a>"]],
["[n][edRef]", ["[$@n ($@edRef)]"]],
["[n]", ["[$@n]"]]
],
"note": [
["[place][hand]", ["[note: $@place ($@hand)] ",""]],
["[place]", ["[note: $@place] ",""]],
],
"subst": [
["[hand]", ["⸢", " (<small>$@hand</small>)⸣"]],
['_', ["⸢", "⸣"]]
],
"add": [
["[place=margin][hand]", [" ⟨$@hand in mg. ","⟩"]],
["[place=margin]", [" ⟨in mg. ","⟩"]],
["[place=above][hand]", ["<sup>⟨"," ($@hand)⟩</sup>"]],
["[place=above]", ["<sup>⟨","⟩</sup>"]],
["[place=inline][hand]", ["⟨"," ($@hand)⟩"]],
["[place=inline]", ["⟨","⟩"]],
["_", ["⟨","⟩"]]
],
"del": [
["[rend=unmarked][hand]", [" "," <sup>del. ($@hand)</sup>"]],
["[rend=unmarked]", [" "," <sup>del.</sup>"]],
["[rend=marker][hand]", [" ","* ($@hand)"]],
["[rend=marker]", [" ","*"]],
["[rend=strikethrough][hand]", [" "," ($@hand)"]],
["[rend=strikethrough]", [" "," "]],
["[rend=expunction][hand]", [" "," ($@hand)"]],
["[rend=expunction]", [" "," "]],
["[rend=erasure][hand]", [" "," ($@hand)"]],
["[rend=erasure]", [" "," "]],
["[rend=overwrite][hand]", [" "," ($@hand)"]],
["[rend=overwrite]", [" "," "]],
["_", [" "," "]]
],
"supplied": [
["[reason=lost]", ["{","}"]],
["_", ["⟨","⟩"]]
],
"surplus": [
"[","]"
],
"gap": [
["[resp][reason=missing]", ["[[lacunam ($@quantity $@unit) ind. $@resp]]"]],
["[source][reason=missing]", ["[[lacunam ($@quantity $@unit) ind. $@source]]"]],
["[reason=missing][quantity]", ["[[lacuna ($@quantity $@unit)]]"]],
["[reason=missing]", ["[[lacuna]]"]],
["[reason=illegible][quantity]", ["[[illegible ($@quantity $@unit)]]"]],
["[reason=illegible]", ["[[illegible]]"]],
["[reason=damage][quantity]", ["[[damage ($@quantity $@unit)]]"]],
["[reason=damage]", ["[[damage]]"]],
["[reason=fenestra][quantity]", ["[[fenestra ($@quantity $@unit)]]"]],
["[reason=fenestra]", ["[[fenestra]]"]],
],
"ref": [
["[target]", ["<a href=\"$rw@target\">", "</a>"]],
["[decls='#biblical'][cref]", function(elt) {
let linkNum = elt.getAttribute("cref").replace(/[A-Za-z]+?:([0-9A-Za-z]+?):([0-9]+?):([0-9]+?)/,"$1:$2:$3");
let linkShow = elt.getAttribute("cref").replace(/[A-Za-z]+?:([0-9A-Za-z]+?):([0-9]+?):([0-9]+?)/,"$1 $2,$3");
let linkPre = 'https://pta.bbaw.de/indices/biblical-references?ref=';
let link = document.createElement("a");
link.innerHTML = "("+linkShow+")";
link.href = linkPre.concat(linkNum);
return link;
}]
],
"note": function(elt){
if (!this.noteIndex){
this["noteIndex"] = 1;
} else {
this.noteIndex++;
}
let id = "note" + this.noteIndex;
let link = document.createElement("a");
link.setAttribute("id", "src" + id);
link.setAttribute("href", "#" + id);
link.innerHTML = this.noteIndex;
let content = document.createElement("sup");
content.appendChild(link);
let notes = this.dom.querySelector("ol.notes");
if (!notes) {
notes = document.createElement("ol");
notes.setAttribute("class", "notes");
this.dom.appendChild(notes);
}
let note = document.createElement("li");
note.id = id;
note.innerHTML = "<a href=\"#src" + id + "\">^</a> " + elt.innerHTML
notes.appendChild(note);
return content;
},
"persName": [
["[key]", ["<a href=\"https://pta.bbaw.de/de/indices/persons?ref=$@key\" target=\"_blank\">","</a>"]],
],
"orgName": [
["[key]", ["<a href=\"https://pta.bbaw.de/de/indices/groups?ref=$@key\" target=\"_blank\">","</a>"]],
],
"placeName": [
["[ref]", ["<a href=\"$rw@ref\" target=\"_blank\">","</a>"]],
],
}
};
c.addBehaviors(behaviors);
document.getElementById('loadFileButton').addEventListener('click', function() {
const fileInput = document.getElementById('fileInput');
const file = fileInput.files[0]; // Get the selected file
if (file) {
// Check file size
const maxSize = 6291456; // 6 MB
if (file.size > maxSize) {
alert("File is too large. Please upload a file smaller than 6 MB.");
return;
}
// Check if the file type is XML
if (file.type === 'text/xml') {
const reader = new FileReader();
// Show loading message
document.getElementById('loadingMessage').style.display = 'block';
reader.onload = function(e) {
const content = e.target.result;
// Create a URL for the file
const fileURL = URL.createObjectURL(file);
// Call the c.getHTML5 function with the file URL
c.getHTML5(fileURL, function(data) {
document.getElementById("output").innerHTML = ""; // Clear previous output
document.getElementById("output").appendChild(data);
// Hide loading message
document.getElementById('loadingMessage').style.display = 'none';
var substitutions = document.querySelectorAll("tei-subst");
substitutions.forEach(function(subst) {
subst.querySelector("tei-add").addEventListener("click", function() {
var del = subst.querySelector("tei-del");
if (window.getComputedStyle(del).getPropertyValue("display") == "none") {
del.style.display = "inline";
} else {
del.style.display = "none";
}
});
});
var nomsac = document.querySelectorAll("tei-choice");
nomsac.forEach(function(subst) {
subst.querySelector("tei-abbr").addEventListener("mouseover", function() {
var expan = subst.querySelector("tei-expan");
if (window.getComputedStyle(expan).getPropertyValue("display") == "none") {
expan.style.display = "inline";
expan.style.color = "grey";
} else {
expan.style.display = "none";
}
});
});
});
};
reader.readAsText(file);
} else {
alert("Please upload a valid XML file.");
}
} else {
alert("Please select a file first.");
}
});
</script>
</body>
</html>