generated from CodeYourFuture/tv-show-dom-project
/
htmlelements.js
89 lines (74 loc) · 3.89 KB
/
htmlelements.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
const rootElem = document.getElementById("root");
let navbarContainer = document.createElement("div");
navbarContainer.classList.add("navbar-container");
let searchBarContainer = document.createElement("div");
searchBarContainer.classList.add("searchbar-container");
let selectEpisodeContainer = document.createElement("div");
selectEpisodeContainer.classList.add("selectepisode-container");
const episodeSection = document.createElement("section");
let selectGenreContainer = document.createElement("div");
selectGenreContainer.classList.add("selectepisode-container");
let selectShowContainer = document.createElement("div");
selectShowContainer.classList.add("selectepisode-container");
let episodeContainer = document.createElement("div");
let selectEpisode = document.createElement("select");
let selectShow = document.createElement("select");
let selectGenre = document.createElement("select");
let defaultOptionSelectEpisode = document.createElement("option");
let defaultOptionSelectShow = document.createElement("option");
let defaultOptionSelectGenre = document.createElement("option");
defaultOptionSelectEpisode.innerText = "Please choose an episode";
defaultOptionSelectShow.innerText = "Please choose a show";
defaultOptionSelectGenre.innerText = "Choose your genre";
selectEpisode.appendChild(defaultOptionSelectEpisode);
selectShow.appendChild(defaultOptionSelectShow);
selectGenre.appendChild(defaultOptionSelectGenre);
const labelSearchInput = document.createElement("label");
const labelSelectEpisode = document.createElement("label");
const labelSelectShow = document.createElement("label");
const labelSelectGenre = document.createElement("label");
selectEpisode.classList.add("select-episode");
labelSearchInput.innerText = "Search your show/episode";
labelSearchInput.classList.add("label-searchinput");
labelSelectEpisode.innerText = "Choose your episode";
labelSelectEpisode.classList.add("label-selectepisode");
selectShow.classList.add("select-episode");
labelSelectShow.innerText = "Choose your Show";
labelSelectShow.classList.add("label-selectepisode");
selectGenre.classList.add("select-episode");
labelSelectGenre.innerText = "Choose your genre";
labelSelectGenre.classList.add("label-selectepisode");
const searchInput = document.createElement("input");
navbarContainer.appendChild(selectGenreContainer);
navbarContainer.appendChild(selectShowContainer);
navbarContainer.appendChild(selectEpisodeContainer);
navbarContainer.appendChild(searchBarContainer);
searchBarContainer.appendChild(labelSearchInput);
searchBarContainer.appendChild(searchInput);
selectEpisodeContainer.appendChild(labelSelectEpisode);
selectEpisodeContainer.appendChild(selectEpisode);
selectShowContainer.appendChild(labelSelectShow);
selectShowContainer.appendChild(selectShow);
selectGenreContainer.appendChild(labelSelectGenre);
selectGenreContainer.appendChild(selectGenre);
let displayAllEpisodesButton = document.createElement("button");
displayAllEpisodesButton.innerText = "All episodes";
displayAllEpisodesButton.classList.add("display-all-button");
navbarContainer.appendChild(displayAllEpisodesButton);
let displayAllShowsButton = document.createElement("button");
displayAllShowsButton.innerText = "All shows";
displayAllShowsButton.classList.add("display-all-button");
navbarContainer.appendChild(displayAllShowsButton);
rootElem.appendChild(navbarContainer);
rootElem.appendChild(episodeContainer);
searchInput.classList.add("search-input");
const searchTotal = document.createElement("p");
searchTotal.classList.add("search-total");
navbarContainer.appendChild(searchTotal);
let footerContainer = document.createElement("footer");
rootElem.appendChild(footerContainer);
let linkElement = document.createElement("a");
footerContainer.appendChild(linkElement);
linkElement.setAttribute("href", "https://www.tvmaze.com/");
linkElement.innerText = "Data on this site is taken from TV MAZE API";
footerContainer.classList.add("footer-container");