-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
336 lines (290 loc) · 11.6 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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<!DOCTYPE html>
<html lang="en">
<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="https://unpkg.com/[email protected]/dist/paper.min.css">
<title>Baybayin</title>
</head>
<body>
<div class="paper container">
<h1 align="center">Baybayin <span class="badge secondary">Converter</span></h1>
<div class="row flex-middle">
<div class="sm-6 col">
<div class="form-group">
<label for="modal-1">Modernong baybay</label>
<textarea class="no-resize input-block shadow shadow-hover" placeholder="Baybayin" id="modernSpelling" oninput="modernToBaybayin()"></textarea>
</div>
<button class="btn-block" onclick="copyToClp('modernSpelling')">Kopyahin</button>
</div>
<div class="sm-6 col">
<div class="form-group">
<label>Baybayin</label>
<textarea class="no-resize input-block shadow shadow-hover baybayin-display" placeholder="ᜊᜌ᜔ᜊᜌᜒᜈ᜔" id="baybay" oninput="baybayinToModern()"></textarea>
</div>
<button class="btn-block" onclick="copyToClp('baybay')">Kopyahin</button>
</div>
<div class="alert alert-secondary" id="unsupportedDiv" style="display:none"><p align="center">May ilang mga titik na hindi suportado.</p></div>
<div class="collapsible sm-12 col">
<input id="collapsible1" type="checkbox" name="collapsible">
<label for="collapsible1">Show Baybayin Chart</label>
<div class="collapsible-body">
<div class="row ">
<div class="sm-6 col">
<table>
<thead>
<tr>
<th>Titik</th>
<th>Base</th>
</tr>
</thead>
<tbody>
<tr>
<td>a</td>
<td>ᜀ</td>
</tr>
<tr>
<td>e/i</td>
<td>ᜁ</td>
</tr>
<tr>
<td>o/u</td>
<td>ᜂ</td>
</tr>
</tbody>
</table>
<div class="alert alert-secondary"><p align="center">Walang idaragdag kung ang kasunod ng katinig ay a. Magdagdag ng kudlit sa itaas ng katinig kapag ang kasunod nito ay e/i. Magdagdag ng kudlit sa ibaba ng katinig kapag ang kasunod nito ay o/u. Kapag ang katinig ay walang kasunod, magdagdag ng ekis sa ilalim nito.
</p> <p align="center" class="paragraph-w-baybayin">Halimbawa: ka - <span>ᜃ</span>, ki - <span>ᜃᜒ</span>, ku - <span>ᜃᜓ</span>, k - <span>ᜃ᜔</span> </p></div>
</div>
<div class="sm-6 col">
<table>
<thead>
<tr>
<th>Titik</th>
<th>Base</th>
</tr>
</thead>
<tbody>
<tr>
<td>b/v</td>
<td>ᜊ</td>
</tr>
<tr>
<td>k</td>
<td>ᜃ</td>
</tr>
<tr>
<td>d/r</td>
<td>ᜇ</td>
</tr>
<tr>
<td>f</td>
<td>ᜉ</td>
</tr>
<tr>
<td>g</td>
<td>ᜄ</td>
</tr>
<tr>
<td>h</td>
<td>ᜑ</td>
</tr>
<tr>
<td>l</td>
<td>ᜎ</td>
</tr>
<tr>
<td>m</td>
<td>ᜋ</td>
</tr>
<tr>
<td>n</td>
<td>ᜈ</td>
</tr>
<tr>
<td>p</td>
<td>ᜉ</td>
</tr>
<tr>
<td>s/z</td>
<td>ᜐ</td>
</tr>
<tr>
<td>t</td>
<td>ᜆ</td>
</tr>
<tr>
<td>w</td>
<td>ᜏ</td>
</tr>
<tr>
<td>y</td>
<td>ᜌ</td>
</tr>
<tr>
<td>ng</td>
<td>ᜅ</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<h6 align="center" id='mouse_over'>Gawa ni rebenely sa araw ni Manuel L. Quezon. Gumamit ng PaperCSS.<h6>
<h6 align="center" id='mouse_over'>Binisita muli sa sunod na taon, buwan din ng wika. Ang dumi ng code ko hahahahahah. Marami akong bagong natutunan mula noong gawin ko 'to.<h6>
</div>
<style>
#mouse_over {
opacity: 0;
}
#mouse_over:hover {
opacity: 1;
}
@font-face {
font-family: 'noto';
src: url('NotoSansTagalog-Regular.ttf');
}
.baybayin-display {
font-family: 'noto';
}
td:nth-child(2) {
font-family: 'noto';
}
.paragraph-w-baybayin span {
font-family: 'noto';
}
</style>
<script>
function modernToBaybayin() {
var inputText = document.getElementById("modernSpelling").value;
inputText = inputText.toLowerCase();
var outputText = "";
var format = /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]+/;
var vowel = {'a' : 'ᜀ', 'e' : 'ᜁ', 'i' : 'ᜁ', 'o' : 'ᜂ' , 'u' : 'ᜂ'};
var consonant = { 'b' : 'ᜊ', 'k' : 'ᜃ', 'd' : 'ᜇ', 'f': 'ᜉ', 'g' : 'ᜄ', 'h' : 'ᜑ', 'l' : 'ᜎ', 'm' : 'ᜋ', 'n' : 'ᜈ', 'p' : 'ᜉ', 'r' : 'ᜇ', 's' : 'ᜐ', 't' : 'ᜆ', 'v' : 'ᜊ', 'w' : 'ᜏ', 'y' : 'ᜌ', 'z' : 'ᜐ' }
var supportedAll = true;
for (var i = 0; i < inputText.length ; i++) {
var current = inputText.charAt(i);
var next = inputText.charAt(i+1);
console.log(current);
if(!(current in consonant) && !(current in vowel) && current !== ' ') {
supportedAll = false;
}
if (current in vowel) {
outputText += vowel[current];
} else {
if(current === 'n' && next === 'g') {
outputText += 'ᜅ'; /// ng
var nextChar = inputText.charAt(i+2);
i += 1;
if (nextChar === 'a') {
// do nothing
i += 1;
} else if (nextChar === 'e' || nextChar === 'i') {
outputText += 'ᜒ';
i += 1;
} else if (nextChar === 'o' || nextChar === 'u') {
outputText += 'ᜓ';
i += 1;
} else { //consonant or space
outputText += '᜔';
}
} else {
if(!(current in consonant)){
outputText += current;
} else {
outputText += consonant[current];
if (next === 'a') {
// do nothing
i += 1;
} else if (next === 'e' || next === 'i') {
outputText += 'ᜒ';
i += 1;
} else if (next === 'o' || next === 'u') {
outputText += 'ᜓ';
i += 1;
} else { //consonant or space
outputText += '᜔';
}
}
}
}
}
var x = document.getElementById("unsupportedDiv");
if(supportedAll) {
x.style.display = "none";
} else {
x.style.display = "block";
}
document.getElementById("baybay").value = outputText;
}
function swap(json){
var ret = {};
for(var key in json){
ret[json[key]] = key;
}
return ret;
}
function baybayinToModern() {
var inputText = document.getElementById("baybay").value;
var outputText = "";
inputText = inputText.toLowerCase();
var format = /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]+/;
var vowel = {'a' : 'ᜀ', 'e' : 'ᜁ', 'i' : 'ᜁ', 'o' : '' , 'u' : 'ᜂ'};
vowel = swap(vowel);
var consonant = { 'b' : 'ᜊ', 'k' : 'ᜃ', 'd' : 'ᜇ', 'g' : 'ᜄ', 'h' : 'ᜑ', 'l' : 'ᜎ', 'm' : 'ᜋ', 'n' : 'ᜈ', 'p' : 'ᜉ', 's' : 'ᜐ', 't' : 'ᜆ', 'w' : 'ᜏ', 'y' : 'ᜌ', 'ng': 'ᜅ' }
consonant = swap(consonant);
var supportedAll = true;
for (var i = 0; i < inputText.length ; i++) {
var current = inputText.charAt(i);
var next = inputText.charAt(i+1);
console.log(current);
if(!(current in consonant) && !(current in vowel) && current !== ' ') {
supportedAll = false;
}
if (current in vowel) {
outputText += vowel[current];
} else {
if(!(current in consonant)){
console.log(current + 'ayy' )
outputText += current;
} else {
console.log(current +' = '+consonant[current])
outputText += consonant[current];
if (next === 'ᜒ') {
outputText += 'i';
i += 1;
} else if (next === 'ᜓ') {
outputText += 'o';
i += 1;
} else if (next === '᜔') { //consonant or space
outputText += '';
i += 1;
} else {
outputText += 'a';
}
}
}
}
var x = document.getElementById("unsupportedDiv");
if(supportedAll) {
x.style.display = "none";
} else {
x.style.display = "block";
}
document.getElementById("modernSpelling").value = outputText;
}
function copyToClp(elementId) {
/* Get the text field */
var copyText = document.getElementById(elementId);
/* Select the text field */
copyText.select();
/* Copy the text inside the text field */
document.execCommand("copy");
}
</script>
</body>
</html>