Skip to content

Instantly share code, notes, and snippets.

@pgericson
Last active March 10, 2016 12:24
Show Gist options
  • Save pgericson/fcd41f4e74b68e500d2a to your computer and use it in GitHub Desktop.
Save pgericson/fcd41f4e74b68e500d2a to your computer and use it in GitHub Desktop.
Garmin Connect add approximate Strokes Per Minute (SPM)
var col = 11; // this is the column before it will be inserted
$('#intervals-table table thead').find('th').eq(col).after('<td>SPM</td>');
$('#intervals-table table tbody').find('tr').each(function(){
var strokes = parseInt($(this).find('td').eq(12).text().trim());
//console.log(strokes);
var timeString = $(this).find('td').eq(5).text().trim();
//console.log(timeString);
var regex = /(\d{1,2}):(\d{2})/g;
var result = regex.exec(timeString);
var minutes = parseInt(result[1]);
var seconds = parseInt(result[2]);
var totalSeconds = minutes * 60 + seconds;
var spm = (strokes*2 / totalSeconds)*60;
$(this).find('td').eq(col).after('<td>' + String(Math.round(spm * 100) / 100) + '</td>');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment