You'll need to click "laps" before running the bookmarklet.
Last active
August 29, 2015 14:26
-
-
Save bmccormack/7e54b5d23cfa76abbb9e to your computer and use it in GitHub Desktop.
On TomTom Runner MySports site, convert Speed in MPH to Pace in minutes per mile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pad(n, width, z) { | |
z = z || '0'; | |
n = n + ''; | |
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n; | |
} | |
var convertMphToMinPerMile = function(mph){ | |
if (typeof(mph) !== "number"){ | |
mph = Number(mph) | |
} | |
secondsPerMile = 3600.0 / mph | |
minutes = Math.floor(secondsPerMile / 60) | |
seconds = Math.floor(secondsPerMile % 60) | |
minPerMile = minutes + ":" + pad(seconds, 2) | |
return minPerMile | |
} | |
var getSpeedColumn = function(){ | |
header = $('div.splits-laps-table:not(.ng-hide) thead tr th'); | |
var toReturn = ""; | |
header.each(function(index){ | |
//console.log($(this).text()); | |
//console.log($(this).text() === "Speed"); | |
if ($(this).text() === "Speed"){ | |
$(this).text("Pace") | |
toReturn = index; | |
}; | |
}); | |
return toReturn; | |
} | |
var iterateLaps = function(ixSpeedColumn){ | |
trLaps = $('div.splits-data-container:not(.ng-hide) tr[ng-repeat*="lap"]'); | |
trLaps.each(function(index){ | |
tdSpeed = $(this).find('td:eq(' + ixSpeedColumn + ')') | |
sSpeed = $(tdSpeed).text() | |
$(tdSpeed).text(convertMphToMinPerMile(sSpeed)) | |
}); | |
} | |
iterateLaps(getSpeedColumn()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment