forked from lojban/ilmentufa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcamxes-dyn.html
131 lines (119 loc) · 4.77 KB
/
camxes-dyn.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
<!doctype html>
<html>
<body>
<meta charset='utf-8' />
<span style="font: 15px arial, sans-serif;">Type any Lojban text in the following textarea. The result will be parsed as you type:</span>
<br /><br />
<form id="form1" name="form1" method="post" action="" style="width:100%">
<textarea id="input_textarea" style="width:100%" rows="8" autofocus></textarea>
<br />
<span style="font: 15px arial, sans-serif;">Output mode: </span>
<select id="optlist" onChange="run_camxes()">
<option>Raw output</option>
<option>Condensed</option>
<option id="default">Prettified</option>
<option>Prettified + selmaho</option>
<option>Prettified + sm ext</option>
<option>Prettified --fm</option>
<option>Prettified --fm + selmaho</option>
<option>Prettified --fm + sm ext</option>
</select>
<select id="morpho-mode" onChange="run_camxes();">
<option>Remove morphology</option>
<option>Keep morphology</option>
</select>
<select id="spaces-display-mode" onChange="run_camxes();">
<option>Hide spaces</option>
<option>Display spaces as '_'</option>
</select>
<span style="padding-left: 24px; text-align: right; font: 15px arial, sans-serif;">Parser: </span>
<select id="parser" onChange="load_parser();">
<option>Camxes: Standard</option>
<option>Camxes: Beta</option>
<option>Camxes: Beta CBM</option>
<option>Camxes: Beta CBM CKT</option>
<option>Camxes: Experimental</option>
<option>Zantufa</option>
<!-- <option>Altatufa</option>
<option>Spagetufa</option> -->
<option>Camxes: Hagiwara</option>
</select>
<script>
var parser_list = [
["camxes.js", "camxes.peg"],
["camxes-beta.js", "camxes-beta.peg"],
["camxes-beta-cbm.js", "camxes-beta-cbm.peg"],
["camxes-beta-cbm-ckt.js", "camxes-beta-cbm-ckt.peg"],
["camxes-exp.js", "camxes-exp.js.peg"],
["http://guskant.github.io/gerna_cipra/js/zantufa-1.js", "http://guskant.github.io/gerna_cipra/zantufa-1.js.peg"],
// ["https://github.com/lagleki/glekitufa/mahantufa/altatufa.js", "https://github.com/lagleki/glekitufa/mahantufa/altatufa.js.peg"],
// ["https://github.com/mezohe/ilmentufa/camxes-exp.js", "https://github.com/mezohe/ilmentufa/camxes-exp.js.peg"],
["camxes-mh.js", "camxes-mh.js.peg"]
];
</script>
<span style="padding-left: 24px; text-align: right; font-size: 12px;">
<a href="camxes.pegjs" target="_blank" id="peg-link">[ Grammar file ]</a>
</span>
</form>
<div style="display:block; overflow: scroll; max-height:24em; border: solid 1px; padding: 10px; background-color: #DDDDFF;"
height="24em">
<pre style="white-space: pre-wrap;"><code id="parse_result" width="100%" height="100%"> </code></pre>
</div>
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<!--
<script type="text/javascript" src="camxes.js"></script>
-->
<script type="text/javascript" src="camxes_preproc.js"></script>
<script type="text/javascript" src="camxes_postproc.js"></script>
<script>
document.getElementById("default").defaultSelected = true;
window.onload = load_parser;
var has_first_parser_been_loaded = false;
function load_parser() {
var i = document.getElementById("parser").selectedIndex;
document.getElementById("peg-link").href = parser_list[i][1];
var getscript_callback = function( data, textStatus, jqxhr ) {
if ( textStatus === "success" ) run_camxes();
};
$.getScript( parser_list[i][0], getscript_callback )
.done(function( script, textStatus ) {
if ( textStatus === "success" ) has_first_parser_been_loaded = true;
})
.fail(function( jqxhr, settings, exception ) {
alert( "load_parser(): " + exception );
});
run_camxes();
}
/*
* Binding the function run_camxes() to keyup event on input_textarea by using jQuery
*/
$('#input_textarea').bind( "keyup",
function(e) {
run_camxes();
} );
function run_camxes() {
if (!has_first_parser_been_loaded) return;
try {
var input = $('#input_textarea').val();
input = camxes_preprocessing(input);
var result = camxes.parse(input);
} catch (e) {
$('#parse_result').text(e.toString());
return;
}
/* We get the output mode selected in the combobox */
var mode = document.getElementById("optlist").selectedIndex;
/* Get the parse tree processing selected in the second combobox */
if (1 == document.getElementById("morpho-mode").selectedIndex)
mode |= 16;
var b_display_spaces = (1 == document.getElementById("spaces-display-mode").selectedIndex);
if (b_display_spaces) mode |= 8;
/* Postprocessing: if mode == 0, the below function won't modify camxes' output */
result = camxes_postprocessing(result, mode);
// @ camxes_postproc.js
/* Retrieve the result */
$('#parse_result').text(result);
}
</script>
</body>
</html>