-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
21 lines (17 loc) · 656 Bytes
/
Copy pathapp.js
File metadata and controls
21 lines (17 loc) · 656 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var InputTxt = document.querySelector('#input-text');
var BtnTranslate = document.querySelector('.primary-btn');
var Output = document.querySelector('.output');
var serverUrl = "https://api.funtranslations.com/translate/dothraki.json"
function getTranslationUrl(input){
return serverUrl + "?" + "text=" + input
}
function clickHandler() {
var inputText = InputTxt.value
fetch(getTranslationUrl(inputText))
.then(response => response.json())
.then(json => {
var translatedText = json.contents.translated;
Output.innerText = translatedText;
});
};
BtnTranslate.addEventListener("click", clickHandler)