-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.html
79 lines (67 loc) · 2.42 KB
/
check.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
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Cultural Connector</title>
<link rel="stylesheet" href="style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"/>
</head>
<body>
<div class="nav">
<img src="translating.png" alt="campfire" class="logo" >
<ul>
<li><a href="about.html">about us</a></li>
<li><a href="contact.html">contact</a></li>
</ul>
</div>
<div class="container ">
<div class="wrapper">
<div class="text-input">
<textarea spellcheck="false" class="from-text" id="englishInput" placeholder="Enter text"></textarea>
<textarea spellcheck="false" readonly disabled class="to-text" id="hindiOutput" Translation"></textarea>
</div>
<div class="converter">
<a href="index.html" class="con">Click here for English</a>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$('#englishInput').keypress(function (e) {
// key code
var key = (e.keyCode ? e.keyCode : e.which);
if(key == 13) // the enter key code
{
$('#englishInput').val($('#hindiOutput').text());
$('#hindiOutput').text('')
$('.select-option').hide();
// return false;
}
else{
$('.select-option').show();
}
const englishText = $('#englishInput').val();
$.ajax({
url: `https://translate.googleapis.com/translate_a/single?client=gtx&sl=hi&tl=en&dt=t&q=${encodeURI(englishText)}`,
success: function(result) {
if(result[0] != undefined && result[0] != null)
{
const hindiText = result[0][0][0];
$('#hindiOutput').text(hindiText);
}
else{
$('#hindiOutput').text('');
}
}
});
});
$(document).on("click", ".select-option", function(){
$('#englishInput').val($('#hindiOutput').text());
$('#hindiOutput').text('')
})
</script>
<script src="countries.js"></script>
<script src="script.js"></script>
</body>
</html>