-
Notifications
You must be signed in to change notification settings - Fork 0
/
fonttester.html
289 lines (284 loc) · 11.5 KB
/
fonttester.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
281
282
283
284
285
286
287
288
289
<html>
<head>
<title>Cuneiform Font Tester</title>
<meta charset="utf-8"/>
<style>
@font-face {
font-family: 'MyWebFont';
src: url('e.otf');/* Legacy iOS */
}
@font-face {
font-family: 'MyWebFont2';
src: url('global.otf');/* Legacy iOS */
}
.costumfont {
font-family: 'MyWebFont', Fallback, sans-serif;
-webkit-font-feature-settings: 'liga';
-moz-font-feature-settings: 'liga';
-o-font-feature-settings: 'liga';
font-feature-settings: 'liga';
}
.costumfont2 {
font-family: 'MyWebFont2', Fallback, sans-serif;
-webkit-font-feature-settings: 'liga';
-moz-font-feature-settings: 'liga';
-o-font-feature-settings: 'liga';
font-feature-settings: 'liga';
}
</style>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="js/paleocodes.js"></script>
<script src="js/cdlitexts.js"></script>
<script src="js/signlist.js"></script>
<script>
function recreateTextTable(language){
var res="";
for(item in cdlitexts[language]){
if(item<1001){
res+="<option value=\""+cdlitexts[language][item]+"\">"+cdlitexts[language][item]+"</option>"
}
}
$('#cdlitextselect').html(res);
}
var activated=false
function activateWebFont(){
if(activated){
$("#fontusage").removeAttr("class");
activated=false;
}else{
$("#fontusage").attr("class", "costumfont");
activated=true;
}
}
function getUnicodeFromTransliteration(signname){
console.log(paleocodestore)
if(signname in signlist){
return signlist[signname];
}
if(signname.toLowerCase() in signlist){
return signlist[signname.toLowerCase()];
}
return "";
}
var activated3=false
function activateWebFont3(){
$(".fontusage3").each(function(){
if(activated3){
$(".fontusage3").removeClass("costumfont2");
}else{
$(".fontusage3").addClass("costumfont2");
}
});
if(activated3){
activated3=false;
}else{
activated3=true;
}
}
$(document).ready(function() {
var res=""
var languages="";
var firstlang="";
for(item in cdlitexts){
if(firstlang==""){
firstlang=item
}
languages+="<option value=\""+item+"\">"+item+"</option>"
}
$('#cdlilanguages').html(languages);
for(item in cdlitexts[firstlang]){
if(item<1001){
res+="<option value=\""+cdlitexts[firstlang][item]+"\">"+cdlitexts[firstlang][item]+"</option>"
}
}
$('#cdlitextselect').html(res);
$(".fontusage3").each(function () {
$(this).bind("copy", function(e){
e.preventDefault();
console.log('copy behaviour detected!');
var selectedText = window.getSelection().toString();
selectedText = selectedText.replace(/\u200B/g, "");
console.log(selectedText)
console.log(e)
console.log($('#copyunicode').prop('checked'))
if($('#copyunicode').prop('checked')){
if(selectedText.includes("-")){
var spl=selectedText.split("-")
var unicodesign=""
for(chara in spl){
var trimmed=spl[chara].replace(/-/g,"").replace(/\./g,"").replace(/#/g,"").replace(/ /g,"").replace(/_/g,"").replace(/\[/g,"").replace(/\]/g,"").replace(/\}/g,"").replace(/\{/g,"").trim()
console.log(trimmed)
unicodesign+=getUnicodeFromTransliteration(trimmed)
console.log(unicodesign)
}
}else{
var trimmed=selectedText.replace(/-/g,"").replace(/\./g,"").replace(/#/g,"").replace(/ /g,"").replace(/_/g,"").replace(/\[/g,"").replace(/\]/g,"").replace(/\{/g,"").replace(/\}/g,"").trim()
console.log(trimmed)
var unicodesign=getUnicodeFromTransliteration(trimmed)
console.log(unicodesign)
}
if(unicodesign!=null){
e.originalEvent.clipboardData.setData('text/plain', unicodesign);
}else{
e.originalEvent.clipboardData.setData('text/plain', selectedText);
}
}else{
e.originalEvent.clipboardData.setData('text/plain', selectedText);
}
console.log(e.originalEvent.clipboardData)
});
});
});
</script>
</head>
<body>
<div class="page-header text-center">
<h1 align="center">Modified transliteration to cuneiform</h1>
</div>
<br/><br/>
<div class="container">
<div class="row">
<div class="left col-sm-12">
How does it work?
<ul>
<li>Cuneiform sign variants can be created using the PaleoCodage encoding which can be tested <a href="https://situx.github.io/PaleoCodage">here</a></li>
<li>PaleoCodage cuneiform sign variants get a distinct ID which is used to identify the character.</li>
<li>IDs are used as the basis for the modified transliteration</li>
<li>A WOFF font is generated and included in this homepage so that the transliteration can be converted to cuneiform</li>
</ul>
<h3>Sign variant example</h3>
<div class="row">
<div class="left col-sm-5">
<span id="transliteration" style="font-size:70">
E Ev1 Ev2 Ev3
</span><br/>
<button id="usefont" onclick="activateWebFont()">Switch Font</button>
</div>
<div class="left col-sm-2" style="font-size:70">
|
</div>
<div class="left col-sm-5">
<span id="fontusage" style="font-size:70">
E Ev1 Ev2 Ev3
</span>
</div>
</div><br/>
<h3>Application of the approach on CDLI texts</h3>
<table><tr><td>
Copy Unicode<input type="checkbox" id="copyunicode"><br/>
Load CDLI Text: Language:<select id="cdlilanguages" onchange="recreateTextTable(document.getElementById('cdlilanguages').value)"></select>
Text:<select id="cdlitextselect" onchange="loadText(document.getElementById('cdlitextselect').value)">
</select><a id="cdlilink" href="#" target="_blank">Link To CDLI</a><br/>
<button id="usefont3" onclick="activateWebFont3()">Switch Font</button>
</td><td><table><tr><th colspan="3" align="center">Legend of Text markings</th></tr><tr><td style="background-color:yellow"> </td><td>Determinative<br/>(e.g. {ki})</td>
<td style="background-color:orange"> </td><td>Broken Sign<br/>(e.g. usz#)</td><td style="background-color:red"> </td><td>Assignment unsure<br/>(e.g. ki?)</td></tr><tr>
<td style="background-color:green"></td><td>Broken away material</td><td style="background-color:blue"></td><td>Sign correction<br/>(e.g. ki!)</td><td style="background-color:grey"> </td><td>Not yet assigned....</td></tr></table></td></tr></table>
</div></div>
<div class="row">
<div class="left col-sm-12">
<table border="0" width="100%" id="texttable" style="font-size:50">
<tr><td>1. 1 MA.NA KU3.BABBAR e-lu</td><td class="fontusage3">1. 1 MA.NA KU3.BABBAR e-lu</td></tr>
<tr><td>2. i-na li-ib-bi sza3 i-na</td><td class="fontusage3">2. i-na li-ib-bi sza3 i-na</td></tr>
<tr><td>3. ri-isz-sz u#-ud-da</td><td class="fontusage3">3. ri-isz-sz u#-ud-da</td></tr>
<tr><td>4. u3 ri-x [i] -sz-x na-pa-ah-szu</td><td class="fontusage3">4. u3 ri-x [i] -sz-x na-pa-ah-szu</td></tr>
<tr><td>5. [a] -na 4 sze-me-ri</td><td class="fontusage3">5. [a] -na 4 sze-me-ri</td></tr>
<tr><td>@bottom</td><td class="fontusage3">@bottom</td></tr>
<tr><td>6. sza3 SZU i-na-bu-ub-lu</td><td class="fontusage3">6. sza3 SZU i-na-bu-ub-lu</td></tr>
<tr><td># oder la</td><td class="fontusage3"># oder la</td></tr>
<tr><td>7. le-e-qu2</td><td class="fontusage3">7. le-e-qu2</td></tr></table>
</div>
</div>
<div class="row">
<div class="left col-sm-12">
<h2>Frequently Asked Questions</h2>
<ol>
<li>What happens when I copy the character? The modified transliteration is copied</li>
<li>I want to copy the unicode representation of the cuneiform character! : No problem! On this homepage you can achieve this using a checkbox setting!</li>
<li>Can I convert the modified transliteration to a common transliteration? Certainly, but not the other way around</li>
<li>How does the modified transliteration differ from the common transliteration? Sign variant information is appended using v-Suffixes</li>
</ol>
</div></div>
<script>
function formatWords(line){
var resstring=""
var words=line.trim().split("-");
for(word in words){
if(words[word].includes("#")){
resstring+="<span style=\"background-color:orange\">"+words[word]+"</span>-"
}else if(words[word].includes("!")){
resstring+="<span style=\"background-color:blue\">"+words[word]+"</span>-"
}else if(words[word].includes("?")){
resstring+="<span style=\"background-color:red\">"+words[word]+"</span>-"
}else if(words[word].includes("{") && words[word].includes("}")){
resstring+=words[word].substring(0,words[word].indexOf('{'))+"<span style=\"background-color:yellow\">"+words[word].substring(words[word].indexOf('{'),words[word].lastIndexOf('}')+1)+"</span>"+words[word].substring(words[word].lastIndexOf('}')+1,words[word].length)+"-"
}else if(words[word].includes("[") && words[word].includes("]")){
resstring+=words[word].substring(0,words[word].indexOf('['))+"<span style=\"background-color:green\">"+words[word].substring(words[word].indexOf('{'),words[word].lastIndexOf('}')+1)+"</span>"+words[word].substring(words[word].lastIndexOf(']')+1,words[word].length)+"-"
}
else{
resstring+=words[word]+"-"
}
}
return resstring.substring(0,resstring.length-1);
}
function loadText(textid){
$.ajax({
url: "https://www.i3mainz.de/projekte/cdli/getText?cdliNumber="+textid,
async: true,
dataType: "text",
success: function (data){
activated3=false;
$('#cdlilink').attr("href","https://cdli.ucla.edu/search/archival_view.php?ObjectID="+textid);
var restable="";
var lines=data.split(/(?:\r\n|\r|\n)/g)
for(line in lines){
if(lines[line].trim()!="" && (lines[line].startsWith("@") || lines[line].startsWith("#") || lines[line].startsWith("$"))){
restable+="<tr><td style=\"font-size:18\">"+lines[line]+"</td><td style=\"font-size:14\"></td><td class=\"fontusage3\"></td></tr>"
}else if(lines[line].trim()!=""){
restable+="<tr><td style=\"font-size:18\">"+lines[line].substring(0,lines[line].indexOf('.')+1)+"</td><td style=\"font-size:14\">"+lines[line].substring(lines[line].indexOf('.')+1)+"</td><td class=\"fontusage3\">"+formatWords(lines[line].substring(lines[line].indexOf('.')+1))+"</td></tr>"
}
}
$('#texttable').html(restable)
$(".fontusage3").each(function () {
$(this).bind("copy", function(e){
e.preventDefault();
console.log('copy behaviour detected!');
var selectedText = window.getSelection().toString();
selectedText = selectedText.replace(/\u200B/g, "");
console.log(selectedText)
console.log(e)
console.log($('#copyunicode').prop('checked'))
if($('#copyunicode').prop('checked')){
if(selectedText.includes("-")){
var spl=selectedText.split("-")
var unicodesign=""
for(chara in spl){
var trimmed=spl[chara].replace(/-/g,"").replace(/\./g,"").replace(/#/g,"").replace(/ /g,"").replace(/\[/g,"").replace(/\]/g,"").replace(/\{/g,"").replace(/\}/g,"").trim()
console.log(trimmed)
unicodesign+=getUnicodeFromTransliteration(trimmed)
console.log(unicodesign)
}
}else{
var trimmed=selectedText.replace(/-/g,"").replace(/\./g,"").replace(/#/g,"").replace(/ /g,"").replace(/\[/g,"").replace(/\]/g,"").replace(/\{/g,"").replace(/\}/g,"").trim()
console.log(trimmed)
var unicodesign=getUnicodeFromTransliteration(trimmed)
console.log(unicodesign)
}
if(unicodesign!=null){
e.originalEvent.clipboardData.setData('text/plain', unicodesign);
}else{
e.originalEvent.clipboardData.setData('text/plain', selectedText);
}
}else{
e.originalEvent.clipboardData.setData('text/plain', selectedText);
}
console.log(e.originalEvent.clipboardData)
});
});
}
});
}
</script>
</body>
</html>