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

Commit 295c529

Browse files
author
Nick Litwin
committed
Delete moment-timezone from scripts folder and use npm, fix image paths
1 parent 0ea0b1c commit 295c529

File tree

8 files changed

+293
-1313
lines changed

8 files changed

+293
-1313
lines changed

app/filters/local-time.filter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import angular from 'angular'
22
import jstz from 'jstimezonedetect'
3-
import moment from 'moment'
3+
import moment from 'moment-timezone'
44

55
(function() {
66
'use strict'

app/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ require('angular-filter')
1212
require('angular-carousel')
1313
require('angular-intro.js')
1414
require('tc-angular-ellipsis')
15-
require('moment')
1615
require('d3')
1716
require('lodash')
1817
require('zepto/zepto.min.js')

app/profile/badges/badges.controller.js

Lines changed: 92 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,137 +1,130 @@
1+
import angular from 'angular'
2+
import moment from 'moment-timezone'
3+
14
(function () {
2-
'use strict';
5+
'use strict'
6+
7+
angular.module('tc.profile').controller('BadgesController', BadgeCtrl)
38

4-
/**
5-
* The controller for badges section of member-profile page.
6-
*/
7-
var BadgeCtrl = function ($scope, CONSTANTS, ProfileService, UserService, userHandle, profile) {
8-
$scope.achievements = profile.badges.Achievements;
9-
var badgeCtrl = this;
10-
// use logged in user's handle for showing badges if not injected into the controller
11-
badgeCtrl.userHandle = userHandle ? userHandle : UserService.getUserIdentity().username;
12-
badgeCtrl.init($scope);
13-
badgeCtrl.mapBadges();
14-
badgeCtrl.profile = profile;
15-
badgeCtrl.dealWithBadgeData($scope, ProfileService);
9+
BadgeCtrl.$inject = ['$scope', 'CONSTANTS', 'ProfileService', 'UserService', 'userHandle', 'profile']
1610

11+
// The controller for badges section of member-profile page.
12+
function BadgeCtrl($scope, CONSTANTS, ProfileService, UserService, userHandle, profile) {
13+
$scope.achievements = profile.badges.Achievements
14+
var badgeCtrl = this
1715

18-
};
19-
/**
20-
* Deal with badge data when we have the user profile ready.
21-
*/
16+
// Use logged in user's handle for showing badges if not injected into the controller
17+
badgeCtrl.userHandle = userHandle ? userHandle : UserService.getUserIdentity().username
18+
badgeCtrl.init($scope)
19+
badgeCtrl.mapBadges()
20+
badgeCtrl.profile = profile
21+
badgeCtrl.dealWithBadgeData($scope, ProfileService)
22+
}
23+
24+
// Deal with badge data when we have the user profile ready.
2225
BadgeCtrl.prototype.dealWithBadgeData = function($scope, ProfileService){
23-
var badgeCtrl = this;
24-
/*
25-
The service method getUser( handle ) already contains achievements information.
26-
So we don't need another more service method here.
27-
*/
28-
29-
var excluded_badgesID = [1,6, 11, 16, 21, 52, 1000, 1001, 1002, 1003, 1004, 1005, 1006]; // few data is not available, so lets exclude them.
30-
31-
if($scope.achievements) {
26+
var badgeCtrl = this
27+
// The service method getUser( handle ) already contains achievements information.
28+
// So we don't need another more service method here.
29+
30+
// Some data is not available, so lets exclude them.
31+
// var excluded_badgesID = [1,6, 11, 16, 21, 52, 1000, 1001, 1002, 1003, 1004, 1005, 1006]
32+
33+
if ($scope.achievements) {
3234
angular.forEach($scope.achievements, function(achievement){
33-
var desc = achievement.description;
34-
/* Fix Studio Badges */
35+
var desc = achievement.description
36+
// Fix Studio Badges
3537
if(badgeCtrl.map[achievement.description] === undefined && desc.indexOf('Studio ') === 0) {
36-
desc = desc.substring(7);
38+
desc = desc.substring(7)
3739
}
38-
/* Fix Studio bad badge name */
40+
// Fix Studio bad badge name
3941
if(desc === 'Fifty Milestone Prize' || desc === 'One Hundred Milestone Prize' || desc === 'Two Hundred And Fifty Milestone Prize') {
40-
desc = desc + 's';
42+
desc = desc + 's'
4143
}
4244
if(desc.indexOf('Designer of the Month') !== -1) {
43-
desc = 'Designer of the Month';
45+
desc = 'Designer of the Month'
4446
}
4547
if(desc.indexOf('Member of the Month') !== -1) {
46-
desc = 'Member of the Month';
48+
desc = 'Member of the Month'
4749
}
48-
var value = badgeCtrl.map[desc];
49-
//activate all active badges.
50+
var value = badgeCtrl.map[desc]
51+
// Activate all active badges.
5052
if(value){
51-
value.date = badgeCtrl.formatDate(achievement.date);
52-
value.active = true;
53+
value.date = badgeCtrl.formatDate(achievement.date)
54+
value.active = true
5355
if(achievement.description.indexOf('Studio ') === 0) {
54-
value.isStudio = true;
56+
value.isStudio = true
5557
}
5658
}
57-
});
59+
})
5860
}
59-
};
61+
}
6062

61-
/**
62-
* Construct a map contains all badges.
63-
*/
63+
// Construct a map containing all badges.
6464
BadgeCtrl.prototype.mapBadges = function(){
65-
var badgeCtrl = this;
66-
badgeCtrl.map = {};
65+
var badgeCtrl = this
66+
badgeCtrl.map = {}
6767
angular.forEach(badgeCtrl.achievementGroups, function(achievementGroup){
68-
//var achievementGroup = this;
6968
angular.forEach(achievementGroup.specificAchievements, function(achievement){
70-
achievement.id = achievementGroup.id;
71-
badgeCtrl.map[achievement.name] = achievement;
72-
});
73-
});
69+
achievement.id = achievementGroup.id
70+
badgeCtrl.map[achievement.name] = achievement
71+
})
72+
})
7473
angular.forEach(badgeCtrl.singleAchievements, function(achievement){
75-
badgeCtrl.map[achievement.name] = achievement;
76-
});
77-
};
74+
badgeCtrl.map[achievement.name] = achievement
75+
})
76+
}
7877

79-
/**
80-
* Convert the date with format like 'Sep 09,2013'
81-
*/
78+
// Convert the date with format like 'Sep 09,2013'
8279
BadgeCtrl.prototype.formatDate = function(date) {
83-
//some function is passing in undefined timezone_string variable causing js errors,
80+
// Some function is passing in undefined timezone_string variable causing js errors,
8481
// so check if undefined and set default:
8582
if (typeof timezone_string === 'undefined') {
86-
var timezone_string = "America/New_York"; // lets set to TC timezone
83+
var timezone_string = 'America/New_York' // lets set to TC timezone
8784
}
88-
return moment(date).tz(timezone_string).format("MMM DD,YYYY");
89-
};
85+
return moment(date).tz(timezone_string).format('MMM DD,YYYY')
86+
}
9087

91-
/**
92-
* Construct the data 'currentlyEarned'.
93-
*/
88+
// Construct the data 'currentlyEarned'.
9489
BadgeCtrl.prototype.populateData = function(destination, count){
95-
var quantifier = "";
90+
var quantifier = ''
9691
switch(destination.id){
97-
case "1":
98-
quantifier = "Post";
99-
break;
100-
case "6":
101-
quantifier = "Submission";
102-
break;
103-
case "11":
104-
quantifier = "Prize";
105-
break;
106-
case "16":
107-
case "117":
108-
quantifier = "Placement";
109-
break;
110-
case "89":
111-
quantifier = "SRM";
112-
break;
113-
case "99":
114-
case "126":
115-
case "127":
116-
quantifier = "Problem";
117-
break;
118-
default:
119-
quantifier = "Win";
120-
break;
92+
case '1':
93+
quantifier = 'Post'
94+
break
95+
case '6':
96+
quantifier = 'Submission'
97+
break
98+
case '11':
99+
quantifier = 'Prize'
100+
break
101+
case '16':
102+
case '117':
103+
quantifier = 'Placement'
104+
break
105+
case '89':
106+
quantifier = 'SRM'
107+
break
108+
case '99':
109+
case '126':
110+
case '127':
111+
quantifier = 'Problem'
112+
break
113+
default:
114+
quantifier = 'Win'
115+
break
121116
}
122117

123118
if (count && count > 1) {
124-
quantifier += "s";
119+
quantifier += 's'
125120
}
126121
if(count){
127-
destination.currentlyEarned = count + ' ' + quantifier;
122+
destination.currentlyEarned = count + ' ' + quantifier
128123
}
129-
};
130-
/**
131-
* Initialize the data array needed by badge section.
132-
*/
124+
}
125+
// Initialize the data array needed by badge section.
133126
BadgeCtrl.prototype.init = function($scope){
134-
this.scope = $scope;
127+
this.scope = $scope
135128

136129
this.achievementGroups =
137130
[
@@ -533,7 +526,7 @@
533526
}
534527
]
535528
}
536-
];
529+
]
537530

538531
this.singleAchievements =
539532
[
@@ -657,12 +650,6 @@
657650
groupClass : 'Member-of-the-Month',
658651
active : false
659652
}
660-
];
661-
};
662-
663-
angular
664-
.module('tc.profile')
665-
.controller('BadgesController', BadgeCtrl);
666-
667-
BadgeCtrl.$inject = ['$scope', 'CONSTANTS', 'ProfileService', 'UserService', 'userHandle', 'profile'];
668-
})();
653+
]
654+
}
655+
})()

0 commit comments

Comments
 (0)