1
+ $ ( document ) . ready ( function ( ) {
2
+ $ ( ".passed" ) . addClass ( "teal lighten-2" ) ;
3
+ $ ( ".failed" ) . addClass ( "red lighten-2" ) ;
4
+ $ ( ".skipped" ) . addClass ( "amber lighten-2" ) ;
5
+ $ ( ".undefined" ) . addClass ( "amber lighten-2" ) ;
6
+ $ ( ".pending" ) . addClass ( "amber lighten-2" ) ;
7
+
8
+ var passed = $ ( ".scenario.passed" ) ;
9
+ var failed = $ ( ".scenario.failed" ) ;
10
+ var skipped = $ ( ".scenario.skipped" ) ;
11
+ var undefined = $ ( ".scenario.undefined" ) ;
12
+ var pending = $ ( ".scenario.pending" ) ;
13
+ var scenarios = $ ( ".scenario" ) ;
14
+
15
+ var working = $ ( ".feature.working" ) ;
16
+ var broken = $ ( ".feature.broken" ) ;
17
+ var incomplete = $ ( ".feature.incomplete" ) ;
18
+ var features = $ ( ".feature" ) ;
19
+
20
+ passed . prepend ( "<i class=\"material-icons\">done_all</i>" ) ;
21
+ failed . prepend ( "<i class=\"material-icons\">highlight_off</i>" ) ;
22
+ skipped . prepend ( "<i class=\"material-icons\">error_outline</i>" ) ;
23
+ undefined . prepend ( "<i class=\"material-icons\">error_outline</i>" ) ;
24
+ pending . prepend ( "<i class=\"material-icons\">error_outline</i>" ) ;
25
+
26
+ features . each ( function ( ) {
27
+ var $this = $ ( this ) ;
28
+ var pCount = $this . find ( ".scenario.passed" ) . length ;
29
+ var fCount = $this . find ( ".scenario.failed" ) . length ;
30
+ var sCount = $this . find ( ".scenario.skipped" ) . length ;
31
+ var uCount = $this . find ( ".scenario.undefined" ) . length ;
32
+ var ppCount = $this . find ( ".scenario.pending" ) . length ;
33
+ if ( pCount > 0 ) {
34
+ $this . find ( ".collapsible-header" ) . append ( "<span class=\"new badge teal lighten-2\" data-badge-caption=\"Passed\">" + pCount + "</span>" ) ;
35
+ }
36
+ if ( fCount > 0 ) {
37
+ $this . find ( ".collapsible-header" ) . append ( "<span class=\"new badge red lighten-2\" data-badge-caption=\"Failed\">" + fCount + "</span>" ) ;
38
+ }
39
+ if ( sCount > 0 ) {
40
+ $this . find ( ".collapsible-header" ) . append ( "<span class=\"new badge amber lighten-2\" data-badge-caption=\"Skipped\">" + sCount + "</span>" ) ;
41
+ }
42
+ if ( uCount > 0 ) {
43
+ $this . find ( ".collapsible-header" ) . append ( "<span class=\"new badge amber lighten-2\" data-badge-caption=\"Undefined\">" + uCount + "</span>" ) ;
44
+ }
45
+ if ( ppCount > 0 ) {
46
+ $this . find ( ".collapsible-header" ) . append ( "<span class=\"new badge amber lighten-2\" data-badge-caption=\"Pending\">" + ppCount + "</span>" ) ;
47
+ }
48
+ } ) ;
49
+
50
+ $ ( ".errorList .error" ) . each ( function ( ) {
51
+ var $this = $ ( this ) ;
52
+ var eCount = $this . find ( ".failedScenarioList .failedScenario" ) . length ;
53
+ if ( eCount > 0 ) {
54
+ $this . find ( ".collapsible-header" ) . append ( "<span class=\"new badge blue lighten-2\" data-badge-caption=\"Scenarios\">" + eCount + "</span>" ) ;
55
+ } else {
56
+ $this . remove ( ) ;
57
+ }
58
+ } ) ;
59
+
60
+ $ ( ".tabs .tab" ) . click ( function ( ) {
61
+ $ ( ".tabs a" ) . removeClass ( "blue-text" ) . addClass ( "white-text" ) ;
62
+ $ ( this ) . find ( 'a' ) . removeClass ( "white-text" ) . addClass ( "blue-text" ) ;
63
+ } ) ;
64
+
65
+ var passedCount = passed . length ;
66
+ var failedCount = failed . length ;
67
+ var skippedCount = skipped . length ;
68
+ var undefinedCount = undefined . length ;
69
+ var pendingCount = pending . length ;
70
+ var scenariosCount = scenarios . length ;
71
+
72
+ var workingCount = working . length ;
73
+ var brokenCount = broken . length ;
74
+ var incompleteCount = incomplete . length ;
75
+ var featuresCount = features . length ;
76
+
77
+ var metaTableFeatures = $ ( "table#metaDataFeatures tbody" ) ;
78
+ var metaTableScenarios = $ ( "table#metaDataScenarios tbody" ) ;
79
+
80
+ metaTableFeatures . append ( "<tr><th>Total Features</th><td>" + featuresCount + "</td></tr>" ) ;
81
+ metaTableScenarios . append ( "<tr><th>Total Scenarios</th><td>" + scenariosCount + "</td></tr>" ) ;
82
+
83
+ var featuresDoughnut = document . getElementById ( "featuresDoughnut" ) . getContext ( '2d' ) ;
84
+ var featuresDoughnutCountData = [ ] ;
85
+ var featuresDoughnutLabels = [ ] ;
86
+ var featuresDoughnutBackgroundColor = [ ] ;
87
+ var featuresDoughnutBorderColor = [ ] ;
88
+ if ( workingCount > 0 ) {
89
+ metaTableFeatures . append ( "<tr><th>Working</th><td>" + ( ( workingCount / featuresCount ) * 100 ) . toFixed ( 1 ) + " %</td></tr>" ) ;
90
+ featuresDoughnutCountData . push ( workingCount ) ;
91
+ featuresDoughnutLabels . push ( "Working" ) ;
92
+ featuresDoughnutBackgroundColor . push ( 'rgba(75, 192, 192, 0.2)' ) ;
93
+ featuresDoughnutBorderColor . push ( 'rgba(75, 192, 192, 1)' ) ;
94
+ }
95
+ if ( brokenCount > 0 ) {
96
+ metaTableFeatures . append ( "<tr><th>Broken</th><td>" + ( ( brokenCount / featuresCount ) * 100 ) . toFixed ( 1 ) + " %</td></tr>" ) ;
97
+ featuresDoughnutCountData . push ( brokenCount ) ;
98
+ featuresDoughnutLabels . push ( "Broken" ) ;
99
+ featuresDoughnutBackgroundColor . push ( 'rgba(255, 99, 132, 0.2)' ) ;
100
+ featuresDoughnutBorderColor . push ( 'rgba(255, 99, 132, 1)' ) ;
101
+ }
102
+ if ( incompleteCount > 0 ) {
103
+ metaTableFeatures . append ( "<tr><th>Incomplete</th><td>" + ( ( incompleteCount / featuresCount ) * 100 ) . toFixed ( 1 ) + " %</td></tr>" ) ;
104
+ featuresDoughnutCountData . push ( incompleteCount ) ;
105
+ featuresDoughnutLabels . push ( "Incomplete" ) ;
106
+ featuresDoughnutBackgroundColor . push ( 'rgba(255, 206, 86, 0.2)' ) ;
107
+ featuresDoughnutBorderColor . push ( 'rgba(255, 206, 86, 1)' ) ;
108
+ }
109
+ var featuresDoughnutData = {
110
+ labels : featuresDoughnutLabels ,
111
+ datasets : [
112
+ {
113
+ label : '# of Votes' ,
114
+ data : featuresDoughnutCountData ,
115
+ backgroundColor : featuresDoughnutBackgroundColor ,
116
+ borderColor : featuresDoughnutBorderColor ,
117
+ borderWidth : 1
118
+ }
119
+ ]
120
+ } ;
121
+ var featuresDoughnutOptions = {
122
+ title : {
123
+ display : true ,
124
+ text : 'Features'
125
+ }
126
+ } ;
127
+ var featuresDoughnutChart = new Chart ( featuresDoughnut , {
128
+ type : 'doughnut' ,
129
+ data : featuresDoughnutData ,
130
+ options : featuresDoughnutOptions
131
+ } ) ;
132
+
133
+ if ( featuresDoughnutCountData . length > 0 ) {
134
+ featuresDoughnutChart . draw ( ) ;
135
+ }
136
+
137
+ var scenariosDoughnut = document . getElementById ( "scenariosDoughnut" ) . getContext ( '2d' ) ;
138
+ var scenariosDoughnutCountData = [ ] ;
139
+ var scenariosDoughnutLabels = [ ] ;
140
+ var scenariosDoughnutBackgroundColor = [ ] ;
141
+ var scenariosDoughnutBorderColor = [ ] ;
142
+ if ( passedCount > 0 ) {
143
+ metaTableScenarios . append ( "<tr><th>Passed</th><td>" + ( ( passedCount / scenariosCount ) * 100 ) . toFixed ( 1 ) + " %</td></tr>" ) ;
144
+ scenariosDoughnutCountData . push ( passedCount ) ;
145
+ scenariosDoughnutLabels . push ( "Passed" ) ;
146
+ scenariosDoughnutBackgroundColor . push ( 'rgba(75, 192, 192, 0.2)' ) ;
147
+ scenariosDoughnutBorderColor . push ( 'rgba(75, 192, 192, 1)' ) ;
148
+ }
149
+ if ( failedCount > 0 ) {
150
+ metaTableScenarios . append ( "<tr><th>Failed</th><td>" + ( ( failedCount / scenariosCount ) * 100 ) . toFixed ( 1 ) + " %</td></tr>" ) ;
151
+ scenariosDoughnutCountData . push ( failedCount ) ;
152
+ scenariosDoughnutLabels . push ( "Failed" ) ;
153
+ scenariosDoughnutBackgroundColor . push ( 'rgba(255, 99, 132, 0.2)' ) ;
154
+ scenariosDoughnutBorderColor . push ( 'rgba(255,99,132,1)' ) ;
155
+ }
156
+ if ( skippedCount > 0 ) {
157
+ metaTableScenarios . append ( "<tr><th>Skipped</th><td>" + ( ( skippedCount / scenariosCount ) * 100 ) . toFixed ( 1 ) + " %</td></tr>" ) ;
158
+ scenariosDoughnutCountData . push ( skippedCount ) ;
159
+ scenariosDoughnutLabels . push ( "Skipped" ) ;
160
+ scenariosDoughnutBackgroundColor . push ( 'rgba(255, 206, 86, 0.2)' ) ;
161
+ scenariosDoughnutBorderColor . push ( 'rgba(255, 206, 86, 1)' ) ;
162
+ }
163
+ if ( undefinedCount > 0 ) {
164
+ metaTableScenarios . append ( "<tr><th>Undefined</th><td>" + ( ( undefinedCount / scenariosCount ) * 100 ) . toFixed ( 1 ) + " %</td></tr>" ) ;
165
+ scenariosDoughnutCountData . push ( undefinedCount ) ;
166
+ scenariosDoughnutLabels . push ( "Undefined" ) ;
167
+ scenariosDoughnutBackgroundColor . push ( 'rgba(255, 206, 86, 0.2)' ) ;
168
+ scenariosDoughnutBorderColor . push ( 'rgba(255, 206, 86, 1)' ) ;
169
+ }
170
+ if ( pendingCount > 0 ) {
171
+ metaTableScenarios . append ( "<tr><th>Pending</th><td>" + ( ( pendingCount / scenariosCount ) * 100 ) . toFixed ( 1 ) + " %</td></tr>" ) ;
172
+ scenariosDoughnutCountData . push ( pendingCount ) ;
173
+ scenariosDoughnutLabels . push ( "Pending" ) ;
174
+ scenariosDoughnutBackgroundColor . push ( 'rgba(255, 206, 86, 0.2)' ) ;
175
+ scenariosDoughnutBorderColor . push ( 'rgba(255, 206, 86, 1)' ) ;
176
+ }
177
+ var scenariosDoughnutData = {
178
+ labels : scenariosDoughnutLabels ,
179
+ datasets : [
180
+ {
181
+ label : '# of Votes' ,
182
+ data : scenariosDoughnutCountData ,
183
+ backgroundColor : scenariosDoughnutBackgroundColor ,
184
+ borderColor : scenariosDoughnutBorderColor ,
185
+ borderWidth : 1
186
+ }
187
+ ]
188
+ } ;
189
+ var scenariosDoughnutOptions = {
190
+ title : {
191
+ display : true ,
192
+ text : 'Scenarios'
193
+ }
194
+ } ;
195
+ var scenariosDoughnutChart = new Chart ( scenariosDoughnut , {
196
+ type : 'doughnut' ,
197
+ data : scenariosDoughnutData ,
198
+ options : scenariosDoughnutOptions
199
+ } ) ;
200
+
201
+ if ( scenariosDoughnutCountData . length > 0 ) {
202
+ scenariosDoughnutChart . draw ( ) ;
203
+ }
204
+
205
+ $ . when ( $ ( '#summaryTable' ) . DataTable ( {
206
+ "language" : {
207
+ "search" : "<i class=\"material-icons\">search</i> Search" ,
208
+ "searchPlaceholder" : "Search" ,
209
+ "lengthMenu" : "Show _MENU_" ,
210
+ "info" : "Showing _START_ to _END_ of _TOTAL_ scenarios" ,
211
+ "infoFiltered" : "filtered from _MAX_ total scenarios"
212
+ }
213
+ } ) ) . done ( function ( ) {
214
+ $ ( 'select' ) . material_select ( ) ;
215
+ } ) ;
216
+ } ) ;
0 commit comments