MCPcopy Create free account
hub / github.com/Comcast/Speed-testJS / downloadTest

Function downloadTest

public/speed-testJS.js:274–369  ·  view source on GitHub ↗
(version)

Source from the content-addressed store, hash-verified

272
273
274 function downloadTest(version) {
275 var currentTest = 'download';
276
277 function calculateStatsonComplete(result) {
278 var finalValue = parseFloat(Math.round(result.stats.mean * 100) / 100).toFixed(2);
279 finalValue = (finalValue > 1000) ? parseFloat(finalValue / 1000).toFixed(2) + ' Gbps' : finalValue + ' Mbps';
280 void (version === 'IPv6' && downloadTest('IPv4'));
281
282 if(version==='IPv4'){
283 void (!(testPlan.hasIPv6 === 'IPv6') && setTimeout(function () { !firstRun && uploadTest(testPlan.hasIPv6 ? 'IPv6' : 'IPv4'); }, 500));
284 }
285 //void (!(version === 'IPv6') && uploadTest(testPlan.hasIPv6 ? 'IPv6' : 'IPv4'));
286 updateValue([currentTest, '-', version].join(''), finalValue);
287 }
288
289 function downloadHttpOnComplete(result) {
290
291 var calculateMeanStats = new window.statisticalCalculator(result, false, sliceStartValue, sliceEndValue, calculateStatsonComplete);
292 calculateMeanStats.getResults();
293 }
294
295 function downloadHttpOnProgress(result) {
296 console.log(result)
297document.getElementById("download-progress-result").innerHTML = result.toFixed(2);;
298 }
299
300 function downloadHttpOnAbort(result) {
301 if (version === 'IPv6') {
302 testPlan.hasIPv6 = false;
303 downloadTest('IPv4');
304 return;
305 }
306 //set accessiblity aria-disabled state.
307 //This will also effect the visual look by corresponding css
308 startTestButton.setAttribute('aria-disabled', false);
309 //update button text to communicate current state of test as In Progress
310 startTestButton.innerHTML = 'Start Test';
311 //enable start button
312 startTestButton.disabled = false;
313 }
314
315 function downloadHttpOnTimeout(result) {
316 if (version === 'IPv6') {
317 testPlan.hasIPv6 = false;
318 downloadTest('IPv4');
319 return;
320 }
321 //set accessiblity aria-disabled state.
322 //This will also effect the visual look by corresponding css
323 startTestButton.setAttribute('aria-disabled', false);
324 //update button text to communicate current state of test as In Progress
325 startTestButton.innerHTML = 'Start Test';
326 //enable start button
327 startTestButton.disabled = false;
328 }
329
330 function downloadHttpOnError(result) {
331 if (version === 'IPv6') {

Callers 5

startTestFunction · 0.85
calculateStatsonCompleteFunction · 0.85
downloadHttpOnAbortFunction · 0.85
downloadHttpOnTimeoutFunction · 0.85
downloadHttpOnErrorFunction · 0.85

Calls 2

mobileAndTabletcheckFunction · 0.85

Tested by

no test coverage detected