-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
89 lines (75 loc) · 2.54 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
console.clear();
const tableRow = document.querySelectorAll(".list__row");
const overlay = document.querySelector(".overlay");
const sidebar = document.querySelector(".sidebar");
const closeOverlayBtn = document.querySelector(".button--close");
const sidebarClose = () => {
sidebar.classList.remove("is-open");
overlay.style.opacity = 0;
setTimeout(() => {
overlay.classList.remove("is-open");
overlay.style.opacity = 1;
}, 300);
};
tableRow.forEach(tableRow => {
tableRow.addEventListener("click", function () {
overlay.style.opacity = 0;
overlay.classList.add("is-open");
sidebar.classList.add("is-open");
setTimeout(() => {
overlay.style.opacity = 1;
}, 100);
// Sidebar content
const sidebarBody = document.querySelector(".sidebar__body");
sidebarBody.innerHTML = '';
const driverPlace = this.querySelector(".list__cell:nth-of-type(1) .list__value").innerHTML;
const driverName = this.querySelector(".list__cell:nth-of-type(2) .list__value").innerHTML;
const driverPoints = this.querySelector(".list__cell:nth-of-type(3) .list__value").innerHTML;
const driverImage = this.dataset.image;
const Teamlid = this.dataset.teamlid;
const Developers = this.dataset.developers;
const newDriver = document.createElement('div');
newDriver.classList = 'driver';
const driverContent = document.createElement('div');
driverContent.classList = 'driver__content';
const profile = document.createElement('div');
profile.classList = 'driver__image';
profile.style.backgroundImage = `url('${driverImage}')`;
newDriver.appendChild(profile);
const driverTitle = document.createElement('div');
driverTitle.classList = 'driver__title';
driverTitle.innerHTML = driverName;
driverContent.appendChild(driverTitle);
const driverInfo = document.createElement('div');
driverInfo.innerHTML = `
<table class="driver__table">
<tbody>
<tr>
<td><small>Teamlid</small></td>
<td>${Teamlid}</td>
</tr>
<tr>
<td><small>Developers:</small></td>
<td>${Developers}</td>
</tr>
<tr>
<td><small>Place</small></td>
<td>${driverPlace}</td>
</tr>
<tr>
<td><small>Points</small></td>
<td>${driverPoints}</td>
</tr>
</tbody>
</table>`;
driverContent.appendChild(driverInfo);
newDriver.appendChild(driverContent);
sidebarBody.appendChild(newDriver);
});
});
closeOverlayBtn.addEventListener("click", function () {
sidebarClose();
});
overlay.addEventListener("click", function () {
sidebarClose();
});