-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.js
78 lines (66 loc) · 2.02 KB
/
ui.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
class UI {
static addFilmToUI(newFilm) {
/*
<tr>
<td><img src="" class="img-fluid img-thumbnail"></td>
<td></td>
<td></td>
<td><a href="#" id="delete-film" class="btn btn-danger">Filmi Sil</a></td>
</tr>
<tr>
<td><img src="" class="img-fluid img-thumbnail"></td>
<td></td>
<td></td>
<td><a href="#" id="delete-film" class="btn btn-danger">Filmi Sil</a></td>
</tr>
*/
const filmList = document.getElementById("films");
filmList.innerHTML += `
<tr>
<td><img src="${newFilm.url}" class="img-fluid img-thumbnail"></td>
<td>${newFilm.title}</td>
<td>${newFilm.director}</td>
<td><a href="#" id="delete-film" class="btn btn-danger">Filmi Sil</a></td>
</tr>
`;
}
static clearInputs(element1, element2, element3) {
element1.value = "";
element2.value = "";
element3.value = "";
}
static displayMessages(message, type) {
const cardBody = document.querySelector(".card-body");
// Alert div -ni olusturma
const div = document.createElement("div");
div.className = `alert alert-${type}`;
div.textContent = message;
cardBody.appendChild(div);
setTimeout(() => {
div.remove();
}, 750);
}
static loadAllFilms(films) {
const filmList = document.getElementById("films");
films.forEach((newFilm) => {
filmList.innerHTML += `
<tr>
<td><img src="${newFilm.url}" class="img-fluid img-thumbnail"></td>
<td>${newFilm.title}</td>
<td>${newFilm.director}</td>
<td><a href="#" id="delete-film" class="btn btn-danger">Filmi Sil</a></td>
</tr>
`;
});
}
static deleteFilmFromUI(element) {
element.closest("tr").remove();
}
static clearAllFilmsFromUI() {
const filmList = document.getElementById("films");
while (filmList.firstElementChild !== null) {
// Child oldugu surece yani
filmList.firstElementChild.remove();
}
}
}