1- $ ( document ) . ready ( function ( ) {
2- var $pc = $ ( '#progressController' ) ;
3- var $pCaption = $ ( '.progress-bar p' ) ;
4- var iProgress = document . getElementById ( 'inactiveProgress' ) ;
5- var aProgress = document . getElementById ( 'activeProgress' ) ;
6- var iProgressCTX = iProgress . getContext ( '2d' ) ;
1+ // $(document).ready(function(){
2+ // var $pc = $('#progressController');
3+ // var $pCaption = $('.progress-bar p');
4+ // var iProgress = document.getElementById('inactiveProgress');
5+ // var aProgress = document.getElementById('activeProgress');
6+ // var iProgressCTX = iProgress.getContext('2d');
7+
78
8-
9- drawInactive ( iProgressCTX ) ;
10-
11- $pc . on ( 'change' , function ( ) {
12- var percentage = $ ( this ) . val ( ) / 100 ;
13- console . log ( percentage + '%' ) ;
14- drawProgress ( aProgress , percentage , $pCaption ) ;
15- } ) ;
9+ // drawInactive(iProgressCTX);
1610
17- function drawInactive ( iProgressCTX ) {
18- iProgressCTX . lineCap = 'square' ;
11+ // $pc.on('change', function(){
12+ // var percentage = $(this).val() / 100;
13+ // console.log(percentage + '%');
14+ // drawProgress(aProgress, percentage, $pCaption);
15+ // });
16+ // });
1917
20- //outer ring
21- iProgressCTX . beginPath ( ) ;
22- iProgressCTX . lineWidth = 15 ;
23- iProgressCTX . strokeStyle = '#e1e1e1' ;
24- iProgressCTX . arc ( 137.5 , 137.5 , 129 , 0 , 2 * Math . PI ) ;
25- iProgressCTX . stroke ( ) ;
18+ // var $pc = $('#progressController');
19+ var $pCaption = $ ( '.progress-bar p' ) ;
20+ var iProgress = document . getElementById ( 'inactiveProgress' ) ;
21+ var aProgress = document . getElementById ( 'activeProgress' ) ;
22+ var iProgressCTX = iProgress . getContext ( '2d' ) ;
23+
24+ $ ( document ) . ready ( function ( ) {
25+ drawInactive ( iProgressCTX ) ;
26+ } ) ;
2627
27- //progress bar
28- iProgressCTX . beginPath ( ) ;
29- iProgressCTX . lineWidth = 0 ;
30- iProgressCTX . fillStyle = '#e6e6e6' ;
31- iProgressCTX . arc ( 137.5 , 137.5 , 121 , 0 , 2 * Math . PI ) ;
32- iProgressCTX . fill ( ) ;
28+ function drawInactive ( iProgressCTX ) {
29+ iProgressCTX . lineCap = 'square' ;
3330
34- //progressbar caption
35- iProgressCTX . beginPath ( ) ;
36- iProgressCTX . lineWidth = 0 ;
37- iProgressCTX . fillStyle = '#fff ' ;
38- iProgressCTX . arc ( 137.5 , 137.5 , 100 , 0 , 2 * Math . PI ) ;
39- iProgressCTX . fill ( ) ;
31+ //outer ring
32+ iProgressCTX . beginPath ( ) ;
33+ iProgressCTX . lineWidth = 15 ;
34+ iProgressCTX . strokeStyle = '#e1e1e1 ' ;
35+ iProgressCTX . arc ( 137.5 , 137.5 , 129 , 0 , 2 * Math . PI ) ;
36+ iProgressCTX . stroke ( ) ;
4037
41- }
42- function drawProgress ( bar , percentage , $pCaption ) {
43- var barCTX = bar . getContext ( "2d" ) ;
44- var quarterTurn = Math . PI / 2 ;
45- var endingAngle = ( ( 2 * percentage ) * Math . PI ) - quarterTurn ;
46- var startingAngle = 0 - quarterTurn ;
38+ //progress bar
39+ iProgressCTX . beginPath ( ) ;
40+ iProgressCTX . lineWidth = 0 ;
41+ iProgressCTX . fillStyle = '#e6e6e6' ;
42+ iProgressCTX . arc ( 137.5 , 137.5 , 121 , 0 , 2 * Math . PI ) ;
43+ iProgressCTX . fill ( ) ;
4744
48- bar . width = bar . width ;
49- barCTX . lineCap = 'square' ;
45+ //progressbar caption
46+ iProgressCTX . beginPath ( ) ;
47+ iProgressCTX . lineWidth = 0 ;
48+ iProgressCTX . fillStyle = '#fff' ;
49+ iProgressCTX . arc ( 137.5 , 137.5 , 100 , 0 , 2 * Math . PI ) ;
50+ iProgressCTX . fill ( ) ;
5051
51- barCTX . beginPath ( ) ;
52- barCTX . lineWidth = 20 ;
53- barCTX . strokeStyle = '#76e1e5' ;
54- barCTX . arc ( 137.5 , 137.5 , 111 , startingAngle , endingAngle ) ;
55- barCTX . stroke ( ) ;
52+ }
53+ function drawProgress ( bar , percentage , $pCaption ) {
54+ var barCTX = bar . getContext ( "2d" ) ;
55+ var quarterTurn = Math . PI / 2 ;
56+ var endingAngle = ( ( 2 * percentage ) * Math . PI ) - quarterTurn ;
57+ var startingAngle = 0 - quarterTurn ;
5658
57- $pCaption . text ( ( parseInt ( percentage * 100 , 10 ) ) + '%' ) ;
58- }
59+ bar . width = bar . width ;
60+ barCTX . lineCap = 'square' ;
5961
60- var percentage = $pc . val ( ) / 100 ;
61- drawProgress ( aProgress , percentage , $pCaption ) ;
62+ barCTX . beginPath ( ) ;
63+ barCTX . lineWidth = 20 ;
64+ barCTX . strokeStyle = '#76e1e5' ;
65+ barCTX . arc ( 137.5 , 137.5 , 111 , startingAngle , endingAngle ) ;
66+ barCTX . stroke ( ) ;
6267
63-
64- } ) ;
68+ $pCaption . text ( ( parseInt ( percentage * 100 , 10 ) ) + '%' ) ;
69+ }
0 commit comments