-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
92 lines (72 loc) · 2.76 KB
/
script.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
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
"use strict";
const button = document.getElementById("button")
const beachVideo = document.getElementById("beachVideo");
const beachAudio = document.getElementById("beachAudio");
const topLid = document.getElementById("topLid");
const bottomLid = document.getElementById("bottomLid");
const firstPhrase = document.getElementById("firstPhrase");
const secondPhrase = document.getElementById("secondPhrase");
const thirdPhrase = document.getElementById("thirdPhrase");
const fourthPhrase = document.getElementById("fourthPhrase");
const inputPanel = document.getElementById("inputPanel");
document.addEventListener("DOMContentLoaded", async() => {
console.log("SUUUUUUP");
button.addEventListener('click', () => {
button.classList.add('buttonBegone');
button.addEventListener('animationend', () => {
button.style.display = 'none';
firstPhrase.classList.add('fadeInOut');
beachAudio.play();
});
});
firstPhrase.addEventListener('animationend', () => {
secondPhrase.classList.add('fadeInOut');
});
secondPhrase.addEventListener('animationend', () => {
thirdPhrase.classList.add('fadeInOut');
});
thirdPhrase.addEventListener('animationend', () => {
fourthPhrase.classList.add('fadeInOut');
});
fourthPhrase.addEventListener('animationend', () => {
beachVideo.classList.add('clearVideo');
topLid.classList.add('topOpen');
bottomLid.classList.add('bottomOpen');
});
topLid.addEventListener('animationend', () => {
topLid.classList.add('fullyOpen');
});
bottomLid.addEventListener('animationend', () => {
bottomLid.classList.add('fullyOpen');
});
beachVideo.addEventListener('animationend', () => {
inputPanel.classList.add('appear');
});
const itemsResponse = await fetch ('http://localhost:8000/items');
const items = await itemsResponse.json();
const itemsEl = document.querySelector('#showItems');
items.map((id) => {
const paragraph = document.createElement('p');
paragraph.innerText = id.name;
itemsEl.appendChild(paragraph);
});
const form = document.querySelector("#petForm");
async function sendData() {
const formData = new FormData(form);
const petName = formData.get("dogName")
try {
const response = await fetch("http://localhost:8000/pets/add", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({name: petName}),
});
console.log(await response.json());
} catch (e) {
console.error(e);
}
}
form.addEventListener("submit", (event) => {
event.preventDefault();
sendData();
});
});