forked from WPPlugins/wp-chinese-conversion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert.html
89 lines (86 loc) · 3.23 KB
/
convert.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Chinese Conversion</title>
<style type="text/css">
body {
margin: 0 auto; width: 900px;
}
.general {
margin-top: 20px;
}
</style>
</head>
<body>
<div id="wrapper" class="general">
<form action="convert.php" method="post" id="form1">
<label for="data">Original Text: </label><br />
<textarea name="data" id="data" rows="20" cols="100"></textarea><br />
<label for="variant">Convert to: </label>
<select id="variant" name="variant" >
<option value="zh-hans">简体中文 (zh-hans)</option>
<option value="zh-hant">繁體中文 (zh-hant)</option>
<option value="zh-cn">大陆简体 (zh-cn)</option>
<option value="zh-hk">港澳繁體 (zh-hk)</option>
<option value="zh-mo">澳門繁體 (zh-mo)</option>
<option value="zh-sg">马新简体 (zh-sg)</option>
<option value="zh-my">马来西亚简体 (zh-my)</option>
<option value="zh-tw">台灣正體 (zh-tw)</option>
</select><br />
<input type="hidden" name="dochineseconversion" value="1" />
<input type="submit" id="s" name="submit" value="Submit (Ctrl + Enter)" class="general" />
</form>
<div id="error" class="general"></div>
<div id="return" style="display: none" class="general">
<label for="response">Converted Text: </label><br />
<textarea id="response" rows="20" cols="100"></textarea><br />
</div><br />
</div>
<script type="text/javascript" >
/* <![CDATA[ */
document.forms[0].onsubmit = function() {
if(XMLHttpRequest) {var ajax = new XMLHttpRequest();}
else { var ajax = new ActiveXObject("Microsoft.XMLHTTP"); }
ajax.onreadystatechange = function() {
if( ajax.readyState == 4 ) {
if(ajax.status == 200 ) {
document.getElementById("response").value = ajax.responseText;
document.getElementById("return").style.display = "block";
document.getElementById("error").innerHTML = "";
}
else {
document.getElementById("error").innerHTML = "Error, please try again.";
}
}
}
var t = 'dochineseconversion=1&variant=' +
( document.getElementById("variant").options[document.getElementById("variant").selectedIndex].value || document.getElementById("variant").options[document.getElementById("variant").selectedIndex].text ) +
'&data=' + encodeURIComponent(document.getElementById("data").value);
document.getElementById("error").innerHTML = "Loading...";
ajax.open("POST", 'convert.php', true);
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send(t);
return false;
}
var isCtrl = false;
document.onkeydown = function(e) {
if(typeof(e) == "undefined") e = window.event || window.Event;
if( (e.which || e.keyCode) == 17 ) isCtrl = true;
}
document.onkeyup = function(e) {
if(typeof(e) == "undefined") e = window.event || window.Event;
if( isCtrl &&
( (e.which || e.keyCode) == 13 || (e.which || e.keyCode) == 10 )
) {
if( typeof(e.preventDefault) != "undefined" ) e.preventDefault();
document.getElementById("s").click();
isCtrl = false;
return false;
}
isCtrl = false;
}
/* ]]> */
</script>
</body>
</html>