Skip to content

Commit

Permalink
Merge pull request #178 from sunil07t/leaderboard
Browse files Browse the repository at this point in the history
Goals Login UI change, Habitica Leaderboard and Custom tab in Goals screen
  • Loading branch information
shankari authored Nov 2, 2016
2 parents 193f702 + 2352b17 commit 9619f47
Show file tree
Hide file tree
Showing 9 changed files with 411 additions and 37 deletions.
8 changes: 4 additions & 4 deletions www/build/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -6569,18 +6569,18 @@ textarea.option-content {
padding-top: 0em;
}
.herobox.noBackgroundImage {
background: #c5d3d6;
background: #fff;
}
.herobox.noBackgroundImage:hover,
.herobox.noBackgroundImage:focus {
background: #cad7da;
background: #fff;
}
.herobox.noBackgroundImage.isUser {
background: #dae3e5;
background: #fff;
}
.herobox.noBackgroundImage.isUser:hover,
.herobox.noBackgroundImage.isUser:focus {
background: #e0e8e9;
background: #fff;
}
.herobox .addthis_pill_style {
width: 50px !important;
Expand Down
54 changes: 52 additions & 2 deletions www/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,41 @@
.signup-title{
font-size: 2em;
padding: 30px 0 10px 0;
color: #707070
}

.signup-button{
margin-left: auto;
margin-right: auto;
display: block;width: 50%;
}

.button.button-light-green {
border-color: transparent;
background-color: #01D0A7;
color: #fff; }
.button.button-light-green:hover {
color: #fff;
text-decoration: none; }
.button.button-light-green.active, .button.button-gold.activated {
background-color:#01D0A7; }
.button.button-light-green.button-clear {
border-color: transparent;
background: none;
box-shadow: none;
color: #01D0A7; }
.button.button-light-green.button-icon {
border-color: transparent;
background: none; }
.button.button-light-green.button-outline {
border-color: #01D0A7;
background: transparent;
color: #01D0A7; }
.button.button-light-green.button-outline.active, .button.button-gold.button-outline.activated {
background-color: #01D0A7;
box-shadow: none;
color: #fff; }

progress{
margin: 0px;
float: right;
Expand Down Expand Up @@ -203,6 +236,9 @@ img.center {
.item-figure img:first-child, .item-figure .list-figure {
width: 100%;
vertical-align: middle; }
.habit-list-border.item {
border-width: 0.5px !important;
}

/* ngAnimate */
/* The starting CSS styles for the enter animation */
Expand All @@ -228,6 +264,20 @@ img.center {
}
/* ngAnimate ends here */

#leaderboard-stats{
padding-left: 20px;
padding-top: 10px;
}

.leaderboard-card.card{
background: #fff !important;
border-radius: 20px;
display: block;
margin: 10px;
position: relative;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.03), 0 2px 3px rgba(0, 0, 0, 0.05);
}

#costume-tab .button {
border: none !important;
color: #6e6e6e !important;
Expand Down Expand Up @@ -696,7 +746,7 @@ ion-header-bar {
box-shadow: 0 1px 2px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
}
.ion-view-background{
background-color: rgba(238,238,238,0.8) !important;
background-color: #ededed !important;
}
.ion-view-background-dark {
background-color: #303030 !important;
Expand Down Expand Up @@ -1627,7 +1677,7 @@ html, body, #chart2, svg {
border-radius: 2px;
width: 100%;
}
.item {
#no-border.item {
border-width: 0 !important;
}
.item.item-input.item-select {
Expand Down
179 changes: 172 additions & 7 deletions www/js/goals.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ angular.module('emission.main.goals',['emission.services', 'emission.plugin.logg
var floatGold;
var refresh;
var HABITICA_REGISTERED_KEY = 'habitica_registered';
//var challengeMembersId = [];

$rootScope.$on("RELOAD_GOAL_PAGE_FOR_REFERRAL", function(event) {
Logger.log("Received referral event, current state is "+$state.$current.name);
Expand All @@ -42,6 +43,13 @@ angular.module('emission.main.goals',['emission.services', 'emission.plugin.logg
$scope.partyModal = modal;
});

$ionicModal.fromTemplateUrl('templates/goals/leaderboard-modal.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.leaderboardModal = modal;
});

var joinGroupSuccess = function() {
refreshInfo();
var alertPopup = $ionicPopup.alert({
Expand Down Expand Up @@ -122,6 +130,13 @@ angular.module('emission.main.goals',['emission.services', 'emission.plugin.logg
showDelete: false
};*/

$scope.openLeaderboard = function() {
$scope.leaderboardModal.show();
};
$scope.closeLeaderboard = function() {
$scope.leaderboardModal.hide();
};

$scope.openPartyModal = function() {
$scope.partyModal.show();
};
Expand Down Expand Up @@ -184,8 +199,8 @@ angular.module('emission.main.goals',['emission.services', 'emission.plugin.logg
$scope.profile = response.data;
});
console.log("Proxy Sucess");
userId = $scope.profile._id
$scope.exp = $scope.profile.stats.exp
userId = $scope.profile._id;
$scope.exp = $scope.profile.stats.exp;
$scope.gold = Math.round($scope.profile.stats.gp);
floatGold = $scope.profile.stats.gp;
$scope.hp = Math.round($scope.profile.stats.hp);
Expand Down Expand Up @@ -222,6 +237,11 @@ angular.module('emission.main.goals',['emission.services', 'emission.plugin.logg
$scope.joinedChallenges = $scope.profile.challenges;
getParty();
getMembers();
allUsersForLeaderBoard();
/*if($scope.joinedChallenges.length > 0){
getUserChallenges();
getUserChallengeMembers();
}*/
console.log($scope.profile);
prepopulateMessage = {
message: 'Fight the global warming monster with me (link joins group, reshare responsibly)',
Expand Down Expand Up @@ -436,8 +456,8 @@ angular.module('emission.main.goals',['emission.services', 'emission.plugin.logg
});
};

$scope.party = {}
$scope.createParty = function() {
$scope.party = {};
$scope.createParty = function() {
if (!angular.isUndefined($scope.party.name)) {
var callOpts = {'method': 'POST', 'method_url': "/api/v3/groups",
'method_args': {'type': 'party', 'privacy': 'private', 'name': $scope.party.name}}
Expand All @@ -454,7 +474,7 @@ angular.module('emission.main.goals',['emission.services', 'emission.plugin.logg
} else {
$ionicPopup.alert({"template": "Please specify a name"});
}
}
};

var questContent = function(){
var callOpts = {'method': 'GET', 'method_url': "/api/v3/content",
Expand All @@ -474,6 +494,151 @@ angular.module('emission.main.goals',['emission.services', 'emission.plugin.logg
});
};

var users = [];
//var allPartyList = [];
var allUsersForLeaderBoard = function(){
var callOpts = {'method': 'GET', 'method_url': "/api/v3/members/all",
'method_args': null};
CommHelper.habiticaProxy(callOpts).then(function(response){
console.log("Sucessfully got all the users");
var allUsers = response.data;
var ignoreList = ['Superb Girl','Test-em-mri','Test_em-mr','Test_berkeley',
'Abcdef','admin','Ucb.sdb.android.3','Ucb.sdb.android.1','Test'];
users = allUsers.filter(function(obj) {
return ignoreList.indexOf(obj.profile.name) === -1;
});
users = users.filter(function(obj){
return obj.profile.name.slice(0,14).toLowerCase() !== 'e-mission-test';
});
users = roundExp(users);
sortForLeaderboard(users);
users = addRank(users);
console.log("Sucessfully sorted all the users");
var threeUsers = users.slice(0,3);
$scope.topThreeUsers = [];
$scope.topThreeUsers.push(threeUsers[1]);
$scope.topThreeUsers.push(threeUsers[0]);
$scope.topThreeUsers.push(threeUsers[2]);
$scope.usersUnderTopThree = users.slice(3);
//allPartyList = getPatyForAllUsers(users);
console.log($scope.topThreeUsers);
//console.log(allPartyList);
}, function(error){
console.log("Error getting all the users");
console.log(error);
});
};

/*var getPatyForAllUsers = function(users) {
var partys = [];
for (var i = 0; i < users.length; i++) {
if('_id' in users[i].party){
userParty = getPartyById(users[i].party._id);
partys.push(userParty);
} else {
var noPartyObj = {'name': 'Has not joined a Party'};
partys.push(noPartyObj);
}
}
return partys;
};
var getPartyById = function(id) {
var callOpts = {'method': 'GET', 'method_url': "/api/v3/groups/" + id,
'method_args': null};
CommHelper.habiticaProxy(callOpts).then(function(response){
console.log("Sucessfully a user's party");
var partyObj = response.data;
return partyObj;
}, function(error){
console.log("Error when getting a user's party");
});
};*/

var getChallenges = function() {
var callOpts = {'method': 'GET', 'method_url': '/api/v3/challenges/user',
'method_args': null};
$scope.challenges=[];
CommHelper.habiticaProxy(callOpts).then(function(response){
console.log("Got challenges");
$scope.challenges = response.data;
console.log(response.data);
}, function(error){
console.log("Error getting challenges");
console.log(error);
});
};

var roundExp = function(list){
for (var i = 0; i < list.length; i++) {
list[i].stats.exp = Math.round(list[i].stats.exp);
}
return list;
};

var sortForLeaderboard = function(list){
list.sort(function(a, b){
var c = b.stats.lvl - a.stats.lvl;
if (c !== 0)
return c;
return b.stats.exp - a.stats.exp;
});
};

var addRank = function(list){
for (var i = 0; i < list.length; i++) {
list[i].rank = i+1;
}
return list;
};

/*var getUserChallenges = function(){
for(var challenge in $scope.joinedChallenges){
var callOpts = {'method': 'GET', 'method_url': '/api/v3/challenges/' + $scope.joinedChallenges[challenge],
'method_args': null};
CommHelper.habiticaProxy(callOpts).then(function(response){
console.log("Got user's challenges");
console.log(response.data);
}, function(error){
console.log("Error getting user's challenges");
console.log(error);
});
}
};
var getUserChallengeMembers = function() {
for(var challenge in $scope.joinedChallenges){
var callOpts = {'method': 'GET', 'method_url': '/api/v3/challenges/' + $scope.joinedChallenges[challenge]+'/members?includeAllMembers=true',
'method_args': null};
CommHelper.habiticaProxy(callOpts).then(function(response){
console.log("Got joined challenges' members");
var members = response.data;
members.forEach(function(user){
challengeMembersId.push(user.id);
});
console.log(challengeMembersId);
getchallengeMemberProfile();
}, function(error){
console.log("Error getting joined challenges' member");
console.log(error);
});
}
};
var getchallengeMemberProfile = function() {
for(var memberId in challengeMembersId){
var callOpts = {'method': 'GET', 'method_url': '/api/v3/members/' + challengeMembersId[memberId],
'method_args': null};
CommHelper.habiticaProxy(callOpts).then(function(response){
console.log("Got challenge members' profile");
console.log(response.data);
}, function(error){
console.log("Error getting challenge members' profile");
console.log(error);
});
}
};*/

var getMembers = function() {
var callOpts = {'method': 'GET', 'method_url': "/api/v3/groups/"+partyId+"/members?includeAllPublicFields=true",
'method_args': null};
Expand All @@ -492,7 +657,7 @@ angular.module('emission.main.goals',['emission.services', 'emission.plugin.logg
});
};

var bikeChallenge = function() {
/*var bikeChallenge = function() {
var callOpts = {'method': 'GET', 'method_url': "/api/v3/challenges/8a8134d6-066d-424d-8f3d-0b559c2c1e78",
'method_args': null};
Expand Down Expand Up @@ -536,7 +701,7 @@ angular.module('emission.main.goals',['emission.services', 'emission.plugin.logg
bikeChallenge();
carpoolChallenge();
publicTransChallenge();
};
};*/

$scope.joinChallenge = function(challengeId) {
var callOpts = {'method': 'POST', 'method_url': "/api/v3/challenges/"+challengeId+"/join",
Expand Down
4 changes: 2 additions & 2 deletions www/templates/diary/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

<div class="col-70">

<div class="item item-icon-left" href="#" style="font-size: 1em; padding-top: 5px; padding-bottom: 5px;padding-left: 25px; margin-top: 0; margin-bottom: {{getEarlierOrLater(tripgj.data.properties.start_ts, tripgj.data.id) == ''? '0':'20px'}};">
<div class="item item-icon-left" id="no-border" href="#" style="font-size: 1em; padding-top: 5px; padding-bottom: 5px;padding-left: 25px; margin-top: 0; margin-bottom: {{getEarlierOrLater(tripgj.data.properties.start_ts, tripgj.data.id) == ''? '0':'20px'}};">
<i class="icon ion-ios-location" style="font-size: 16px; left: 0; color: #33e0bb;"></i>
{{tripgj.start_place.properties.displayName.split(',')[0]}}

</div>
<div class="item item-icon-left" href="#" style="font-size: 1em; padding-top: 5px; padding-bottom: 5px;padding-left: 25px; margin-top: 0; margin-bottom: 0;">
<div class="item item-icon-left" id="no-border" href="#" style="font-size: 1em; padding-top: 5px; padding-bottom: 5px;padding-left: 25px; margin-top: 0; margin-bottom: 0;">
<i class="icon ion-ios-location" style="font-size: 16px; left: 0; color: #ff5251;"></i>
{{tripgj.end_place.properties.displayName.split(',')[0]}}
</div>
Expand Down
Loading

0 comments on commit 9619f47

Please sign in to comment.