-
Notifications
You must be signed in to change notification settings - Fork 0
/
leoboard.html
1074 lines (914 loc) · 33.2 KB
/
leoboard.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
<!doctype html>
<html lang="en">
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-12214827-17"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-12214827-17');
</script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<style type="text/css">
.club {
overflow: hidden;
position: relative;
border: solid black 1px;
height: 200px;
}
#districtslidertext {
}
html {
overflow-y: scroll;
-webkit-font-smoothing: antialiased;
-webkit-text-shadow: rgba(0,0,0,.01) 0 0 1px;
/*text-shadow: rgba(0,0,0,.01) 0 0 1px;*/
}
.club .clubname {
position: absolute;
bottom: 2%;
left: 2%;
right: 2%;
text-align: center;
line-height: 90%;
}
.club .goalsmet {
position: absolute;
top: 0;
left: 0;
right: 0;
text-align: center;
font-size: 500%;
-webkit-text-stroke: 1px black;
color: white;
text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}
.club .membershipneeded {
position: absolute;
top: 50%;
left: 0;
right: 0;
text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
text-align: center;
font-size: 300%;
}
div.bycoach {
position: relative;
border: solid black 2px;
}
div.bycoach span.pos {
position: absolute;
top: 1%;
right: 1%;
font-size: 200%;
}
div.bydcp {
position: relative;
border: solid black 2px;
}
div.bydcp span.pos {
position: absolute;
top: 1%;
right: 1%;
font-size: 200%;
}
div.byarea {
position: relative;
border: solid black 2px;
}
div.byarea span.pos {
position: absolute;
bottom: 1%;
right: 1%;
font-size: 200%;
}
div.byarea span.pos span {
display: block;
text-align: right;
}
.ui-tooltip {
max-width: 90%;
width: 500px;
}
.ui-tooltip th {
white-space: nowrap;
padding-right: 20px;
}
.ui-menu {
position: absolute;
width: 100px;
}
.modal {
display: none;
position: fixed;
z-index: 1000;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: rgba( 0, 0, 0, .4 )url('https://code.pachogrande.com/img/FhHRx.gif')50% 50%no-repeat;
}
/* When the body has the loading class, we turn
the scrollbar off with overflow:hidden */
body.loading {
overflow: hidden;
}
/* Anytime the body has the loading class, our
modal element will be visible */
body.loading .modal {
display: block;
}
.progress {
height: 42px;
border: solid black 1px;
}
.progress-bar {
color: black;
text-align: center;
}
</style>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js"></script>
<script src="https://code.pachogrande.com/jqueryui-bootstrap-bridge.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="js/leotools-common.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>LEO Board for District 96</title>
</head>
<body data-district="96">
<nav class="navbar-inverse">
<div class="container-fluid">
<!--<div class="navbar-header">-->
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" id="SortDisplay">Sort <span class="caret"></span></a>
<ul class="dropdown-menu">
<li class="dropdown-header">
Ascending Order
</li>
<li>
<a href="javascript:change_sort('clubnumber', 1)">By Club Number</a>
</li>
<li>
<a href="javascript:change_sort('membership', 1)">By Current Membership</a>
</li>
<li>
<a href="javascript:change_sort('dcpmembership', 1)">By Required Membership For DCP</a>
</li>
<li>
<a href="javascript:change_sort('dcpgoals', 1)">By Current DCP</a>
</li>
<li role="separator" class="divider"></li>
<li class="dropdown-header">
Descending Order
</li>
<li>
<a href="javascript:change_sort('clubnumber', -1)">By Club Number</a>
</li>
<li>
<a href="javascript:change_sort('membership', -1)">By Current Membership</a>
</li>
<li>
<a href="javascript:change_sort('dcpmembership', -1)">By Required Membership For DCP</a>
</li>
<li>
<a href="javascript:change_sort('dcpgoals', -1)">By Current DCP (default)</a>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" id="GroupDisplay">Group <span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<a href="javascript:change_group('none')">No grouping (default)</a>
</li>
<li>
<a href="javascript:change_group('area')">By Area</a>
</li>
<li>
<a href="javascript:change_group('dcp')">By DCP</a>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" id="RenderDisplay">Render (Change Your Colours)<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<a href="javascript:change_rendermode('default')">Change Your Colours (default)</a>
</li>
<li>
<a href="javascript:change_rendermode('member')">Membership</a>
</li>
</ul>
</li>
</ul>
<div class="nav navbar-nav navbar-right">
<button id="helpvideo" type="button" class="btn btn-default navbar-btn" aria-label="Help Video">
<span class="glyphicon glyphicon-film" aria-hidden="true"></span>
</button>
</div>
<!--</div>-->
</div>
</nav>
<div class="container-fluid">
<div class="row districtrow">
<div class="col-xs-3 col-md-1 text-right">District:</div>
<div class="col-xs-9 col-md-11"><input type="range" id="districtslider" list="districtnumbers" /></div>
<div id="districtslidertext" class="col-xs-12 text-center">District 96</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="progress" id="goalsbar"><div class="progress-bar" id="goalsbar_10"></div><div class="progress-bar" id="goalsbar_9"></div><div class="progress-bar" id="goalsbar_8"></div><div class="progress-bar" id="goalsbar_7"></div><div class="progress-bar" id="goalsbar_6"></div><div class="progress-bar" id="goalsbar_5"></div><div class="progress-bar" id="goalsbar_4"></div><div class="progress-bar" id="goalsbar_3"></div><div class="progress-bar" id="goalsbar_2"></div><div class="progress-bar" id="goalsbar_1"></div><div class="progress-bar" id="goalsbar_0"></div></div>
</div>
</div>
</div>
<div id=contentarea class="container-fluid">
</div>
<script>
$(document).on({
ajaxStart: function() { $("body").addClass("loading"); },
ajaxStop: function() { $("body").removeClass("loading"); }
});
function changeto(district)
{
var xhr;
console.log('changeto(district=' + district + ')');
var LT = new Leotools({'district': district});
proxy_url = LT.cors_proxy + LT.current_club_performance_url();
$.ajax({
url: proxy_url,
method: "GET",
dataType: "html",
success: function(res) {
console.log("Successful pull of district=" + district + " via AJAX");
jsonArray = jQuery.parseJSON(res);
columns = jsonArray[0];
coldefs = [];
for(i=0; i<columns.length; i++)
{
baseStr = columns[i];
baseStr = baseStr.replace(/[,.@#$%\^&*=_+"'\/<>\\\|{}\[\]]/g,"");
baseStr = baseStr.replace(/[\t ]+/g,'');
baseStr = baseStr.replace(/\n{1,}/g,'');
baseStr = baseStr.toLowerCase();
// console.log(baseStr);
columns[i] = baseStr;
}
// Shift the header row from the data
jsonArray.shift();
// The last two rows indicate when the information was pulled, pop them out of the way before rendering
jsonArray.pop();
jsonArray.pop();
$("div#contentarea div").remove();
console.log('data has ' + jsonArray.length + ' items in it');
$.each( jsonArray, function( key, v ) {
var val = {};
for(i=0; i<v.length; i++)
{
val[ columns[i] ] = v[i];
}
val['membershiprequired'] = (parseInt(val['membase']) <= 17 ? (parseInt(val['membase']) + 3) : 20 );
val['membershipneeded'] = ( val['activemembers'] - val['membershiprequired'] );
val['coachingeligible'] = parseInt( val['activemembers'] >= 8 && val['activemembers'] <= 12 );
val['advice'] = '';
if(val.goalsmet == 0)
{
val['advice'] = 'A champion could get this club rocking! ';
}
else if(val.goalsmet == 1)
{
val['advice'] = 'A plan and a champion could get this club rocking! ';
}
else if(val.goalsmet == 2)
{
val['advice'] = 'A plan and a champion could get this club rocking! ';
}
else if(val.goalsmet == 3)
{
val['advice'] = 'Two more DCP points till Distinguished Club! ';
}
else if(val.goalsmet == 4)
{
val['advice'] = 'One more DCP point till Distinguished Club! ';
}
else if(val.goalsmet == 5)
{
val['recog'] = 'Distinguished Club! ';
val['next'] = 'Only two more goals until Select Distinguished! ';
val['advice'] = val['recog'] + val['next'];
}
else if(val.goalsmet == 6)
{
val['recog'] = 'Distinguished Club! ';
val['next'] = 'Only one more goal until Select Distinguished! ';
val['advice'] = val['recog'] + val['next'];
}
else if(val.goalsmet == 7)
{
val['recog'] = 'Selected Distinguished Club! ';
val['next'] = 'Only two more goals until Presidents Distinguished! ';
val['advice'] = val['recog'] + val['next'];
}
else if(val.goalsmet == 8)
{
val['recog'] = 'Selected Distinguished Club! ';
val['next'] = 'Only one more goals until Presidents Distinguished! ';
val['advice'] = val['recog'] + val['next'];
}
else if(val.goalsmet == 9)
{
val['recog'] = 'Presidents Distinguished Club! ';
val['next'] = 'Only one more goals until a perfect 10/10! ';
val['advice'] = val['recog'] + val['next'];
}
else if(val.goalsmet == 10)
{
val['recog'] = 'Presidents Distinguished Club! ';
val['next'] = 'Flawless! ';
val['advice'] = val['recog'] + val['next'];
}
if(val['coachingeligible'])
{
val['advice'] += 'Did you know you qualify for a club coach? ';
}
if(val['clubstatus'] == 'Suspended')
{
val['advice'] += '<span class=urgent>You are in danger of losing your club charter - get district help immediately!</span> ';
}
val['retention'] = (parseInt(val['membase']) / (parseInt(val['membase']) + parseInt(val['newmembers']) + parseInt(val['addnewmembers'])));
//console.log(val);
jq = $( "<div class='col-xs-3 col-sm-3 col-md-2 col-lg-1 club' id='club_" + val.clubnumber + "'>" +
"<span class=clubname>" + val.clubname + "</span>" +
"<span class=goalsmet>" + val.goalsmet + "</span>" +
"<span class=membershipneeded>" + ( val.membershipneeded > 0 ? '+' : '' ) + val.membershipneeded + "</span>" +
( val.coaching_eligible >= 1 ? '<span class=coaching_eligible>Coach?</span>' : '' ) +
"</div>" );
$.each( val, function( ekey, eval) {
jq.attr('data-' + ekey, eval);
});
$("div#contentarea").append(jq);
});
}
}).done(function() {
console.log('JSON pull complete, firing done()');
//$(window).resize();
window.clubinfo = Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
$("div.club").each(function(index){
gm = $(this).attr('data-goalsmet');
if(gm == 0) { $(this).css('background-color', 'rgba(100,100,100,0.4)'); window.clubinfo[0]++; }
if(gm == 1) { $(this).css('background-color', 'rgba(255,000,000,0.4)'); window.clubinfo[1]++; }
if(gm == 2) { $(this).css('background-color', 'rgba(255, 64,000,0.4)'); window.clubinfo[2]++; }
if(gm == 3) { $(this).css('background-color', 'rgba(255,127,000,0.4)'); window.clubinfo[3]++; }
if(gm == 4) { $(this).css('background-color', 'rgba(255,255,000,0.4)'); window.clubinfo[4]++; }
if(gm == 5) { $(this).css('background-color', 'rgba(127,255,000,0.4)'); window.clubinfo[5]++; }
if(gm == 6) { $(this).css('background-color', 'rgba(000,255,000,0.4)'); window.clubinfo[6]++; }
if(gm == 7) { $(this).css('background-color', 'rgba(000,255,255,0.4)'); window.clubinfo[7]++; }
if(gm == 8) { $(this).css('background-color', 'rgba(000,127,255,0.4)'); window.clubinfo[8]++; }
if(gm == 9) { $(this).css('background-color', 'rgba(000,000,255,0.4)'); window.clubinfo[9]++; }
if(gm == 10) { $(this).css('background-color', 'rgba(127,000,255,0.4)'); window.clubinfo[10]++; }
mn = $(this).attr('data-membershipneeded');
if(mn < -4) {
$(this).find('span.membershipneeded').css('color', 'rgba(255,000,000,1)');
} else if(mn < 0) {
$(this).find('span.membershipneeded').css('color', 'rgba(255,255,000,1)');
} else if(mn >= 0) {
$(this).find('span.membershipneeded').css('color', 'rgba(000,255,000,1)');
} else {
$(this).find('span.membershipneeded').css('color', 'rgb(255,255,255,1)');
}
});
subtotal = 0;
for(i=0; i<=10; i++)
{
subtotal += window.clubinfo[i];
}
$("#goalsbar_0").css('background-color', 'rgba(100,100,100,0.4)').attr('data-goalsmet', 0);
$("#goalsbar_1").css('background-color', 'rgba(255,000,000,0.4)').attr('data-goalsmet', 1);
$("#goalsbar_2").css('background-color', 'rgba(255, 64,000,0.4)').attr('data-goalsmet', 2);
$("#goalsbar_3").css('background-color', 'rgba(255,127,000,0.4)').attr('data-goalsmet', 3);
$("#goalsbar_4").css('background-color', 'rgba(255,255,000,0.4)').attr('data-goalsmet', 4);
$("#goalsbar_5").css('background-color', 'rgba(127,255,000,0.4)').attr('data-goalsmet', 5);
$("#goalsbar_6").css('background-color', 'rgba(000,255,000,0.4)').attr('data-goalsmet', 6);
$("#goalsbar_7").css('background-color', 'rgba(000,255,255,0.4)').attr('data-goalsmet', 7);
$("#goalsbar_8").css('background-color', 'rgba(000,127,255,0.4)').attr('data-goalsmet', 8);
$("#goalsbar_9").css('background-color', 'rgba(000,000,255,0.4)').attr('data-goalsmet', 9);
$("#goalsbar_10").css('background-color', 'rgba(127,000,255,0.4)').attr('data-goalsmet', 10);
rt=0;
for(i=0; i<=10; i++)
{
pc = window.clubinfo[i] / subtotal * 100;
if(pc > 0)
{
$("#goalsbar_" + i).show().css('width', parseInt(pc*10)/10 + '%').html(i + "<br>" + parseInt(pc*10)/10 + "%");
rt += parseInt(pc*10)/10;
}
else
{
$("#goalsbar_" + i).hide();
}
}
pc = window.clubinfo[0] / subtotal * 100;
$("#goalsbar_" + 0).css('width', (parseInt( (window.clubinfo[0] / subtotal * 100) *10)/10 + (100-rt)) + '%');
change_sort();
change_group();
});;
document.title = 'LEO Board for District ' + district;
//window.history.replaceState("html", document.title, '/leoboard/' + district + '/' + daterange);
$("#districtslidertext").text( 'District ' + district );
}
function change_rendermode(rm)
{
if( (rm == "default") || (rm =="member") )
{
// OK
}
else
{
rm = "default";
}
if( rm == "default" )
{
$("#RenderDisplay")
.html("Render (Change Your Colours) " + '<span class="caret"></span>')
.data('rendertype', rm);
window.clubinfo = Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
$("div.club").each(function(index){
gm = $(this).attr('data-goalsmet');
if(gm == 0) { $(this).css('background-color', 'rgba(100,100,100,0.4)'); window.clubinfo[0]++; }
if(gm == 1) { $(this).css('background-color', 'rgba(255,000,000,0.4)'); window.clubinfo[1]++; }
if(gm == 2) { $(this).css('background-color', 'rgba(255, 64,000,0.4)'); window.clubinfo[2]++; }
if(gm == 3) { $(this).css('background-color', 'rgba(255,127,000,0.4)'); window.clubinfo[3]++; }
if(gm == 4) { $(this).css('background-color', 'rgba(255,255,000,0.4)'); window.clubinfo[4]++; }
if(gm == 5) { $(this).css('background-color', 'rgba(127,255,000,0.4)'); window.clubinfo[5]++; }
if(gm == 6) { $(this).css('background-color', 'rgba(000,255,000,0.4)'); window.clubinfo[6]++; }
if(gm == 7) { $(this).css('background-color', 'rgba(000,255,255,0.4)'); window.clubinfo[7]++; }
if(gm == 8) { $(this).css('background-color', 'rgba(000,127,255,0.4)'); window.clubinfo[8]++; }
if(gm == 9) { $(this).css('background-color', 'rgba(000,000,255,0.4)'); window.clubinfo[9]++; }
if(gm == 10) { $(this).css('background-color', 'rgba(127,000,255,0.4)'); window.clubinfo[10]++; }
mn = $(this).attr('data-membershipneeded');
if(mn < -4) {
$(this).find('span.membershipneeded').css('color', 'rgba(255,000,000,1)');
} else if(mn < 0) {
$(this).find('span.membershipneeded').css('color', 'rgba(255,255,000,1)');
} else if(mn >= 0) {
$(this).find('span.membershipneeded').css('color', 'rgba(000,255,000,1)');
} else {
$(this).find('span.membershipneeded').css('color', 'rgb(255,255,255,1)');
}
});
}
if( rm == "member" )
{
$("#RenderDisplay")
.html("Render (Membership) " + '<span class="caret"></span>')
.data('rendertype', rm);
window.clubinfo = Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
$("div.club").each(function(index){
gm = $(this).attr('data-goalsmet');
if(gm == 0) { window.clubinfo[0]++; }
if(gm == 1) { window.clubinfo[1]++; }
if(gm == 2) { window.clubinfo[2]++; }
if(gm == 3) { window.clubinfo[3]++; }
if(gm == 4) { window.clubinfo[4]++; }
if(gm == 5) { window.clubinfo[5]++; }
if(gm == 6) { window.clubinfo[6]++; }
if(gm == 7) { window.clubinfo[7]++; }
if(gm == 8) { window.clubinfo[8]++; }
if(gm == 9) { window.clubinfo[9]++; }
if(gm == 10) { window.clubinfo[10]++; }
mn = $(this).attr('data-membershipneeded');
if(mn < -4) {
$(this).find('span.membershipneeded').css('color', 'rgba(255,000,000,1)');
$(this).css('background-color', 'rgba(255,000,000,0.4)');
} else if(mn < 0) {
$(this).find('span.membershipneeded').css('color', 'rgba(255,255,000,1)');
$(this).css('background-color', 'rgba(255,255,000,0.4)');
} else if(mn >= 0) {
$(this).find('span.membershipneeded').css('color', 'rgba(000,255,000,1)');
$(this).css('background-color', 'rgba(000,255,000,0.4)');
} else {
$(this).find('span.membershipneeded').css('color', 'rgb(255,255,255,1)');
$(this).css('background-color', 'rgba(255,255,255,0.4)');
}
});
}
}
function display_by_area()
{
if( $("#contentarea div.byarea").length > 0)
{
return;
}
$("div.club").each(function(index) {
division = $(this).attr('data-division');
area = $(this).attr('data-area');
da = division + '_' + area;
if( $("#contentarea div.byarea#" + da).length > 0)
{
$(this).detach().appendTo( $("#contentarea div.byarea#" + da) );
}
else
{
$("#contentarea").append( $("<div class='byarea row' id='" + da + "'><span class='pos'><span class='division'>Division " + division +"</span><span class='area'>Area " + area + "</span></span></div>" ));
$(this).detach();
$("#contentarea div.byarea#" + da).append($(this));
}
});
$("div.byarea").sort(function(a,b){
an = $(a).attr('id');
bn = $(b).attr('id');
return an.localeCompare(bn);
}).each(function(index){
p = $(this).parent();
$(this).detach().appendTo(p);
});
}
function display_by_dcp()
{
if( $("#contentarea div.bydcp").length > 0)
{
return;
}
$("div.club").each(function(index) {
goals = $(this).attr('data-goalsmet');
if( $("#contentarea div.bydcp#bydcp_" + goals).length > 0)
{
$(this).detach().appendTo( $("#contentarea div.bydcp#bydcp_" + goals) );
}
else
{
$("#contentarea").append( $("<div class='bydcp row' id='bydcp_" + goals + "' data-dcp='" + goals + "'><span class='pos'><span class='goals'>Goals " + goals +"</span></span></div>" ));
$(this).detach().appendTo( $("#contentarea div.bydcp#bydcp_" + goals) );
}
});
$("div.bydcp").sort(function(a,b){
an = Math.trunc( $(a).attr('data-dcp') );
bn = Math.trunc( $(b).attr('data-dcp') );
dir = -1;
if(an > bn) { return dir; }
if(an < bn) { return -1 * dir; }
return 0;
}).each(function(index){
p = $(this).parent();
$(this).detach().appendTo(p);
});
}
function display_by_none()
{
$("div.club").each(function(){
ca = $("#contentarea");
$(this).detach().appendTo(ca);
});
$("div.bycoach").remove();
$("div.byarea").remove();
$("div.bydcp").remove();
}
/* Change the current grouping. Explicitly if supplied, otherwise infer from HTML, otherwise assume default */
function change_group(grouptype=null)
{
console.log('change_group(' + grouptype + ')');
if(grouptype == '' || grouptype == null)
{
grouptype = $("#GroupDisplay").data('grouptype');
}
if(grouptype == '' || typeof grouptype == 'undefined')
{
grouptype = 'none';
}
if(grouptype == "none")
{
display_by_none();
$("#GroupDisplay")
.html("Grouping Disabled " + '<span class="caret"></span>')
.data('grouptype', grouptype);
change_sort();
}
if(grouptype == "coach")
{
display_by_none();
display_by_coach();
$("#GroupDisplay")
.html("Grouping By Coaching Status " + '<span class="caret"></span>')
.data('grouptype', grouptype);
change_sort();
}
if(grouptype == "area")
{
display_by_none();
display_by_area();
$("#GroupDisplay")
.html("Grouping By Area " + '<span class="caret"></span>')
.data('grouptype', grouptype);
change_sort();
}
if(grouptype == "dcp")
{
display_by_none();
display_by_dcp();
$("#GroupDisplay")
.html("Grouping By DCP " + '<span class="caret"></span>')
.data('grouptype', grouptype);
change_sort();
}
}
/* Change the current sort type and direction. Explicitly if supplied, otherwise infer from HTML, otherwise assume defaults */
function change_sort(sorttype=null, sortdir=null)
{
//console.log('change_sort(' + sorttype + ', ' + sortdir + ')');
if(sorttype == '' || sorttype == null)
{
sorttype = $("#SortDisplay").data('sorttype');
}
if(sorttype == '' || typeof sorttype == 'undefined')
{
sorttype = 'dcpgoals';
}
if(sortdir == '' || sortdir == null)
{
sortdir = $("#SortDisplay").data('sortdir');
}
if(sortdir == '' || typeof sortdir == 'undefined')
{
sortdir = -1;
}
console.log('inferred sorttype=' + sorttype + ' and sortdir=' + sortdir);
if(sorttype == "clubnumber")
{
sort_by_clubnumber(sortdir);
$("#SortDisplay")
.html("Sorting by Club Number (" + (sortdir == 1 ? 'asc' : 'desc') + ")" + '<span class="caret"></span>')
.data('sorttype', sorttype)
.data('sortdir', sortdir);
}
if(sorttype == "membership")
{
sort_by_membership(sortdir);
$("#SortDisplay")
.html("Sorting by Current Membership (" + (sortdir == 1 ? 'asc' : 'desc') + ")" + '<span class="caret"></span>')
.data('sorttype', sorttype)
.data('sortdir', sortdir);
}
if(sorttype == "dcpgoals")
{
sort_by_clubgoals(sortdir);
$("#SortDisplay")
.html("Sorting by Current DCP (" + (sortdir == 1 ? 'asc' : 'desc') + ")" + '<span class="caret"></span>')
.data('sorttype', sorttype)
.data('sortdir', sortdir);
}
if(sorttype == "dcpmembership")
{
sort_by_dcpmembership(sortdir);
$("#SortDisplay")
.html("Sorting by Required Membership For DCP (" + (sortdir == 1 ? 'asc' : 'desc') + ")" + '<span class="caret"></span>')
.data('sorttype', sorttype)
.data('sortdir', sortdir);
}
}
function sort_by_clubnumber(dir)
{
dir = dir || 1;
$("div.club").sort(function(a,b){
an = Math.trunc( $(a).attr('data-clubnumber') );
bn = Math.trunc( $(b).attr('data-clubnumber') );
if(an > bn) { return dir; }
if(an < bn) { return -1 * dir; }
return 0;
}).each(function(index){
p = $(this).parent();
$(this).detach().appendTo(p);
});
}
function sort_by_dcpmembership(dir)
{
dir = dir || 1;
$("div.club").sort(function(a,b){
an = Math.trunc( $(a).attr('data-membershipneeded') );
bn = Math.trunc( $(b).attr('data-membershipneeded') );
if(an > bn) { return dir; }
if(an < bn) { return -1 * dir; }
return 0;
}).each(function(index){
p = $(this).parent();
$(this).detach().appendTo(p);
});
}
function sort_by_membership(dir)
{
dir = dir || 1;
$("div.club").sort(function(a,b){
an = Math.trunc( $(a).attr('data-activemembers') );
bn = Math.trunc( $(b).attr('data-activemembers') );
if(an > bn) { return dir; }
if(an < bn) { return -1 * dir; }
return 0;
}).each(function(index){
p = $(this).parent();
$(this).detach().appendTo(p);
});
}
function sort_by_clubgoals(dir)
{
dir = dir || 1;
$("div.club").sort(function(a,b){
/* Primary Sort by DCP */
an = Math.trunc( $(a).attr('data-goalsmet') );
bn = Math.trunc( $(b).attr('data-goalsmet') );
if(an > bn) { return dir; }
if(an < bn) { return -1 * dir; }
/* Secondary Sort by membership */
an = Math.trunc( $(a).attr('data-activemembers') );
bn = Math.trunc( $(b).attr('data-activemembers') );
if(an > bn) { return dir; }
if(an < bn) { return -1 * dir; }
return 0;
}).each(function(index){
p = $(this).parent();
$(this).detach().appendTo(p);
});
}
searchParams = new URLSearchParams(window.location.search);
if(searchParams.has('district'))
{
$("BODY").data('district', searchParams.get('district'));
}
window.district = $("BODY").data('district');
function refresh_districts()
{
var LT = new Leotools();
proxy_url = LT.cors_proxy + LT.current_district_summary_url();
$.ajax({
url: proxy_url,
method: "GET",
dataType: "html",
success: function(res)
{
jsonArray = jQuery.parseJSON(res);
jsonArray.shift();
jsonArray.pop();
jsonArray.pop();
district_list = [];
for(i=0; i<jsonArray.length; i++)
{
district_list.push( jsonArray[i][1]);
}
district_list.sort( function cmp_district(a,b) {
cmp_A = '';
if(a == 'F')
{
cmp_A = -1;
}
else if(a == 'U')
{
cmp_A = 500;
}
else
{
cmp_A = parseInt(a);
}
cmp_B = '';
if(b == 'F')
{
cmp_B = -1;
}
else if(b == 'U')
{
cmp_B = 500;
}
else
{
cmp_B = parseInt(b);
}
return (cmp_A > cmp_B) ? 1 : ( (cmp_B > cmp_A) ? -1 : 0 );
}
);
window.districts = district_list;
create_sliders();
}
});
}
function create_sliders()
{
console.log('instantiate sliders');
console.log('window.district=' + window.district);
console.log('window.districts=' + window.districts);
val = -1;
for(i=0;i<=window.districts.length;i++)
{
if(window.district == window.districts[i]) { val = i; }
}
$("#districtslider")
.attr('min', 0)
.attr('max', (window.districts.length-1) )
.val(val)
.on('change', function(){
mydistrict = window.districts[ $('#districtslider').val() ];
console.log('changing district from ' + window.district + ' to ' + mydistrict);
window.district = mydistrict;
window.history.pushState("", "LEO Board for District " + mydistrict, "leoboard.html?district=" + district);
changeto(window.district);
})
.on('input', function(){
val = $(this).val();
text = window.districts[val];
$("#districtslidertext").text( 'District ' + text );
});
changeto(window.district);
}
function pt(num)
{
var out = parseInt(( num * 1000))/10 + '%';
return out;
}
function fx(num,precision)
{
if(!precision) { precision = 10; }
return Math.round((num)*precision)/precision;
}
$(document).uitooltip({
items: "div.club,div#goalsbar div,div.districtrow",
content: function() {
var e = $(this);
if(e.hasClass('club'))
{
out = '<table>';
out += '<tr><td colspan=2><b><u>' + e.attr('data-clubname') + '</u></b></td></tr>';
out += '<tr><th>Club Number</th><td>' + e.attr('data-clubnumber') + '</td></tr>';
out += '<tr><th>Area</th><td>' + e.attr('data-area') + '</td></tr>';
out += '<tr><th>Division</th><td>' + e.attr('data-division') + '</td></tr>';
out += '<tr><th>District</th><td>' + e.attr('data-district') + '</td></tr>';
out += '<tr><th>Membership Base</th><td>' + e.attr('data-membase') + '</td></tr>';
out += '<tr><th>Membership Required</th><td>' + e.attr('data-membershiprequired') + '</td></tr>';
out += '<tr><th>Membership To Date</th><td>' + e.attr('data-activemembers') + '</td></tr>';
out += '<tr><th>Current DCP Goals</th><td>' + e.attr('data-goalsmet') + '</td></tr>';
out += '<tr><th>YTD membership retention</th><td>' + Math.floor(e.attr('data-retention')*100) + '%</td></tr>';
out += '<tr><th>LEO says</th><td>' + e.attr('data-advice') + '</td></tr>';
out += '<tr><th>Current Status</th><td>';
good = '<td style="background-color:#00ff00; border: solid black 1px; text-align: center;" width="10%">';
ok = '<td style="background-color:#ffff00; border: solid black 1px; text-align: center;" width="10%">';
bad = '<td style="background-color:#ff0000; border: solid black 1px; text-align: center;" width="10%">';
t = '<table width=100%><tr>' +
( e.attr('data-level1s') >= 4 ? good : e.attr('data-level1s') == 1 ? ok : bad ) + e.attr('data-level1s') + '</td>' +
( e.attr('data-level2s') >= 2 ? good : e.attr('data-level2s') == 1 ? ok : bad ) + e.attr('data-level2s') + '</td>' +