Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit c805f8a

Browse files
author
Nick Litwin
committed
Add top level topcoder files
1 parent 853aaca commit c805f8a

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

app/topcoder.controller.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
(function() {
2+
'use strict';
3+
4+
angular.module('topcoder').controller('TopcoderController', TopcoderController);
5+
6+
TopcoderController.$inject = ['$window', '$stateParams', 'Auth', 'CONSTANTS', 'ProfileService'];
7+
8+
function TopcoderController() {
9+
var vm = this;
10+
vm.domain = CONSTANTS.domain;
11+
vm.sidebarActive = false;
12+
13+
vm.logout = function() {
14+
Auth.logout(function() {
15+
if($stateParams.challengeId) {
16+
$window.location.href = 'https://www.' + vm.domain + '/challenge-details/' + $stateParams.challengeId + '/?type=develop';
17+
}
18+
});
19+
};
20+
21+
ProfileService.getUserProfile()
22+
.then(function(response) {
23+
vm.profile = response.data;
24+
vm.handleColor = 'color: #000000';
25+
26+
// TODO: Should this be moved to a helper function?
27+
var highestRating = 0;
28+
angular.forEach(response.data.ratingSummary, function(rating) {
29+
if(rating.rating > highestRating) {
30+
highestRating = rating.rating;
31+
vm.handleColor = rating.colorStyle;
32+
}
33+
});
34+
35+
if(vm.profile.photoLink === '') {
36+
vm.profile.photoLink = '//community.topcoder.com/i/m/nophoto_login.gif';
37+
} else {
38+
vm.profile.photoLink = '//community.topcoder.com' + vm.profile.photoLink;
39+
}
40+
});
41+
42+
}
43+
})();

app/topcoder.module.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
(function() {
2+
'use strict';
3+
4+
var dependencies = [
5+
'tc.account',
6+
'ui.router'
7+
];
8+
9+
angular
10+
.module('topcoder', dependencies)
11+
.run(appRun);
12+
13+
appRun.$inject = ['$rootScope', '$state'];
14+
15+
function appRun($rootScope, $state) {
16+
// Attaching $state to the $rootScope allows us to access the
17+
// current state in index.html (see div with ui-view on the index page)
18+
$rootScope.$state = $state;
19+
}
20+
21+
})();

0 commit comments

Comments
 (0)