-
Notifications
You must be signed in to change notification settings - Fork 0
/
Developer Contributions Register.html
1219 lines (805 loc) · 39.7 KB
/
Developer Contributions Register.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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<html>
<head>
<!-- AUTHOR: L KRAUSZ
DATE: 1/3/2023 -->
<title>Developer Contributions Paid</title>
</head>
<body>
<!-- external libs from cdnjs -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script type ="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/plotly.js/1.33.1/plotly-basic.min.js"></script>
<!-- script type="text/javascript" src="https://cdn.plot.ly/plotly-basic-latest.min.js"></script -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/4.1.2/papaparse.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/floatthead/2.2.1/jquery.floatThead.min.js"></script>
<!-- PivotTable.js libs from ../dist -->
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/pivottable/2.23.0/pivot.min.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pivottable/2.23.0/pivot.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pivottable/2.23.0/d3_renderers.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pivottable/2.23.0/plotly_renderers.min.js"></script>
<script type="text/javascript" src='https://cdnjs.cloudflare.com/ajax/libs/pivottable/2.23.0/export_renderers.min.js'></script>
<!-- subtotal.js libs from ../dist, not available from a CDN -->
<!-- base href= "/" -->
<script type="text/javascript" src="scripts/PivotJS-subtotal/subtotal.js"></script>
<link rel="stylesheet" type="text/css" href="scripts/PivotJS-subtotal/subtotal.css">
<!-- needed to dl as Excel -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.0/FileSaver.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.16.9/xlsx.full.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<style>
body {font-family: Verdana;}
.blink_me {
animation: blinker 1.5s linear infinite;
}
@keyframes blinker {
50% {
opacity: 0;
}
}
th.pvtRowLabel {
white-space: nowrap;
}
.ms-webpartPage-root {
border-spacing: 0px;
}
.desc {
padding-bottom: 10px;
width: 80vw;
}
.rotate {
height: 90px;/* fixed height . set fixed width to rotated elements */
width: 110px !important;/* a liitle less than parents height */
-webkit-transform: rotate(310deg);
-moz-transform: rotate(310deg);
-ms-transform: rotate(310deg);
-o-transform: rotate(310deg);
transform: rotate(310deg) translatex(-64%) translatey(56%);
transform-origin: top left;
margin-right: -73px;
}
#inclusions strong {
font-weight: 500;
color:lightseagreen;
}
/* extras for floating headers */
.floatThead-container {
overflow: hidden;
}
.pvtFilterBox {
z-index: 2001;
}
/* ************************* */
.pvtRowLabel {
font-weight: normal;
}
.hidden {
display: none;
}
.note {
font-size: smaller;
font-style: italic;
color: silver;
}
#progressHeading {
color: grey;
font-size: smaller;
}
table.pvtTable tbody tr th.pvtRowLabel.discontinued, .discontinued {
color:grey !important;
background-color: beige !important;
}
#header {
width: 100%;
background-color: lightblue;
height: 100px;
}
.excelImg {
width: 30px;
height: 30px;
}
/* table.pvtTable tbody tr th.pvtRowLabel {
min-width: 150px;
} */
table.pvtTable tbody tr th.pvtRowLabel.comFacCell,
table.pvtTable thead tr th.pvtColLabel.comFacCell {
background-color: #F9DFE1 !important;
}
table.pvtTable tbody tr th.pvtRowLabel.osCell,
table.pvtTable thead tr th.pvtColLabel.osCell {
background-color: #D4EBD4 !important;
}
table.pvtTable tbody tr th.pvtRowLabel.roadCell,
table.pvtTable thead tr th.pvtColLabel.roadCell {
background-color: #f1e8df !important;
}
table.pvtTable tbody tr th.pvtRowLabel.drainageCell,
table.pvtTable thead tr th.pvtColLabel.drainageCell {
background-color: #e4eef8 !important;
}
table.pvtTable tbody tr th.pvtRowLabel.otherCell,
table.pvtTable thead tr th.pvtColLabel.otherCell {
background-color: #EFEED8 !important;
}
#subTotalRowLimitDiv input{
width: 60px;
}
#subTotalRowLimitDiv{
padding: 2px;
background-color: lightgrey;
font-size: smaller;
}
.rowWrap {
height: auto;
}
.cellWrap {
white-space: normal !important;
word-wrap: break-word;
word-break: break-all;
max-width: 200px;
}
.pointer {
cursor: pointer;
}
.intro {
font-size: smaller;
font-style:italic;
text-align:left;
}
table.dataTable {
border-collapse: collapse;
}
.dataTable tbody tr th {
text-align: left;
}
tr.dataDic td {
font-size: 12px;
font-family: Verdana, Geneva, Tahoma, sans-serif;
padding: 8px;
}
tr.dataDic td cs {
font-weight: 600;
color: #66b2b2;
text-shadow: 0 0 0 #66b2b2;
}
.dicDivider {
background-color:rgb(49, 76, 78);
color: white;
}
tr.dataDic:nth-child(even) {
background-color: #E6E6E3;
}
.thickLine {
border-top: 2pt solid black !important;
}
pre {
background-color: ghostwhite;
border: 1px solid silver;
padding: 10px 20px;
margin: 20px;
border-radius: 4px;
width: 25%;
margin-left: auto;
margin-right: auto;
}
table.dataTable > td {
font-size: smaller;
}
.swal-text {
width: 100%;
overflow-y: scroll;
}
</style>
<script type="text/javascript">
debug = false;
var dataObj;
var config = {};
//var threeYearArray = [String(new Date().getFullYear()-2), String(new Date().getFullYear()-1), String(new Date().getFullYear())];
var twoYearArray = [String(new Date().getFullYear()-1), String(new Date().getFullYear())];
var yearArray = [String(new Date().getFullYear())];
var configRenderer;
var storageTag = "-dcpaid2"; // make these unique to each chart
let configShowUI = localStorage.getItem('showUi'+storageTag) === null ? false : JSON.parse(localStorage.getItem('showUi'+storageTag));
var sorters = {
"Purpose": $.pivotUtilities.sortAs(
["Community Facilities","Open Space", "Roads","Drainage"]
)
}
var pdObject = {};
var vals = ['AMOUNT']; //default
var sum = $.pivotUtilities.aggregatorTemplates.sum;
var numberFormat = $.pivotUtilities.numberFormat;
var intFormat = numberFormat({digitsAfterDecimal: 0, prefix: '$'});
var curFormat = numberFormat({digitsAfterDecimal: 0, prefix: '$'});
var custom_aggregators = {
"AMOUNT": function() { return sum(curFormat)(["Amount"])},
"LEVIED": function() { return sum(curFormat)(["LEVIED"])},
"PAID": function() { return sum(curFormat)(["PAID"])},
"BALANCE": function() {return sum(curFormat)(["BALANCE"])}
};
var discontinued = [];
async function getDiscontinued() {
await fetch('data/discontinued.json')
.then((response) => response.json())
.then((json) => discontinued = json);
}
getDiscontinued();
var dataDictionary = [];
async function getDataDictionary() {
await fetch('data/datadictionary.json')
.then((response) => response.json())
.then((json) => dataDictionary = json);
}
getDataDictionary();
var fromXlOne = false;
var fileNameAndPath = "data/CurrentS94TransactionsMF.csv";
// FULL GITHUB PATH REQUIRED TO GET THE REAL 'SAVE DATE' FOR THE CSV
var gitHubPath = "https://api.github.com/repos/flowerbot/contributionspaid/commits?path=data/CurrentS94TransactionsMF.csv&page=1&per_page=1"
var curPath = window.location.href;
const options = {
weekday: "long",
year: "numeric",
month: "long",
day: "numeric",
};
var client = new XMLHttpRequest();
if(curPath.indexOf("github")>=0) {
client.open("HEAD", gitHubPath, true);
} else {
client.open("HEAD", fileNameAndPath);
}
client.onreadystatechange = function() {
if(this.readyState == 2) {
var newDate = new Date(client.getResponseHeader("Last-Modified")).toLocaleDateString("en-AU", options);
var newTime = new Date(client.getResponseHeader("Last-Modified")).toLocaleTimeString("en-AU");
var dtString = newDate + " " + newTime;
// console.log("NEW daTE:", newDate, "; NEW TIME:", newTime);
document.getElementById("fileDate").innerHTML = dtString;
}
}
client.send();
document.addEventListener('click', function (e) {
const cell = e.target.closest('th');
if (!cell) {return;} // Quit, not clicked on a cell
const row = cell.parentElement;
tmpData = dataObj[0];
rowIndex = tmpData.findIndex((el) => el == "Application ID");
tableRowIndex = savedConfig.rows.findIndex((el) => el == "Application ID");
pcIndex = tmpData.findIndex((el)=> el == "RAM_PROCESS_CTR");
tmpRows = document.querySelectorAll("table.pvtTable >tbody tr");
maxCols = tmpRows[0].cells.length;
appCtr = 0;
subtract = 0;
//totals = "Balance"
//record = [];
if(maxCols-row.cells.length != 0) subtract = maxCols-row.cells.length;
if(tableRowIndex > -1) {
if( ["Table", "Heatmap", "Row Heatmap", "Col Heatmap"].indexOf(savedConfig.rendererName) > -1 ) {
DAText = row.cells[tableRowIndex-subtract].innerHTML;
console.log("row index:", rowIndex);
appCtr = dataObj.filter(function(i) {
return (i[rowIndex]==DAText);
})[0][pcIndex];
} else {
rName = savedConfig.rendererName;
if(rName.indexOf("Table With Subtotal") > -1) {
thisRow = e.target.closest('tr');
sel = thisRow.getAttribute("class");
try {
DAText = thisRow.querySelector('th.rowcol'+tableRowIndex).innerHTML.replace(/[^\w\/]+/g, "");
appCtr = dataObj.filter(function(i) {
return (i[rowIndex]==DAText);
})[0][pcIndex];
} catch (ex) {
appCtr = 0;
}
}
}
if(appCtr > 0) {
popup(DAText,appCtr);
// if (window.confirm("View DA Tracker details for "+ DAText + " ?"))
// {
// var win = window.open('https://datracker.tweed.nsw.gov.au/Pages/XC.Track/SearchApplication.aspx?id='+appCtr, '_blank');
// win.focus();
// }
}
}
});
function makeTableHTML(myArray) {
var result = "<html>"
result += "<style> table thead { position: sticky; inset-block-start: 0; background-color: silver; } th, td { font-size: smaller; font-family: Arial; }"
result += "th { border-bottom: 2px solid blue; }"
result += "</style>"
result += "<body><table border=1 style='border-collapse: collapse;' class='dataTable'>";
for(var i=0; i<1; i++) {
result += "<thead><tr>";
for(var j=0; j<myArray[i].length; j++){
result += "<th>"+myArray[i][j]+"</th>";
}
result += "</tr></thead>";
}
for(var i=1; i<myArray.length; i++) {
result += "<tr>";
for(var j=0; j<myArray[i].length; j++){
result += "<td >"+myArray[i][j]+"</td>";
}
result += "</tr>";
}
result += "</table></body></html>";
return result;
}
function popupJSON(obj) {
var win = window.open("", "Data Table", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+(screen.width-30)+",height="+(screen.height-30)+",top=15,left=15");
//win.document.body.innerHTML = "<p>*** PLEASE WAIT, GETTING DATA ***</p>";
html = makeTableHTML(obj);
/* console.log(obj);
var jsonLine = /^( *)("[\w]+": )?("[^"]*"|[\w.+-]*)?([,[{])?$/mg;
var replacer = function(match, pIndent, pKey, pVal, pEnd) {
var key = '<span class="json-key" style="color: brown">',
val = '<span class="json-value" style="color: navy">',
str = '<span class="json-string" style="color: olive">',
r = pIndent || '';
if (pKey)
r = r + key + pKey.replace(/[": ]/g, '') + '</span>: ';
if (pVal)
r = r + (pVal[0] == '"' ? str : val) + pVal + '</span>';
return r + (pEnd || '');
};
var html = JSON.stringify(obj, null, 3)
.replace(/&/g, '&').replace(/\\"/g, '"')
.replace(/</g, '<').replace(/>/g, '>')
.replace(jsonLine, replacer);
*/
/* Swal.fire({
html: html,
width: 1200,
heightAuto: false,
showConfirmButton: false,
showCloseButton: true,
backdrop:true,
}) */
win.document.body.innerHTML = html;
}
function popupFieldInfo() {
var html = "<div class='intro'>For each developer contribution charge on an application, there will be up to 3 data rows represented in this chart - 1 for each of LEVIED, PAID (only if paid) and WIK CREDIT (only if credit applied).</div>";
html += "<div style='overflow-y:scroll; height:80vh'><table class='dataTable'><tr><th>Attribute</th><th>Description</th></tr>";
html += "<tr><td colspan=2 class='dicDivider'>Charge-related:</td></tr>" ;
dataDictionary.forEach(i =>{
if(i["Value"] == "Application ID") html += "<tr><td colspan=2 class='dicDivider'>Application-related:</td></tr>" ;
html += "<tr class='dataDic'><td style='min-width: 110px; vertical-align: top;'>" + i["Value"] + "</td><td>" + i["Description"] + "</td></tr>";
})
html += "</table></div>"
Swal.fire({
//title: 'Go to the DA tracker?',
// text: "View DA Tracker details for "+ DAText + "?",
/* icon: 'question',
iconHTML: 'YY?', */
html: html,
// confirmButtonText: 'OK',
width: 700,
heightAuto: false,
showConfirmButton: false,
showCloseButton: true,
backdrop: true
});
}
async function popup(DAText,appCtr) {
// console.log(record);
const {value: accept } = await Swal.fire({
//title: 'Go to the DA tracker?',
// text: "View DA Tracker details for "+ DAText + "?",
/* icon: 'question',
iconHTML: 'YY?', */
html: "View DA Tracker details for "+ DAText + "?",
confirmButtonText: 'OK',
showCancelButton: true,
backdrop: false
});
if(accept) {
var win = window.open('https://datracker.tweed.nsw.gov.au/Pages/XC.Track/SearchApplication.aspx?id='+appCtr, '_blank');
win.focus();
}
}
$(function(){
let selectedOption = localStorage.getItem('selectedOption'+storageTag) === null ? "focusOnApps" : localStorage.getItem('selectedOption'+storageTag);
$("#chartType").val(selectedOption);
var stRowLimit = localStorage.getItem("stRowLimit");
if(stRowLimit != null) document.getElementById("subtotalto").value = parseInt(stRowLimit);
var dataClass = $.pivotUtilities.SubtotalPivotData;
var renderers = $.extend($.pivotUtilities.renderers,
$.pivotUtilities.plotly_renderers,
$.pivotUtilities.subtotal_renderers,
$.pivotUtilities.export_renderers);
var tpl = $.pivotUtilities.aggregatorTemplates;
var SubtotalDisableFrom = document.getElementById("subtotalto").value;
var rendererOptions = {
rowSubtotalDisplay: {
collapseAt: 1,
disableFrom: SubtotalDisableFrom
},
colSubtotalDisplay: {
collapseAt: 1
},
heatmap: {
colorScaleGenerator: function(values) {
return d3.scale.linear()
.domain([-6000000, 0, 600000])
.range(["#9AFF3D", "#FFFFFF", "#FF0000"])
}
},
localeStrings: {
totals: "Balance"
},
};
Papa.parse(fileNameAndPath, {
download: true,
skipEmptyLines: true,
complete: function(parsed){
console.log("records parsed: ", parsed.data.length);
const options = {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
timeZoneName: 'short'
};
var curPath = window.location.href;
var localDate = "";
// getFileDate(fileNameAndPath);
fixedData = [];
if (parsed.data[0][0] == "FORMAT XLONE REPORT") fromXLOne = true;
var emptyCols = [];
dataObj = parsed.data;
console.log("records filtered to:", dataObj.length);
document.getElementById("progressTotal").innerHTML = dataObj.length;
document.getElementById("progress").innerHTML = dataObj.length;
let headerRow = dataObj[0];
let yearIndex = headerRow.indexOf("Approval Year");
let yearValues = dataObj.map(v => Number(v[yearIndex]));
let v2 = yearValues.splice(0,1);
var minYear = Math.min(...yearValues);
document.getElementById("earliestDate").innerHTML = minYear.toString();
savedConfig = JSON.parse(localStorage.getItem('pivotdatakey'+storageTag));
if(savedConfig) {
toggleButtonText(savedConfig.showUI);
} else {
$("#subTotalRowLimitDiv").hide();
}
$("#output").pivotUI(dataObj, {
hiddenAttributes: ["CHARGE_TYPE", "APPLICATION_NO","RAM_PROCESS_CTR", "CHARGE_CTR"],
dataClass: dataClass,
rows: (savedConfig) ? savedConfig.rows : ["Application ID", "locality", "Short Description", "Determined By", "Determined", "Levy"],
cols: (savedConfig) ? savedConfig.cols : ["Purpose", "TR TYPE"],
vals: (savedConfig) ? savedConfig.vals : ["AMOUNT"],
derivedAttributes: {
"Determined": function(d) {
return (d["Approval Date"]).substring(0,10);
}
},
renderers: renderers,
rendererOptions: rendererOptions,
menuLimit: 3000,
sorters: sorters,
exclusions: {"Determined By": [""]},
aggregatorName: (savedConfig) ? savedConfig.aggregatorName : "AMOUNT",
showUI: (savedConfig) ? savedConfig.showUI : false, //configShowUI,
inclusions: (savedConfig) ? savedConfig.inclusions : { "Approval Year": yearArray },
rendererName: (savedConfig) ? savedConfig.rendererName : "Table",
aggregators: custom_aggregators,
onRefresh: function (config) {
savedConfig = config;
vals = config.vals;
localStorage.setItem('pivotdatakey'+storageTag, JSON.stringify(config)); // Add callback function for onRefresh
try {
document.getElementById("inclusions").innerHTML = "<strong>Inclusions:</strong><span >" + JSON.stringify(config["inclusions"]) + "</span> ";
} catch (ex) {console.log("inclusions not found")};
//try {
txt = document.getElementById("inclusions").innerHTML;
document.getElementById("inclusions").innerHTML = txt + "<strong>aggregator:</strong><span >" + JSON.stringify(config.aggregatorName) + "</span> ";
// } catch (ex) {console.log("vals not found")};
if(config.aggregatorName != "Multifact aggregator" && config.rendererName != "Table" ) {
$(".pvtColLabel").wrapInner("<div class='rotate'></div>");
} else {
//this worked for a one attribute column array but nothing else, and the aggregator doesn't behave unless every column is
// represented so best not to use it
/* $newHead = $('<thead></thead>').prependTo('table.pvtTable').append($('table.pvtTable tr:first'));
$newHead.append($('table.pvtTable tr:nth-child(1)')); */
}
var $table = $('table.pvtTable');
try {
$table.floatThead({
scrollContainer: function($table){
return $table.closest('.wrapper');
},
position: 'auto',
floatTableClass: 'pivotBody',
autoReflow: true
});
} catch(ex) {}
colorLevy();
if(config.rendererName.indexOf("Table") > -1 || config.rendererName.indexOf("Heatmap") > -1) {
wrapDescription();
}
}
}, false, "en");
$(".pvtColLabel").wrapInner("<div class='rotate'></div>");
}
}
);
});
function dataExport() {
var myWindow = (window.open("", "", "width=600,height=600,scrollbars=1"));
var tableTxt = "";
var exportTableTxt = "";
var tableId = "dataExportTable";
var downloadLink;
var dataType = 'application/vnd.ms-excel';
var msgText = "<H2>JSON FORMAT:</H2><p>Save JSON to a text file, or copy it to a JSON viewer, like the one at <a href='https://jsongrid.com/json-grid'target='_blank'>jsongrid.com</a> </p>";
myWindow.document.title="Export ..";
myWindow.document.write(msgText + "<pre style='border:1px solid #dddddd;'>" + JSON.stringify(dataObj, null, " ")+"</pre>");
}
function sheetJSWorkBook(type, fn, dl) {
var $table = $('table.pvtTable');
$table.floatThead('destroy'); // put it back together (unfloat it) for the excel dl
var elt = document.getElementsByClassName('pvtTable')[0];
var wb = XLSX.utils.table_to_book(elt, {sheet:"SWD Data"});
wb.SheetNames.push("Inclusions");
var inc = document.getElementById("inclusions").innerHTML;
var tempTable = document.createElement("table");
tempTable.innerHTML = "<tr><td>"+inc + "</td></tr>";
var ws = XLSX.utils.table_to_sheet(tempTable);
wb.Sheets["Inclusions"] = ws;
fixHeader(); // float it again
return dl ?
XLSX.write(wb, {bookType:type, bookSST:true, type: 'base64'}) :
XLSX.writeFile(wb, fn || ('developer contributions.' + (type || 'xlsx')));
}
function revert() {
localStorage.clear();
location.reload();
}
function fixHeader() {
var $table = $('table.pvtTable');
$table.floatThead({
position: 'fixed',
});
}
function selectChange(el) {
var tConfig = $("#output").data("pivotUIOptions");
localStorage.setItem('selectedOption'+storageTag,el.value);
//"Table"
if(el.value == "TSV") {
delete tConfig["rendererName"];
tConfig["rendererName"] = "TSV Export";
} else
if(el.value == "focusOnApps") {
console.log("focus on apps triggered");
delete tConfig["rows"];
delete tConfig["cols"];
delete tConfig["rendererName"];
delete tConfig["inclusions"];
delete tConfig["aggregatorName"];
delete tConfig["vals"];
tConfig["rows"] = ["Application ID", "locality", "Short Description", "Determined By", "Determined", "Levy"];
tConfig["cols"] = ["Purpose", "TR TYPE"];
tConfig["rendererName"] = "Table";
tConfig["aggregatorName"] = "AMOUNT";
tConfig["inclusions"] = { "Approval Year": yearArray };
tConfig["vals"] = ["AMOUNT"];
}
else
if(el.value == "LeviedPaid") {
console.log("focus on apps triggered");
delete tConfig["rows"];
delete tConfig["cols"];
delete tConfig["rendererName"];
delete tConfig["inclusions"];
delete tConfig["aggregatorName"];
delete tConfig["vals"];
console.log("format:", tConfig.format);
tConfig["rows"] = ["Application ID", "locality", "Short Description", "Locality", "Determined By", "Determined", "Purpose", "Levy"];
tConfig["cols"] = [];
tConfig["rendererName"] = "Multifact Table";
tConfig["aggregatorName"] = "Multifact aggregator"
tConfig["inclusions"] = { "Approval Year": yearArray };
tConfig["vals"] = ["LEVIED","PAID"];
}
else
if(el.value == "Pies") {
console.log("pies triggered");
delete tConfig["rows"];
delete tConfig["cols"];
delete tConfig["rendererName"];
delete tConfig["inclusions"];
delete tConfig["vals"];
delete tConfig["aggregatorName"];
tConfig["rows"] = ["Purpose"];
tConfig["cols"] = ["locality"];
tConfig["rendererName"] = "Horizontal Stacked Bar Chart";
tConfig["inclusions"] = {};
tConfig["aggregatorName"] = ["PAID"];
tConfig["vals"] = ["PAID"];
} else
if(el.value == "all") {
console.log("all triggered");
delete tConfig["rows"];
delete tConfig["cols"];
delete tConfig["rendererName"];
delete tConfig["inclusions"];
delete tConfig["vals"];
delete tConfig["aggregatorName"];
tConfig["rows"] = ["Approval Year", "Purpose","Levy"];
tConfig["cols"] = ["TR TYPE"];
tConfig["rendererName"] = "Table With Subtotal";
tConfig["inclusions"] = { "Approval Year": yearArray};
tConfig["aggregatorName"] = ["AMOUNT"];
tConfig["vals"] = ["AMOUNT"];
}
else
if(el.value == "chartYear") {
console.log("year chart triggered");
delete tConfig["rows"];
delete tConfig["cols"];
delete tConfig["rendererName"];
delete tConfig["inclusions"];
delete tConfig["exclusions"];
delete tConfig["vals"];
delete tConfig["aggregatorName"];
tConfig["rows"] = ["Purpose"];
tConfig["cols"] = ["Approval Year"];
tConfig["rendererName"] = "Horizontal Stacked Bar Chart";
tConfig["inclusions"] = {};
tConfig["exclusions"] = {};
tConfig["aggregatorName"] = ["PAID"];
tConfig["vals"] = ["PAID"];
}
localStorage.setItem('pivotdatakey'+storageTag, JSON.stringify(tConfig)); // Add callback function for onRefresh
$("#output").pivotUI(dataObj, tConfig, true);
}
function toggleButtonText(val) {
if(val) {
document.getElementById('toggleHideUIButton').value= "Hide Chart Settings";
$('#subTotalRowLimitDiv').show();
} else {
document.getElementById('toggleHideUIButton').value= "Show Chart Settings";
$('#subTotalRowLimitDiv').hide();
}
}
function toggleConfigHide(obj, toggle) {
console.log('toggling new ', toggle);
var tConfig = $("#output").data("pivotUIOptions");
console.log('showUi'+storageTag+":", localStorage.getItem('showUi'+storageTag))
var newVis = !JSON.parse(tConfig["showUI"]);
delete tConfig["showUI"];
tConfig["showUI"] = newVis;