Skip to content

Instantly share code, notes, and snippets.

@acconrad
Created January 15, 2013 19:53
Show Gist options
  • Save acconrad/4541454 to your computer and use it in GitHub Desktop.
Save acconrad/4541454 to your computer and use it in GitHub Desktop.
'use strict'
# App Module
angular.module('myApp', ['myFilters', 'myServices']).config ['$routeProvider', ($routeProvider) ->
$routeProvider.when('/users',
templateUrl: '<%= asset_path("leaderboard.html") %>'
controller: LeaderboardCtrl
)
]
'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']
<!-- Navigation -->
<div class="navbar navbar-inverse navbar-fixed-top" bs-navbar>
<div class="navbar-inner">
<ul class="nav">
<li data-match-route="/users"><a href="#/users"><i class="icon-list"></i></a>
</ul>
</div>
</div><!--/ Navigation -->
'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