-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
29 lines (26 loc) · 1.02 KB
/
app.js
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
import api from "./services/API.js";
import Banner from "./components/Banner.js";
import translate from "./services/Translate.js";
const appBanner = document.createElement("app-banner");
document.querySelector("body").insertAdjacentElement("afterbegin", appBanner);
window.app = Object.create({
api,
services: {
translate,
},
});
window.addEventListener("DOMContentLoaded", () => {
const form = document.querySelector(".form-boundary");
let translation;
form.addEventListener("submit", async (event) => {
event.preventDefault();
const textToTranslate = document.querySelector("#user-input").value;
const language = document.querySelector("#language").value;
const translationHTML = document.querySelector("#translation");
const buttonHTML = document.querySelector("button");
buttonHTML.innerText = "translating...";
translation = await translate(language, textToTranslate);
translationHTML.insertAdjacentText("afterbegin", translation);
buttonHTML.innerText = "translate again";
});
});