-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinvites.html
132 lines (119 loc) · 3.68 KB
/
invites.html
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<html>
<body>
<div style="display: inline; padding-left: 30%">
<label
style="color: green; padding-right: 30px"
id="total-confirmed-attending"
></label>
<label
style="color: blue; padding-right: 30px"
id="total-not-answered"
></label>
<label
style="color: lightcoral; padding-right: 30px"
id="total-confirmed-not-attending"
></label>
<label style="color: black" id="accomodation-needed"></label>
</div>
<br />
<br />
<br />
<table id="invitee" style="border: 1px black; padding-left: 30%">
<thead>
<td>Name</td>
<td>Confirmed</td>
<td>Attending</td>
<td>Invitation link</td>
<td style="width: 400px">Message</td>
<td>Accomodation needed</td>
</thead>
<tbody id="t-body"></tbody>
</table>
</body>
</html>
<script>
fetch(
""
).then((s) => s.json().then((k) => doStuff(k)));
function doStuff(response) {
let invitesJson = response;
var invites = invitesJson;
var tbody = document.getElementById("t-body");
var finalHtml = "";
var totalConfirmedAttending = 0;
var totalUnanswered = 0;
var totalConfirmedNotAttending = 0;
var accomodationNeeded = 0;
invites.forEach((invitee) => {
var guests = invitee.guests;
accomodationNeeded +=
invitee.accommodationNeeded && invitee.attending && invitee.confirmed
? 1
: 0;
var message = invitee.message ?? "";
var messageCount = 0;
guests.forEach((guest, index) => {
if (guest.name) {
var color = "";
if (
guest.isComming &&
invitee.attending &&
invitee.confirmed &&
!guest.isChild
) {
totalConfirmedAttending++;
color = "chartreuse";
} else if (
(!guest.isComming || !invitee.attending) &&
invitee.confirmed
) {
totalConfirmedNotAttending++;
color = "lightcoral";
} else if (!invitee.confirmed) {
totalUnanswered++;
color = "yellow";
}
finalHtml +=
'<tr style="background-color:' +
color +
'">' +
"<td>" +
guest.name +
"</td>" +
"<td>" +
invitee.confirmed +
"</td>" +
"<td>" +
(invitee.attending && guest.isComming) +
"</td>" +
'<td> <a target="_blank" href="' +
"http://alexcristina-wedding.info?id=" +
invitee.id +
'"> link </a>' +
"</td>" +
"<td>" +
(index == 0 ? message : "") +
"</td>" +
"<td>" +
(index == 0 &&
invitee.accommodationNeeded &&
invitee.attending &&
invitee.confirmed
? "yes"
: "") +
"</td>" +
"</tr>";
}
});
});
tbody.innerHTML = finalHtml;
document.getElementById("total-confirmed-attending").innerHTML =
"Total confirmed attending => " + totalConfirmedAttending;
document.getElementById("total-not-answered").innerHTML =
"Total unanswered => " + totalUnanswered;
document.getElementById("total-confirmed-not-attending").innerHTML =
"Total confirmed NOT attending => " + totalConfirmedNotAttending;
document.getElementById("accomodation-needed").innerHTML =
"Total accomodation needed " + accomodationNeeded;
}
</script>