Skip to content

Instantly share code, notes, and snippets.

Created May 13, 2016 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/d48959421679ddfb36c0efe8e6a7bf59 to your computer and use it in GitHub Desktop.
Save anonymous/d48959421679ddfb36c0efe8e6a7bf59 to your computer and use it in GitHub Desktop.
Strava heatmap bookmarklet to load additional entries
function getActivitiesCallback(data){var replaceMode=$("#replaceMode").val();if(replaceMode=="1"){activities=[]}newActivities=[];$("#progressbar").show();showLink(false);if(data==null||data.status==null){alert("Error");return}if(data.status!="OK"){alert("Error: "+data.message);return}if(data.activities.length==0){alert("Warning: No activities found");return}for(var i=0;i<data.activityDetails.length;++i){newActivities.push({id:data.activityDetails[i].id});activities.push({id:data.activityDetails[i].id});activityLookup[data.activityDetails[i].id]=data.activityDetails[i]}activityDetails=data.activityDetails;activityCounter=0;if(replaceMode=="1"){displayedActivities=0}if(newActivities.length>5000){var buttons={"Cancel":function(){$(this).dialog("close")},"Display first 1000 activities (very slow)":function(){$(this).dialog("close");newActivities=newActivities.slice(0,5000);loadActivity()},"Display first 100 activities":function(){$(this).dialog("close");newActivities=newActivities.slice(0,100);loadActivity()}};if(home){buttons["Display all"]=function(){$(this).dialog("close");loadActivity()}}$("#dialogText").html("<p>Your search parameters selected a total of "+newActivities.length+" activities.</p><p>Displaying more than 1000 activities produces an unusable map on most computers. You can choose to display the first 100 activities, display the first 1000 activities (which will be very slow), or cancel and start another search.</p>");$("#dialog-confirm").dialog("option","buttons",buttons);$("#dialog-confirm").dialog("option","title","Found "+newActivities.length+" activities");$("#dialog-confirm").dialog("open")}else if(newActivities.length>100&&displayAllParm!="true"){var buttons={"Cancel":function(){$(this).dialog("close")},"Display all activities (slow)":function(){$(this).dialog("close");loadActivity()},"Display first (oldest) 100 activities":function(){$(this).dialog("close");newActivities=newActivities.slice(0,100);loadActivity()},"Display last (most recent) 100 activities":function(){$(this).dialog("close");newActivities=newActivities.slice(-100);loadActivity()}};$("#dialogText").html("<p>Your search parameters selected a total of "+newActivities.length+" activities.</p><p>Displaying more than 100 activities will take several minutes to load, and the map will be slow on some computers. You can choose to display the first 100 activities, the last 100 activities, display all activities (which will be slow), or cancel and start another search.</p>");$("#dialog-confirm").dialog("option","buttons",buttons);$("#dialog-confirm").dialog("option","title","Found "+newActivities.length+" activities");$("#dialog-confirm").dialog("open")}else{startTime=new Date().getTime();loadActivity()}displayAllParm="false"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment