@@ -37,7 +37,7 @@ exports = module.exports = HTML;
3737
3838var statsTemplate =
3939 '<ul id="mocha-stats">' +
40- '<li class="progress-contain"><progress class="progress-element" max="100" value="0"></progress><svg class="progress-ring"><circle class="ring-whole "/><circle class="ring-highlight" stroke-dasharray="0%,100%"/></svg><div class="progress-text">0%</div></li>' +
40+ '<li class="progress-contain"><progress class="progress-element" max="100" value="0"></progress><svg class="progress-ring"><circle class="ring-flatlight" stroke-dasharray="100%,0% "/><circle class="ring-highlight" stroke-dasharray="0%,100%"/></svg><div class="progress-text">0%</div></li>' +
4141 '<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' +
4242 '<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>' +
4343 '<li class="duration">duration: <em>0</em>s</li>' +
@@ -71,7 +71,10 @@ function HTML(runner, options) {
7171 var stack = [ report ] ;
7272 var progressText = items [ 0 ] . getElementsByTagName ( 'div' ) [ 0 ] ;
7373 var progressBar = items [ 0 ] . getElementsByTagName ( 'progress' ) [ 0 ] ;
74- var progressRing = items [ 0 ] . getElementsByClassName ( 'ring-highlight' ) [ 0 ] ;
74+ var progressRing = [
75+ items [ 0 ] . getElementsByClassName ( 'ring-flatlight' ) [ 0 ] ,
76+ items [ 0 ] . getElementsByClassName ( 'ring-highlight' ) [ 0 ] ] ;
77+ var progressRingRadius = null ; // computed CSS unavailable now, so set later
7578 var root = document . getElementById ( 'mocha' ) ;
7679
7780 if ( ! root ) {
@@ -223,17 +226,21 @@ function HTML(runner, options) {
223226 // setting a toFixed that is too low, makes small changes to progress not shown
224227 // setting it too high, makes the progress text longer then it needs to
225228 // to address this, calculate the toFixed based on the magnitude of total
226- var decmalPlaces = Math . ceil ( Math . log10 ( runner . total / 100 ) ) ;
229+ var decimalPlaces = Math . ceil ( Math . log10 ( runner . total / 100 ) ) ;
227230 text (
228231 progressText ,
229- percent . toFixed ( Math . min ( Math . max ( decmalPlaces , 0 ) , 100 ) ) + '%'
232+ percent . toFixed ( Math . min ( Math . max ( decimalPlaces , 0 ) , 100 ) ) + '%'
230233 ) ;
231234 }
232235 if ( progressRing ) {
233- var radius = 19 ; // to do, figure out how to match with css
236+ var radius = parseFloat ( getComputedStyle ( progressRing [ 0 ] ) . getPropertyValue ( 'r' ) ) ;
234237 var wholeArc = Math . PI * 2 * radius ;
235238 var highlightArc = percent * ( wholeArc / 100 ) ;
236- progressRing . style [ 'stroke-dasharray' ] = `${ highlightArc } px,${ wholeArc } px` ;
239+ // The progress ring is in 2 parts, the flatlight color and highlight color.
240+ // Rendering both on top of the other, seems to make a 3rd color on the edges.
241+ // To create 1 whole ring with 2 colors, both parts are inverse of the other.
242+ progressRing [ 0 ] . style [ 'stroke-dasharray' ] = `0,${ highlightArc } px,${ wholeArc } px` ;
243+ progressRing [ 1 ] . style [ 'stroke-dasharray' ] = `${ highlightArc } px,${ wholeArc } px` ;
237244 }
238245
239246 // update stats
0 commit comments