-
Notifications
You must be signed in to change notification settings - Fork 8
/
_make-array.html
143 lines (120 loc) · 4.17 KB
/
_make-array.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
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Latin char list generator</title>
<!-- creates markup for a list of Latin characters -->
<!--script src="../../../../uniview/u.js"></script-->
<script src="langs.js"></script>
<script>
cl = []
totalLangs = 0
totalChars = 0
function makeList (list, lang) {
list = list.trim()
list = list.replace(/\s+/g,'')
var listarray = [...list]
//var out = 'var cl = []\n\n'
var out = ''
//console.log(listarray)
for (let i=0;i<listarray.length;i++) {
var dec = listarray[i].codePointAt(0)
console.log(dec, cl[dec])
if (cl[dec]) cl[dec].push(lang)
else {
cl[dec] = []
cl[dec].push(lang)
}
}
for (let i=0;i<cl.length;i++) {
if (cl[i]) {
out += 'cl[0x'+i.toString(16).toUpperCase()+']=['
//out += 'cl[0x'+String.fromCodePoint(i)+']=['
for (let x=0;x<cl[i].length;x++) out += '"'+cl[i][x]+'",'
out += ']\n'
}
}
return out
}
function updateCL (list, auxlist, lang) {
if (debug) console.log('UPDATECL: list ',list, 'auxlist ',auxlist, 'lang', lang)
list = list.trim()
auxlist = auxlist.trim()
list = list.replace(/\s+/g,'')
auxlist = auxlist.replace(/\s+/g,'')
var listarray = [...list]
var auxarray = [...auxlist]
//console.log(listarray)
for (let i=0;i<listarray.length;i++) {
var dec = listarray[i].codePointAt(0)
//console.log(dec, cl[dec])
if (cl[dec]) cl[dec][0].push(lang)
else {
cl[dec] = [[],[]]
cl[dec][0].push(lang)
}
}
for (let i=0;i<auxarray.length;i++) {
var dec = auxarray[i].codePointAt(0)
if (cl[dec]) cl[dec][1].push(lang)
else {
cl[dec] = [[],[]]
cl[dec][1].push(lang)
}
}
}
function dump () {
out = ''
for (let i=0;i<cl.length;i++) {
if (cl[i]) {
window.totalChars++
out += 'cl[0x'+i.toString(16).toUpperCase()+']=[['
for (let x=0;x<cl[i][0].length;x++) out += '"'+cl[i][0][x]+'",'
out += '], ['
if (cl[i][1]) for (let x=0;x<cl[i][1].length;x++) out += '"'+cl[i][1][x]+'",'
out += ']]\n'
}
}
return 'var cl = []\n\n'+out
}
function create () {
for (var lang in langs) {
list = ''
auxlist = ''
window.totalLangs++
if (langs[lang].letter) list += langs[lang].letter
if (langs[lang].mark) list += langs[lang].mark
if (langs[lang].number) list += langs[lang].number
if (langs[lang].punctuation) list += langs[lang].punctuation
if (langs[lang].symbol) list += langs[lang].symbol
if (langs[lang].separator) list += langs[lang].separator
if (langs[lang].other) list += langs[lang].other
if (langs[lang].letteraux) auxlist += langs[lang].letteraux
if (langs[lang].markaux) auxlist += langs[lang].markaux
if (langs[lang].numberaux) auxlist += langs[lang].numberaux
if (langs[lang].punctuationaux) auxlist += langs[lang].punctuationaux
if (langs[lang].symbolaux) auxlist += langs[lang].symbolaux
if (langs[lang].separatoraux) auxlist += langs[lang].separatoraux
if (langs[lang].otheraux) auxlist += langs[lang].otheraux
if (langs[lang].aux) auxlist += langs[lang].aux
console.log(list,lang,auxlist)
if (list != '') updateCL(list,auxlist,lang)+'\n'
}
console.log(cl)
var out = dump()
console.log('langs:',window.totalLangs,'chars:',window.totalChars)
return out
}
</script>
<style>
p, input, #character, #inputArea { font-size: 200%; }
</style>
</head>
<body>
<p>Create arrays of languages which use a given character</p>
<p>Run this file to create char_lang.js after langs.js file changes. Click on create lists, then copy/paste to the char_langs.js file (in BBEdit!).</p>
<p><button type="submit" onClick="document.getElementById('output').value = create(); document.getElementById('output').select(); return false;">Create lists!</button></p>
<p>
<textarea id="output" style="width: 90%; height: 600px;"></textarea></p>
</body>
</html>