Skip to content

Commit

Permalink
Second round of unification/cleanup
Browse files Browse the repository at this point in the history
Remove all the references from the diary helper to `$scope` variables.
These were added back when we displayed common trips
(c393e3d)
in order to avoid duplicating the common trip information between the list view
and the common trips code.

We then used them directly in the UI to format data for display.

However, as part of 30561b9 we changed the template to populate values from trip variables instead of `$scope` functions. So this reassignment is no longer required.

Let's remove them and replace them with direct calls to the diary helper.
  • Loading branch information
shankari committed Oct 4, 2021
1 parent 8a6d4b5 commit a96194d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 52 deletions.
29 changes: 2 additions & 27 deletions www/js/diary/infinite_scroll_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,12 @@ angular.module('emission.main.diary.infscrolllist',['ui-leaflet',
return ($scope.differentCommon(tripgj))? "stop-time-tag-lower" : "stop-time-tag";
}

$scope.getFormattedDistanceInMiles = function(input) {
return (0.621371 * $scope.getFormattedDistance(input)).toFixed(1);
}

$scope.populateBasicClasses = function(tripgj) {
tripgj.display_start_time = DiaryHelper.getLocalTimeString(tripgj.start_local_dt);
tripgj.display_end_time = DiaryHelper.getLocalTimeString(tripgj.end_local_dt);
tripgj.display_distance = $scope.getFormattedDistanceInMiles(tripgj.distance);
tripgj.display_distance = DiaryHelper.getFormattedDistance(tripgj.distance);
tripgj.display_date = moment(tripgj.start_ts * 1000).format('ddd DD MMM YY');
tripgj.display_time = $scope.getFormattedTimeRange(tripgj.start_ts,
tripgj.display_time = DiaryHelper.getFormattedTimeRange(tripgj.start_ts,
tripgj.end_ts);
tripgj.background = "bg-light";
tripgj.listCardClass = $scope.listCardClass(tripgj);
Expand Down Expand Up @@ -355,27 +351,6 @@ angular.module('emission.main.diary.infscrolllist',['ui-leaflet',
$scope.setupInfScroll();
};

$scope.getEarlierOrLater = DiaryHelper.getEarlierOrLater;
$scope.getLongerOrShorter = DiaryHelper.getLongerOrShorter;
$scope.getHumanReadable = DiaryHelper.getHumanReadable;
$scope.getKmph = DiaryHelper.getKmph;
$scope.getPercentages = DiaryHelper.getPercentages;
$scope.getFormattedDistance = DiaryHelper.getFormattedDistance;
$scope.getSectionDetails = DiaryHelper.getSectionDetails;
$scope.getFormattedTime = DiaryHelper.getFormattedTime;
$scope.getFormattedTimeRange = DiaryHelper.getFormattedTimeRange;
$scope.getFormattedDuration = DiaryHelper.getFormattedDuration;
$scope.getTripDetails = DiaryHelper.getTripDetails;
$scope.starColor = DiaryHelper.starColor;
$scope.arrowColor = DiaryHelper.arrowColor;
$scope.getArrowClass = DiaryHelper.getArrowClass;
$scope.isCommon = DiaryHelper.isCommon;
$scope.isDraft = DiaryHelper.isDraft;
// $scope.expandEarlierOrLater = DiaryHelper.expandEarlierOrLater;
// $scope.increaseRestElementsTranslate3d = DiaryHelper.increaseRestElementsTranslate3d;

$scope.parseEarlierOrLater = DiaryHelper.parseEarlierOrLater;

// Tour steps
var tour = {
config: {
Expand Down
28 changes: 3 additions & 25 deletions www/js/diary/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ angular.module('emission.main.diary.list',['ui-leaflet',
$scope.populateBasicClasses = function(tripgj) {
tripgj.display_start_time = DiaryHelper.getLocalTimeString(tripgj.data.properties.start_local_dt);
tripgj.display_end_time = DiaryHelper.getLocalTimeString(tripgj.data.properties.end_local_dt);
tripgj.display_distance = $scope.getFormattedDistance(tripgj.data.properties.distance);
tripgj.display_time = $scope.getFormattedTimeRange(tripgj.data.properties.start_ts,
tripgj.display_distance = DiaryHelper.getFormattedDistance(tripgj.data.properties.distance);
tripgj.display_time = DiaryHelper.getFormattedTimeRange(tripgj.data.properties.start_ts,
tripgj.data.properties.end_ts);
tripgj.isDraft = $scope.isDraft(tripgj);
tripgj.isDraft = DiaryHelper.isDraft(tripgj);
tripgj.background = DiaryHelper.getTripBackground(tripgj);
tripgj.listCardClass = $scope.listCardClass(tripgj);
tripgj.percentages = $scope.getPercentages(tripgj)
Expand Down Expand Up @@ -292,36 +292,14 @@ angular.module('emission.main.diary.list',['ui-leaflet',

$scope.refresh = function() {
readAndUpdateForDay(Timeline.data.currDay);
$scope.$broadcast('invalidateSize');
};

$scope.getEarlierOrLater = DiaryHelper.getEarlierOrLater;
$scope.getLongerOrShorter = DiaryHelper.getLongerOrShorter;
$scope.getHumanReadable = DiaryHelper.getHumanReadable;
$scope.getKmph = DiaryHelper.getKmph;
$scope.getPercentages = DiaryHelper.getPercentages;
$scope.getFormattedDistance = DiaryHelper.getFormattedDistance;
$scope.getSectionDetails = DiaryHelper.getSectionDetails;
$scope.getFormattedTime = DiaryHelper.getFormattedTime;
$scope.getFormattedTimeRange = DiaryHelper.getFormattedTimeRange;
$scope.getFormattedDuration = DiaryHelper.getFormattedDuration;
$scope.getTripDetails = DiaryHelper.getTripDetails;
$scope.starColor = DiaryHelper.starColor;
$scope.arrowColor = DiaryHelper.arrowColor;
$scope.getArrowClass = DiaryHelper.getArrowClass;
$scope.isCommon = DiaryHelper.isCommon;
$scope.isDraft = DiaryHelper.isDraft;
// $scope.expandEarlierOrLater = DiaryHelper.expandEarlierOrLater;
// $scope.increaseRestElementsTranslate3d = DiaryHelper.increaseRestElementsTranslate3d;

$scope.makeCurrent = function() {
$ionicPopup.alert({
template: "Coming soon, after Shankari's quals in early March!"
});
}

$scope.parseEarlierOrLater = DiaryHelper.parseEarlierOrLater;

// Tour steps
var tour = {
config: {
Expand Down
5 changes: 5 additions & 0 deletions www/js/diary/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ angular.module('emission.main.diary.services', ['emission.plugin.logger',
return (dist_in_meters/1000).toFixed(3);
}
}

dh.getFormattedDistanceInMiles = function(input) {
return (0.621371 * dh.getFormattedDistance(input)).toFixed(1);
}

dh.getSectionDetails = function(section) {
var startMoment = moment(section.properties.start_ts * 1000);
var endMoment = moment(section.properties.end_ts * 1000);
Expand Down

0 comments on commit a96194d

Please sign in to comment.