Last active
March 10, 2016 12:24
-
-
Save pgericson/fcd41f4e74b68e500d2a to your computer and use it in GitHub Desktop.
Garmin Connect add approximate Strokes Per Minute (SPM)
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
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