forked from AlexQ6/Goalflix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteamvid.js
executable file
·64 lines (47 loc) · 1.44 KB
/
teamvid.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
function searchVid(name) {
axios
.get("https://www.scorebat.com/video-api/v1/")
.then((response) => {
teamVid(response, name);
})
.catch((err) => console.log(err));
};
function deleteChildren() {
let first = league.firstElementChild;
while (first) {
first.remove();
first = league.firstElementChild;
}
}
let createEle = (response, i) => {
let match = document.createElement("div");
match.className = "highMatch";
let video = document.createElement("div");
video.className = "highVideo";
let teams = document.createElement("p");
teams.className = "highTeams";
league.appendChild(match);
match.appendChild(teams);
match.appendChild(video);
teams.textContent = response.data[i].title;
video.innerHTML = response.data[i].videos[0].embed;
};
let teamVid = (response, name) => {
// console.log(response)
deleteChildren();
for (i in response.data) {
if (matchTeam(response.data[i].side1.name, response.data[i].side2.name, name)) {
createEle(response, i);
}
}
}
let matchTeam = (side1, side2, name) => {
let s1 = side1.toLowerCase().replace(/ fc/g, "")
let s2 = side2.toLowerCase().replace(/ fc/g, "")
let newName = name.toLowerCase().replace(/ fc/g, "")
if (s1 == newName || s2 == newName) {
return true
}
}
const name = new URLSearchParams(window.location.search).get("name")
searchVid(name)