26
26
window . show_problem = 0 ;
27
27
{ % endif % }
28
28
{ % endif % }
29
- { % if results_json % }
30
- window . results_json = { { results_json } } ;
31
- { % endif % }
32
29
</ script >
33
30
34
31
{% compress js %}
52
49
53
50
< script src ="{{ static('libs/chart.js/Chart.js') }} "> </ script >
54
51
< script type ="text/javascript ">
52
+ var chart = null ;
53
+
54
+ function stats_graph ( raw_data ) {
55
+ var colors = window . results_colors_json ;
56
+
57
+ var ctx = $ ( '#status-graph' ) . find ( 'canvas' ) [ 0 ] . getContext ( '2d' ) ;
58
+ var font = $ ( 'body' ) . css ( 'font-family' ) ;
59
+ if ( chart !== null ) {
60
+ chart . destroy ( ) ;
61
+ }
62
+ chart = new Chart ( ctx , {
63
+ type : 'pie' ,
64
+ data : {
65
+ datasets : [ {
66
+ data : raw_data . categories . map ( function ( entry ) {
67
+ return entry . count ;
68
+ } ) ,
69
+ backgroundColor : raw_data . categories . map ( function ( entry ) {
70
+ return colors [ entry . code ] ;
71
+ } ) ,
72
+ } ] ,
73
+ labels : raw_data . categories . map ( function ( entry ) {
74
+ return entry . name ;
75
+ } ) ,
76
+ } ,
77
+ options : {
78
+ animation : false ,
79
+ scaleFontFamily : font ,
80
+ tooltips : {
81
+ titleFontFamily : font ,
82
+ bodyFontFamily : font ,
83
+ } ,
84
+ legend : {
85
+ display : false ,
86
+ } ,
87
+ } ,
88
+ } ) ;
89
+
90
+ $ ( '#total-submission-count' ) . text ( raw_data . total ) ;
91
+ }
92
+
55
93
$ ( function ( ) {
56
94
var info_float = $ ( '.info-float' ) ;
57
95
var container = $ ( '#content-right' ) ;
90
128
} ) ;
91
129
92
130
// Draw the statistics graph.
93
- { % if results_json % }
131
+ { % if can_show_result_data % }
94
132
$ ( function ( ) {
95
- var chart = null ;
96
- function stats_graph ( raw_data ) {
97
- var colors = { { results_colors_json } } ;
98
-
99
- var ctx = $ ( '#status-graph' ) . find ( 'canvas' ) [ 0 ] . getContext ( '2d' ) ;
100
- var font = $ ( 'body' ) . css ( 'font-family' ) ;
101
- if ( chart !== null ) {
102
- chart . destroy ( ) ;
103
- }
104
- chart = new Chart ( ctx , {
105
- type : 'pie' ,
106
- data : {
107
- datasets : [ {
108
- data : raw_data . categories . map ( function ( entry ) {
109
- return entry . count ;
110
- } ) ,
111
- backgroundColor : raw_data . categories . map ( function ( entry ) {
112
- return colors [ entry . code ] ;
113
- } ) ,
114
- } ] ,
115
- labels : raw_data . categories . map ( function ( entry ) {
116
- return entry . name ;
117
- } ) ,
118
- } ,
119
- options : {
120
- animation : false ,
121
- scaleFontFamily : font ,
122
- tooltips : {
123
- titleFontFamily : font ,
124
- bodyFontFamily : font ,
125
- } ,
126
- legend : {
127
- display : false ,
128
- } ,
129
- } ,
130
- } ) ;
131
-
132
- $ ( '#total-submission-count' ) . text ( raw_data . total ) ;
133
- }
134
- stats_graph ( window . results_json ) ;
133
+ let currentUrl = window . location . href ;
134
+ let separator = currentUrl . includes ( '?' ) ? '&' : '?' ;
135
+ let newUrl = currentUrl + separator + 'results=1' ;
136
+ $ . get ( newUrl , function ( data ) {
137
+ window . results_json = data . results_json ;
138
+ window . results_colors_json = data . results_colors_json ;
139
+ stats_graph ( window . results_json ) ;
140
+ } ) ;
135
141
} ) ;
136
142
{ % endif % }
137
143
</ script >
@@ -320,37 +326,37 @@ <h2>{{content_title}}</h2>
320
326
{% endblock %}
321
327
322
328
{% block right_sidebar %}
323
- {% if results_json %}
324
- < div class ="right-sidebar ">
325
- < div class ="submission ">
326
- < div class ="sidebox ">
327
- < h3 class ="colored-text "> < i class ="fa fa-search "> </ i > {{ _('Filter submissions') }}</ h3 >
328
- < div class ="sidebox-content ">
329
- < form id ="filter-form " name ="form " action ="" method ="get ">
330
- < div class ="filter-form-group ">
331
- < label class ="bold-text margin-label " for ="status "> < i class ="non-italics " > {{ _('Status') }}</ i > </ label >
332
- < select id ="status " name ="status " multiple >
333
- {% for id, name in all_statuses %}
334
- < option {% if id in selected_statuses %}selected{% endif %}
335
- value ="{{ id }} "> {{ name }}</ option >
336
- {% endfor %}
337
- </ select >
338
- </ div >
339
- < div class ="filter-form-group ">
340
- < label class ="bold-text margin-label " for ="language "> < i class ="non-italics "> {{ _('Language') }}</ i > </ label >
341
- < select id ="language " name ="language " multiple >
342
- {% for code, name in all_languages %}
343
- < option {% if code in selected_languages %}selected{% endif %}
344
- value ="{{ code }} "> {{ name }}</ option >
345
- {% endfor %}
346
- </ select >
347
- </ div >
348
- < div class ="form-submit-group " >
349
- < a id ="go " onclick ="form.submit() " class ="button small "> {{ _('Go') }}</ a >
350
- </ div >
351
- </ form >
352
- </ div >
329
+ < div class ="right-sidebar ">
330
+ < div class ="submission ">
331
+ < div class ="sidebox ">
332
+ < h3 class ="colored-text "> < i class ="fa fa-search "> </ i > {{ _('Filter submissions') }}</ h3 >
333
+ < div class ="sidebox-content ">
334
+ < form id ="filter-form " name ="form " action ="" method ="get ">
335
+ < div class ="filter-form-group ">
336
+ < label class ="bold-text margin-label " for ="status "> < i class ="non-italics " > {{ _('Status') }}</ i > </ label >
337
+ < select id ="status " name ="status " multiple >
338
+ {% for id, name in all_statuses %}
339
+ < option {% if id in selected_statuses %}selected{% endif %}
340
+ value ="{{ id }} "> {{ name }}</ option >
341
+ {% endfor %}
342
+ </ select >
343
+ </ div >
344
+ < div class ="filter-form-group ">
345
+ < label class ="bold-text margin-label " for ="language "> < i class ="non-italics "> {{ _('Language') }}</ i > </ label >
346
+ < select id ="language " name ="language " multiple >
347
+ {% for code, name in all_languages %}
348
+ < option {% if code in selected_languages %}selected{% endif %}
349
+ value ="{{ code }} "> {{ name }}</ option >
350
+ {% endfor %}
351
+ </ select >
352
+ </ div >
353
+ < div class ="form-submit-group " >
354
+ < a id ="go " onclick ="form.submit() " class ="button small "> {{ _('Go') }}</ a >
355
+ </ div >
356
+ </ form >
353
357
</ div >
358
+ </ div >
359
+ {% if can_show_result_data %}
354
360
< div class ="sidebox ">
355
361
< div id ="statistics-table ">
356
362
< h3 class ="colored-text "> < i class ="fa fa-pie-chart "> </ i > {{ _('Statistics') }}</ h3 >
@@ -364,9 +370,9 @@ <h3 class="colored-text"><i class="fa fa-pie-chart"></i>{{ _('Statistics') }}</h
364
370
</ div >
365
371
</ div >
366
372
</ div >
367
- </ div >
373
+ {% endif %}
368
374
</ div >
369
- {% endif %}
375
+ </ div >
370
376
{% endblock %}
371
377
372
378
{% block left_sidebar %}
0 commit comments