The Pug Automatic

Nike+ Challenge widget with kilometers

Written January 28, 2007. Tagged OS X, Dashboard widgets.

The Nike+ Challenge widget only displays miles, even if your preference is kilometers. I modified the widget to display kilometers instead. My version only displays kilometers, never miles.

Download here.

Updated 2007-05-04
Now works with the latest version of the widget. Use the download link above.

Small modifications were made to nikepluschallenges.js and utils.js:

--- utils.js
+++ (clipboard)
@@ -166,9 +166,9 @@
else return floatNumber;
}

+// Modified to actually return KM
function getMilesFromKM(kilometers,precision){
- kmToMiles = kilometers / 1.609344;
- return cropFloat(kmToMiles+"",precision);
+ return cropFloat(kilometers+"",precision);
}

function bubblesort2DimArray(arrayList,key){

--- nikepluschallenges.js
+++ (clipboard)
@@ -455,7 +455,7 @@
getProgressInformationDistanceLimit(progress,comparatorValue,isCurrentUser,isWinner);
break;
case "mostDistance":
- challengeDiv += getProgessInformationDistanceTime(progress,leadersProgress,comparatorValue,isCurrentUser,isWinner);
+ challengeDiv += getProgessInformationDistanceTime(progress,leadersProgress,comparatorValue,isCurrentUser,isWinner).replace(/ mi(?=<\/div>)/, ' km');
break;
case "fastestRun":
challengeDiv += getProgressInformationDistanceFastest(progress,leadersProgress,comparatorValue,isCurrentUser,isWinner);

The diff is mainly to illustrate what I changed. Patching straight from it might not work well due to nikepluschallenges.js using \r linebreaks, unlike utils.js and my editor.