-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathponemonic.html
76 lines (62 loc) · 2.26 KB
/
ponemonic.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>ponemonic</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-fluid">
<p> <a href="http://qinmishu.org" >Qinmishu.org</a> <a href="http://qinmishu.org" >主页</a></p>
<form role="form">
<div class="form-group">
<label for="output">输出:</label>
<textarea class="form-control" rows="6" id="output"></textarea>
</div>
<div class="form-group">
<label for="cmd">输入:</label>
<input type="text" class="form-control" id="cmd">
<input type="button" class="btn btn-info" id="run" value="运行">
</div>
</form>
</div>
<script src="ponemonic.js" type="text/javascript"></script>
<script>
// in case the trim method does not exist in String.
// it was added to standard in latter version of js.
// http://stackoverflow.com/questions/498970/trim-string-in-javascript
if (!String.prototype.trim) {
(function() {
// Make sure we trim BOM and NBSP
var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
String.prototype.trim = function() {
return this.replace(rtrim, '');
};
})();
}
function handleCmd(){
cmd = $("#cmd").val();
cmd = cmd.trim();
if (cmd == ""){
return;
}
//console.log(input);
result = pinyinchinesechar.InputToOutput(cmd);
$("#output").val(result);
}
$("#run").click(handleCmd);
$("#output").val(pinyinchinesechar.DigitToConsonantTable());
//handle enter key
jQuery('#cmd').on("keypress", function (e) {
if (e.keyCode == 13) {
// Cancel the default action on keypress event
e.preventDefault();
handleCmd();
}
});
</script>
</body>
</html>