Created
January 15, 2013 19:53
-
-
Save acconrad/4541454 to your computer and use it in GitHub Desktop.
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
'use strict' | |
# App Module | |
angular.module('myApp', ['myFilters', 'myServices']).config ['$routeProvider', ($routeProvider) -> | |
$routeProvider.when('/users', | |
templateUrl: '<%= asset_path("leaderboard.html") %>' | |
controller: LeaderboardCtrl | |
) | |
] |
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
'use strict' | |
@LeaderboardCtrl = ($scope, User, Utility) -> | |
21$scope.leaders = User.query() | |
$scope.calculatePoints = (points) -> | |
Utility.getRank(points) + ' ' + Utility.getRankName(points) | |
@LeaderboardCtrl.$inject = ['$scope', 'User', 'Utility'] |
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
'use strict' | |
# Services | |
angular.module('nascarStarstreetServices', ['ngResource']).factory('User', ($resource) -> | |
$resource 'users/:userId.json', {}, | |
query: | |
method: 'GET' | |
params: | |
userId: 'users' | |
isArray: true | |
).factory 'Utility', -> | |
getRankName: (points) -> | |
switch parseInt(points, 10) | |
when points <= 1000 | |
'Development Driver' | |
when points > 1000 and points <= 2000 | |
'Truck Series' | |
when points > 2000 and points <= 3000 | |
'Nationwide Series' | |
when points > 3000 and points <= 4000 | |
'Sprint Cup' | |
when points > 4000 | |
'Sprint Cup Champion' | |
getRank: (points) -> | |
switch parseInt(points, 10) | |
when points <= 1000 | |
'<i class="icon-star"></i>' | |
when points > 1000 and points <= 2000 | |
'<i class="icon-star"></i><i class="icon-star"></i>' | |
when points > 2000 and points <= 3000 | |
'<i class="icon-star"></i><i class="icon-star"></i><i class="icon-star"></i>' | |
when points > 3000 and points <= 4000 | |
'<i class="icon-star"></i><i class="icon-star"></i><i class="icon-star"></i><i class="icon-star"></i>' | |
when points > 4000 | |
'<i class="icon-star"></i><i class="icon-star"></i><i class="icon-star"></i><i class="icon-star"></i><i class="icon-star"></i>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment