-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathresults.html
363 lines (307 loc) · 11.4 KB
/
results.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
{% extends 'btax/input_base.html' %}
{% load staticfiles %}
{% load flatblocks %}
{% block style %}
{{block.super}}
<link href="{% static 'css/vendor/bootstrap3-block-grid.min.css' %}" rel="stylesheet">
<link href="{% static 'js/vendor/DataTables/datatables.min.css' %}" rel="stylesheet"></link>
<link href="{% static 'css/vendor/bootstrap/bootstrap.min.css' %}" rel="stylesheet"></link>
<link href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css" rel="stylesheet">
<link rel='stylesheet' href={{cdn_css|safe}} type="text/css"/>
<script type="text/javascript" src={{cdn_js|safe}}></script>
<link
href="https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.7.min.css"
rel="stylesheet" type="text/css">
<script src="https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.7.min.js"></script>
<style>
.btn {
color: black;
}
.text-white { color: white;
}
colgroup {
padding: 15px;
width: 150px;
}
tr:nth-child(even) {background: #f9f9f9}
tr:nth-child(odd) {background: #FFF}
tr.group {
}
.single-line {
white-space: nowrap;
}
.sorting_asc:after {
content:"" !important;
}
.sorting_desc:after {
content:"" !important;
}
.sorting:after {
content:"" !important;
}
.sorting:after {
content:"" !important;
}
.tooltip-inner {
min-width: 200px;
max-width: 100%;
}
#results-container {
}
.bk-root .bk-grid-column {
margin: 0 auto;
}
.controls-row {
margin-left:100px;
margin-right:100px;
}
.data-label {
padding-left:20px !important;
}
table.dataTable thead .sorting,
table.dataTable thead .sorting_asc,
table.dataTable thead .sorting_desc {
background : none;
cursor: default;
}
</style>
{% endblock %}
{% block content %}
<div class="wrapper">
{% include 'taxbrain/header.html' %}
<div class="result-header">
<div class="result-header-control">
<h1>{% flatblock "ccc_results_header" %}</h1>
</div>
<p class="meta">These results were generated by <a href="https://github.com/OpenSourcePolicyCenter/webapp-public/tree/v{{webapp_version}}"> PolicyBrain version {{ webapp_version }}</a> on {{ created_on|date:"D, M jS Y \a\t g:iA" }} UTC using <a href="https://github.com/open-source-economics/B-Tax/tree/{{btax_version}}"> B-Tax version {{ btax_version }}.</a> </p>
<a href="/ccc/edit/{{ unique_url.pk }}/" class="text-white btn btn-secondary">Edit Parameters</a>
</div>
<br>
<div class="center-block">
{{ bubble_div|safe }}
{{ bubble_js|safe }}
</div>
<div id="results-container" class="container">
<div class="row controls-row">
<div id="view_by_inputs" class="col-sm-12">
<h2>View Output by:</h2>
<label class="radio-inline active">
<input type="radio" name="view_by_radio" value="industry" checked="">Industry
</label>
<label class="radio-inline">
<input type="radio" value="asset" name="view_by_radio">Asset
</label>
</div>
</div>
<div class="row controls-row">
<div id="output_interest_inputs" class="col-sm-12">
<h2>Output of Interest:</h2>
<label class="radio-inline">
<input type="radio" value="mettr" name="output_interest_radio" checked="">METTR
<span class="input-tooltip"
data-toggle="tooltip"
data-placement="top"
title=""
data-original-title="{{ tooltips.mettr }}"></span>
</label>
<label class="radio-inline active">
<input type="radio" value="metr" name="output_interest_radio">METR
<span class="input-tooltip" data-toggle="tooltip"
data-placement="top"
title=""
data-original-title="{{ tooltips.metr}}"></span>
</label>
<label class="radio-inline">
<input type="radio" value="coc" name="output_interest_radio">Cost of Capital
<span class="input-tooltip"
data-toggle="tooltip"
data-placement="top"
title=""
data-original-title="{{ tooltips.coc }}"></span>
</label>
<label class="radio-inline">
<input type="radio" value="d" name="output_interest_radio">Depreciation
<span class="input-tooltip"
data-toggle="tooltip"
data-placement="top"
title=""
data-original-title="{{ tooltips.dprc }}"></span>
</label>
</div>
</div>
<div class="row controls-row">
<div id="output_format_inputs" class="col-sm-12">
<h2>Output Format:</h2>
<label class="radio-inline active">
<input type="radio" value="reform" name="output_format_radio" checked="">Reform
</label>
<label class="radio-inline">
<input type="radio" value="baseline" name="output_format_radio">Baseline
</label>
<label class="radio-inline">
<input type="radio" value="changed" name="output_format_radio" >Change from reform
</label>
</div>
</div>
<div class="row">
<div id="results-table-area" class="col-sm-12">
</div>
</div>
</div>
<div id="table-drilldown-container"></div>
<div class="push"></div>
</div>
{% endblock %}
{% block bottom_scripts %}
{{ block.super }}
<script src="{% static 'js/vendor/babel-standalone/babel.min.js' %}"></script>
<script src="{% static 'js/vendor/jquery/jquery.min.js' %}"></script>
<script src="{% static 'js/vendor/bootstrap/bootstrap.min.js' %}"></script>
<script src="{% static 'js/vendor/underscore/underscore-min.js' %}"></script>
<script src="{% static 'js/vendor/backbone/backbone-min.js' %}"></script>
<script src="{% static 'js/vendor/DataTables/datatables.js' %}"></script>
<script>
window.tableData = JSON.parse('{{ table_json | safe }}');
window.viewBy = "industry";
window.outputInterest = "mettr";
window.outputFormat = "reform";
</script>
<script type="text/babel">
$(function () {
var print = function(msg) {
console.log(msg);
};
var onViewByChange = function(e) {
window.viewBy = e.target.value;
print(".onViewByChange()");
buildTable();
};
var onOutputInterestChange = function(e) {
window.outputInterest = e.target.value;
print(".onOutputInterestChange()");
buildTable();
};
var onOutputFormatChange = function(e) {
window.outputFormat = e.target.value;
print(".onOutputFormatChange()");
buildTable();
};
var formatValue = function(cells, ind) {
if (ind > cells.length - 1) {
return 'n/a';
}
var cell = cells[ind];
if (typeof cell.value == 'string') {
return cell.value;
} else if (typeof cell.value == 'number') {
var val_str = (parseFloat(cell.value / cell.format.divisor)).toFixed(cell.format.decimals).toString();
return val_str;
}
};
var buildTableObj = function(tableType) {
var $table = $('<table/>');
$table.addClass('stripe');
$table.append(`
<thead>
<tr>
<th rowspan="2">${tableType}</th>
<th colspan="2">Typically Financed</th>
<th colspan="2">Equity Financed</th>
<th colspan="2">Debt Financed</th>
</tr>
<tr>
<th scope="col">Corporate</th>
<th scope="col">Non-corporate</th>
<th scope="col">Corporate</th>
<th scope="col">Non-corporate</th>
<th scope="col">Corporate</th>
<th scope="col">Non-corporate</th>
</tr>
</thead>
`);
var $table_body = $('<tbody/>');
var asset, metr_c, metr_nc, metr_c_e, metr_nc_e, metr_c_d, metr_nc_d;
var row;
var items = window.tableData[window.viewBy + '_' + window.outputInterest][window.outputFormat];
for(var i=0; i < items.rows.length; i++) {
row = items.rows[i];
if(row.label == row.major_grouping){
var sb = "<strong>";
var se = "</strong>";
}else{
var sb = "";
var se = "";
}
if(row.major_grouping === row.label){
if(row.summary_c === 'breakline'){
$table_body.append(`
<tr>
<td class="data-label">
<strong>${row.label}</strong>
</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
`);
continue;
}
var label_cls = "group";
}else{
var label_cls = "data-label";
}
$table_body.append(`
<tr>
<td class="${label_cls}">${sb}${row.label}${se}</td>
<td>${sb}${formatValue(row.cells, 0)}${se}</td>
<td>${sb}${formatValue(row.cells, 1)}${se}</td>
<td>${sb}${formatValue(row.cells, 2)}${se}</td>
<td>${sb}${formatValue(row.cells, 3)}${se}</td>
<td>${sb}${formatValue(row.cells, 4)}${se}</td>
<td>${sb}${formatValue(row.cells, 5)}${se}</td>
<td></td>
<td></td>
<td></td>
</tr>`);
}
$table.append($table_body);
$('#results-table-area').html($table);
};
var buildTable = function() {
if (window.viewBy === 'asset') {
buildTableObj('Asset');
} else if (window.viewBy == 'industry') {
buildTableObj('Industry');
}
$('#results-table-area>table').DataTable({
"columnDefs": [{"visible": false, "targets": 7},{"visible": false, "targets": 8},{"visible": false, "targets": 9}],
"order": [[7, 'asc']],
"paging":false,
"ordering":false,
"info":false,
});
};
document.getElementById('view_by_inputs').addEventListener('change', onViewByChange, false);
document.getElementById('output_interest_inputs').addEventListener('change', onOutputInterestChange, false);
document.getElementById('output_format_inputs').addEventListener('change', onOutputFormatChange, false);
delete window.tableData['result_years'];
buildTable();
// Order by the grouping
$('table tbody').on( 'click', 'tr.group', function () {
var currentOrder = table.order()[0];
if ( currentOrder[0] === 2 && currentOrder[1] === 'asc' ) {
table.order( [ 2, 'desc' ] ).draw();
}
else {
table.order( [ 2, 'asc' ] ).draw();
}
} );
});
</script>
{% endblock %}