MCPcopy Create free account
hub / github.com/BloombergGraphics/whatiscode / renderStats

Function renderStats

modules/toc/toc.js:194–218  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

192 }
193
194 function renderStats() {
195
196 var eta = getEstimatedFinishTime();
197
198 if ( isNaN( eta.getTime() ) ) {
199 var etaStr = "the Second Coming, probably"
200 } else {
201 var dateFormat = d3.time.format.multi([
202 ["%H:%M", function(d) { return +d - +new Date() < 24*60*60*1000; }],
203 ["%H:%M on %B %e", function(d) { return +d - +new Date() < 24*60*60*1000*365; }],
204 ["%H:%M on %B %e, %Y", function(d) { return true; }]
205 ]);
206 var etaStr = dateFormat(eta);
207 }
208
209 var statSel = module.sel.select("div.toc-section.stats");
210 if(statSel.empty()) {
211 statSel = module.sel.select("div.toc").append("div.toc-section.stats");
212 }
213
214 statSel.text("You’re averaging "
215 + (getWordsPerMs() * 1000 * 60).toFixed()
216 + " words per minute; at this rate, you’ll finish by "
217 + etaStr + ".");
218 }
219
220 function latest() {
221 return stats.scrollLog[stats.scrollLog.length-1];

Callers 1

toc.jsFile · 0.85

Calls 2

getEstimatedFinishTimeFunction · 0.85
getWordsPerMsFunction · 0.85

Tested by

no test coverage detected