-
Notifications
You must be signed in to change notification settings - Fork 4
/
leftScorecard.js
56 lines (51 loc) · 1.95 KB
/
leftScorecard.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
class LeftScorecard {
constructor() {
this.prevLength = passengersInCar.length;
}
update() {
for (var i = 0; i < passengersInCar.length; i++) {
passengersInCar[i].patience -= 2;
}
if (passengersInCar.length > 0) {
var nextDestination = passengersInCar[0].destination;
if (typeof nextDestination !== 'undefined' && nextDestination != null)
$(".bg").css('background-image', 'url(assets/images/places/' + nextDestination + '.jpg)')
else
$(".bg").css('background-image', 'url(assets/images/places/Blank.jpg)')
}
else {
$(".bg").css('background-image', 'url(assets/images/places/Blank.jpg)')
}
}
animateFrindsInCar() {
$("#friendsInCar").addClass("animate__flash");
}
animateNotice() {
$("#notice").addClass("animate__slideInDown");
}
show() {
var html = `
<div class="row animate__animated my-1" id="friendsInCar">
<div class="col-8">Friends in Car:</div>
<div class="col-4 text-right">${passengersInCar.length} / 2</div>
</div>`;
if (passengersInCar.length > 0) {
html += `<div class="my-1">Next Destinations:</div>`;
}
for (var i = 0; i < passengersInCar.length; i++) {
html += `
<div class="row my-1">
<div class="col-4 mr-1">${passengersInCar[i].destination}</div>
<div class="col-6 per-parent">
<div class="per-wrapper" style="width: ${passengersInCar[i].patience}%"> </div>
</div>
<div class="col-1">${passengersInCar[i].patience}</div>
</div>`;
}
$('#leftDiv').html(html);
if (leftScorecard.prevLength != passengersInCar.length) {
leftScorecard.prevLength = passengersInCar.length;
leftScorecard.animateFrindsInCar();
}
}
}