Skip to content

Commit 71fef68

Browse files
committed
Update timer.js
Updated usage without API
1 parent 78f1803 commit 71fef68

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

app/js/timer.js

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ angular.module('timer', [])
66
scope: {
77
interval: '=interval',
88
startTimeAttr: '=startTime',
9-
countdownattr: '=countdown',
10-
fullSeconds: '=fullSeconds',
11-
fullMinutes: '=fullMinutes',
12-
fullHours: '=fullHours'
9+
countdownattr: '=countdown'
1310
},
1411
controller: function ($scope, $element, $attrs) {
1512
//angular 1.2 doesn't support attributes ending in "-start", so we're
@@ -92,25 +89,15 @@ angular.module('timer', [])
9289
});
9390

9491
function calculateTimeUnits() {
95-
if ($scope.fullSeconds === true) {
96-
$scope.seconds = Math.floor($scope.millis / 1000);
97-
} else {
98-
$scope.seconds = Math.floor(($scope.millis / 1000) % 60);
99-
}
100-
101-
if ($scope.fullMinutes === true) {
102-
$scope.minutes = Math.floor($scope.millis / 60000);
103-
} else {
104-
$scope.minutes = Math.floor((($scope.millis / (60000)) % 60));
105-
}
92+
$scope.seconds = Math.floor(($scope.millis / 1000) % 60);
93+
$scope.minutes = Math.floor(($scope.millis / 60000) % 60);
94+
$scope.hours = Math.floor(($scope.millis / 3600000) % 24);
10695

107-
if ($scope.fullHours === true) {
108-
$scope.hours = Math.floor($scope.millis / 3600000);
109-
} else {
110-
$scope.hours = Math.floor((($scope.millis / (3600000)) % 24));
111-
}
96+
$scope.fullSeconds = Math.floor($scope.millis / 1000);
97+
$scope.fullMinutes = Math.floor($scope.millis / 60000);
98+
$scope.fullHours = Math.floor($scope.millis / 3600000);
11299

113-
$scope.days = Math.floor((($scope.millis / (3600000)) / 24));
100+
$scope.days = Math.floor(($scope.millis / 3600000) / 24);
114101
}
115102

116103
//determine initial values of time units

0 commit comments

Comments
 (0)