-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtranslate.html
67 lines (56 loc) · 1.73 KB
/
translate.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
<html>
<head>
<script src="https://cdn.firebase.com/js/client/2.2.1/firebase.js"></script>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js'></script>
<script src='javascripts/microsoftTranslator.js'></script>
<script src='javascripts/translationRouter.js'></script>
<link rel="stylesheet" type="text/css" href="css/old_css.css">
</head>
<body>
<!-- CHAT MARKUP -->
<div class="example-chat l-demo-container">
<header>translate to korean</header>
<div class='example-chat-toolbar'>
<label for="textInput">text:</label>
<input type='text' id='textInput' placeholder='text to translate...'>
<input type='button' id='translate' value='translate'>
</div>
<ul id='example-messages' class="example-chat-messages"></ul>
</div>
<script type="text/javascript">
var translateButton = $('#translate');
var textInput = $('#textInput');
translateButton.click(function() {
doTranslation();
});
textInput.keypress(function (e) {
// on r
if (e.keyCode == 13) {
doTranslation();
};
});
function mycallback(response)
{
//alert(response);
insertTranslation(response);
}
function doTranslation() {
if (textInput.val()) {
//Translator.translate(textInput.val(), 'en', 'ko', 'insertTranslation');
Translator.translate(textInput.val(), 'en', 'ko', insertTranslation);
textInput.val('');
}
};
var messageList = $('#example-messages');
//insert to page
function insertTranslation(message) {
var messageElement = $("<li>");
// var nameElement = $("<strong class='example-chat-username'></strong>")
// nameElement.text(username);
messageElement.text(message);
//ADD MESSAGE
messageList.append(messageElement);
}
</script>
</body>
</html>