-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
103 lines (94 loc) · 4.63 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<link href='https://fonts.googleapis.com/css?family=Droid+Sans' rel='stylesheet' type='text/css'>
<style>
body {
font-family: "Droid Sans";
}
</style>
</head>
<body>
<div align="center" style="margin-top: 20px;">
<h1>USA National Tally</h1>
<div style="display: block">
<span id="current-count"></span> currently of <span id="truth-count"></span> counted in <span class="last-count-year"></span>, across <span id="regions-count"></span> regions, which is ~<span id="pct-total"></span>% of the meetings in the USA.
<h5><a href="map.html">Map Search Demo</a><br><a href="phoneline.html">Nationwide Phoneline</a></h5>
<div id="tally" style="margin-top: 20px"></div>
</div>
</div>
</body>
<script src="croutonjs/crouton.min.js"></script>
<script type="text/javascript">
var lastYearOfTruth = 2020;
var tomatoResults;
var truthTotal = 0;
var truth;
var useTomatoStub = false;
function getServiceBodyById(id) {
for (var i = 0; i < tomatoResults.length; i++) {
var service_body = tomatoResults[i];
if (service_body['url'] === id) {
return service_body;
}
}
return null;
}
function getServiceBodiesFromTomato(page, payload, callback) {
if (payload == null) {
callback([])
}
$.getJSON(useTomatoStub ? "tally/tomatoStub.json" : "https://tomato.bmltenabled.org/main_server/client_interface/json/?switcher=GetServiceBodies", function (data) {
callback(data['results']);
});
}
function getTomatoData() {
$.ajaxSetup({timeout:30000});
getServiceBodiesFromTomato(1, null, function (data) {
tomatoResults = data;
var tallyHtml = "<table border='1'><tr><th>Id</th><th>Service Body</th><th>" + lastYearOfTruth + " Count</th><th>Present Count</th><th>%</th></tr>";
var current_total = 0;
var completedCount = 0;
var pctTotal = 0;
for (var j = 0; j < truth.length; j++) {
var truthItem = truth[j];
truthTotal += truth[j]['count'];
var truthServiceBodyCount = truthItem['count'];
var currentServiceBodyCount = 0;
for (var t = 0; t < truthItem['tomatoIds'].length; t++) {
var tomatoId = truthItem['tomatoIds'][t];
var tomatoServiceBody = getServiceBodyById(tomatoId);
currentServiceBodyCount += tomatoServiceBody !== null ? tomatoServiceBody['num_meetings'] : 0;
}
tallyHtml += "<tr><td>" + (j + 1).toString() + "</td>";
tallyHtml += "<td>" + truthItem['name'] + "</td>";
tallyHtml += "<td>" + truthServiceBodyCount.toString() + "</td>";
tallyHtml += "<td>" + currentServiceBodyCount.toString() + "</td>";
var pct = truthItem['complete'] ? 100 : Math.floor((currentServiceBodyCount / truthServiceBodyCount) * 100);
pctTotal += pct;
tallyHtml += "<td>" + pct.toString() + "</td></tr>";
current_total += currentServiceBodyCount;
completedCount += truthItem['complete'] ? 1 : 0;
}
var pctCalc = Math.floor((pctTotal / truth.length));
tallyHtml += "<tr><td colspan='2'>Totals</td>";
tallyHtml += "<td>" + truthTotal + "</td>";
tallyHtml += "<td>" + current_total + "</td>";
tallyHtml += "<td>" + pctCalc.toString() + "</td></tr></table>";
document.getElementById("tally").innerHTML = tallyHtml;
document.getElementById("current-count").innerText = current_total;
document.getElementById("truth-count").innerText = truthTotal;
document.getElementById("regions-count").innerText = truth.length.toString();
$(".last-count-year").text(lastYearOfTruth.toString());
document.getElementById("pct-total").innerText = pctCalc.toString();
});
}
$.getJSON("tally/" + lastYearOfTruth + ".json", function(data) {
truth = data;
getTomatoData()
});
</script>
<div style="margin-top: 20px; font-size: 10pt;">
This tally will assume that if a root server is fully capturing data that will equal 100% of the tally. In some cases what was reported last will differ than current numbers in Tomato. Although this is included in the total meeting count, the total percentage is an aggregate of completion, not a comparison of what was reported last in the <span class="last-count-year"></span> regional reports.
</div>
</html>