-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
95 lines (76 loc) · 3.58 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<link rel="shortcut icon" href="./imgs/favicon.png" type="image/png">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/brands.min.css"
integrity="sha512-nS1/hdh2b0U8SeA8tlo7QblY6rY6C+MgkZIeRzJQQvMsFfMQFUKp+cgMN2Uuy+OtbQ4RoLMIlO2iF7bIEY3Oyg=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<title>Pirate Assistant</title>
</head>
<body>
<nav class="navbar">
<p class="nav-head">Pirate Assistant</p>
<p class="nav-text">Convert from English to Pirate speak. Shiver me timbers! I be needin' t' send 'em all to Davy
Jones' locker. Arrrrr! Anyway go ahead and translate and have some fun!</p>
</nav>
<div class="img-container"><img src="./imgs/pirate.gif" alt="not found"></div>
<div class="display-div">
<textarea placeholder="please enter the text you want to convert" id="input-text"></textarea>
<div class="btn">
<button id="translate-btn">Assist to Pirate</button>
<button id="clear-btn">Clear</button>
</div>
<div id="output-text">
</div>
</div>
<footer class="footer">
<p class="footer-text">Made with 💖 by Aritra Chowdhury</p>
<div class="icons">
<a href="https://t.me/Aritra_chowdhury" target="_blank"><img src="./imgs/icons8-telegram-app.svg" alt=""
style="margin:20px; cursor: pointer"></a>
<a href="https://www.instagram.com/aritra_papan/" target="_blank"><img src="./imgs/icons8-instagram.svg" alt=""
style="margin:20px; cursor: pointer"></a>
<a href="https://www.facebook.com/home.php" target="_blank"><img src="./imgs/icons8-facebook.svg" alt=""
style="margin:20px; cursor: pointer"></a>
<a href="https://github.com/Aritra-art" target="_blank"><img src="./imgs/icons8-github-50.png" alt=""
style="margin:20px; cursor: pointer"></a>
</div>
</footer>
</body>
<script>
const inputText = document.querySelector('#input-text')
const outputText = document.querySelector('#output-text')
const translate = document.querySelector('#translate-btn')
const clear = document.querySelector('#clear-btn')
const error = document.querySelector("#error")
outputText.innerHTML = '<small style="color:gray; letter-spacing:0.1rem;">your converted pirate text would appear here</small>'
const api = "https://api.funtranslations.com/translate/pirate.json"
const constructApi = (text) => `${api}?text=${text}`
const translateEventHandler = () => {
if (inputText.value) {
outputText.textContent = 'Translation is in progress ... '
fetch(constructApi(inputText.value))
.then(response => response.json())
.then(json =>
outputText.textContent = json.contents.translated
)
.catch((error) => {
console.log(error)
return (outputText.innerHTML = '<small style="color:red;">There is a internal server error. please try again later 😔...</small>')
});
} else {
outputText.innerHTML = '<small style="color:red; font-style:italic;">please enter a text to convert !!</small>'
}
}
const clearEventHandler = () => {
inputText.value = '';
outputText.innerHTML = '<small style="color:gray; letter-spacing:0.1rem;">your converted pirate text would appear here</small>'
}
translate.addEventListener('click', translateEventHandler);
clear.addEventListener('click', clearEventHandler);
</script>
</html>