-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from thisissoon/feature/show-hours-in-track-time
Feature: Show hours in track time
- Loading branch information
Showing
9 changed files
with
85 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use strict"; | ||
/** | ||
* Removes leading 0's from time but leaves | ||
* minutes and seconds intacted | ||
* @module FM.player.removeLeadingZeros | ||
* @author SOON_ | ||
*/ | ||
angular.module("FM.player.removeLeadingZeros", [ | ||
|
||
]) | ||
/** | ||
* @example | ||
* {{ time | date: "H:mm:ss" | removeLeadingZeros }} | ||
* @class removeLeadingZeros | ||
*/ | ||
.filter("removeLeadingZeros", [ | ||
function (){ | ||
return function (input) { | ||
|
||
var s = input; | ||
|
||
if ( s && s.split ){ | ||
var arr = s.split(":"); | ||
|
||
arr.map(function (currentValue, index, arr){ | ||
if ((index < arr.length - 2) && (parseInt(currentValue) === 0)){ | ||
arr.splice(index, 1); | ||
} | ||
}); | ||
|
||
s = arr.join(":"); | ||
} | ||
|
||
return s; | ||
}; | ||
} | ||
]); |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"use strict"; | ||
|
||
describe("FM.player.removeLeadingZeros", function() { | ||
var $scope, filter; | ||
|
||
beforeEach(module("FM.player.removeLeadingZeros")); | ||
|
||
beforeEach(inject(function ($rootScope, $filter, $injector) { | ||
$scope = $rootScope.$new(); | ||
filter = $filter("removeLeadingZeros"); | ||
|
||
})); | ||
|
||
it("should filter times", function(){ | ||
var result = filter("0:03:46"); | ||
expect(result).toEqual("03:46"); | ||
|
||
var result = filter("0:03:00"); | ||
expect(result).toEqual("03:00"); | ||
|
||
var result = filter("1:03:46"); | ||
expect(result).toEqual("1:03:46"); | ||
|
||
var result = filter("1:00:00"); | ||
expect(result).toEqual("1:00:00"); | ||
}); | ||
|
||
it("should NOT filter times", function(){ | ||
var result = filter("3:46"); | ||
expect(result).toEqual("3:46"); | ||
|
||
var result = filter("0:46"); | ||
expect(result).toEqual("0:46"); | ||
|
||
var result = filter(1); | ||
expect(result).toEqual(1); | ||
}); | ||
|
||
|
||
}); |