mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Merge branch 'develop' into Hus274-7688
This commit is contained in:
@@ -19,7 +19,6 @@ angular.module('habitrpg')
|
||||
if(!err) $scope.registrationInProgress = false;
|
||||
Analytics.login();
|
||||
Analytics.updateUser();
|
||||
Analytics.track({'hitType':'event','eventCategory':'behavior','eventAction':'login'});
|
||||
$window.location.href = ('/' + window.location.hash);
|
||||
});
|
||||
};
|
||||
@@ -62,6 +61,7 @@ angular.module('habitrpg')
|
||||
|
||||
$http.post(url, scope.registerVals).success(function(res, status, headers, config) {
|
||||
runAuth(res.data._id, res.data.apiToken);
|
||||
Analytics.register();
|
||||
}).error(errorAlert);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User', 'Challenges', 'Notification', '$compile', 'Groups', '$state', '$stateParams', 'Members', 'Tasks', 'TAVERN_ID',
|
||||
function($rootScope, $scope, Shared, User, Challenges, Notification, $compile, Groups, $state, $stateParams, Members, Tasks, TAVERN_ID) {
|
||||
habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User', 'Tasks', 'Challenges', 'Notification', '$compile', 'Groups', '$state', '$stateParams', 'Members', 'Tasks', 'TAVERN_ID',
|
||||
function($rootScope, $scope, Shared, User, Tasks, Challenges, Notification, $compile, Groups, $state, $stateParams, Members, Tasks, TAVERN_ID) {
|
||||
|
||||
// Use presence of cid to determine whether to show a list or a single
|
||||
// challenge
|
||||
@@ -37,6 +37,22 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
|
||||
$scope.editTask = Tasks.editTask;
|
||||
$scope.cancelTaskEdit = Tasks.cancelTaskEdit;
|
||||
|
||||
$scope.canEdit = function(task) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$scope.doubleClickTask = function (obj, task) {
|
||||
if (obj._locked) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (task._editing) {
|
||||
$scope.saveTask(task);
|
||||
} else {
|
||||
$scope.editTask(task);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create
|
||||
*/
|
||||
@@ -278,7 +294,7 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
|
||||
angular.copy(task._edit, task);
|
||||
task._edit = undefined;
|
||||
task._editing = false;
|
||||
// TODO persist
|
||||
Tasks.updateTask(task._id, task);
|
||||
}
|
||||
|
||||
$scope.toggleBulk = function(list) {
|
||||
@@ -361,7 +377,7 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
|
||||
|
||||
_calculateMaxPrize(gid);
|
||||
|
||||
if (gid == TAVERN_ID) {
|
||||
if (gid == TAVERN_ID && !($scope.newChallenge.prize > 0)) {
|
||||
$scope.newChallenge.prize = 1;
|
||||
}
|
||||
})
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
habitrpg.controller('ChatCtrl', ['$scope', 'Groups', 'Chat', 'User', '$http', 'ApiUrl', 'Notification', 'Members', '$rootScope', 'Analytics',
|
||||
function($scope, Groups, Chat, User, $http, ApiUrl, Notification, Members, $rootScope, Analytics){
|
||||
if ($scope.group) {
|
||||
Chat.markChatSeen($scope.group.id);
|
||||
}
|
||||
$scope.message = {content:''};
|
||||
$scope._sending = false;
|
||||
|
||||
@@ -26,12 +29,17 @@ habitrpg.controller('ChatCtrl', ['$scope', 'Groups', 'Chat', 'User', '$http', 'A
|
||||
$scope.postChat = function(group, message){
|
||||
if (_.isEmpty(message) || $scope._sending) return;
|
||||
$scope._sending = true;
|
||||
var previousMsg = (group.chat && group.chat[0]) ? group.chat[0].id : false;
|
||||
Chat.postChat(group._id, message, previousMsg)
|
||||
// var previousMsg = (group.chat && group.chat[0]) ? group.chat[0].id : false;
|
||||
Chat.postChat(group._id, message) //, previousMsg) not sending the previousMsg as we have real time updates
|
||||
.then(function(response) {
|
||||
var message = response.data.data.message;
|
||||
|
||||
group.chat.unshift(message);
|
||||
if (message) {
|
||||
group.chat.unshift(message);
|
||||
group.chat.splice(200);
|
||||
} else {
|
||||
group.chat = response.data.data.chat;
|
||||
}
|
||||
|
||||
$scope.message.content = '';
|
||||
$scope._sending = false;
|
||||
@@ -86,13 +94,12 @@ habitrpg.controller('ChatCtrl', ['$scope', 'Groups', 'Chat', 'User', '$http', 'A
|
||||
} else {
|
||||
$scope.abuseObject = message;
|
||||
$scope.groupId = groupId;
|
||||
Members.selectMember(message.uuid)
|
||||
.then(function () {
|
||||
$rootScope.openModal('abuse-flag',{
|
||||
controller:'MemberModalCtrl',
|
||||
scope: $scope
|
||||
});
|
||||
});
|
||||
|
||||
$scope.isSystemMessage = message.uuid === 'system';
|
||||
$rootScope.openModal('abuse-flag',{
|
||||
controller:'MemberModalCtrl',
|
||||
scope: $scope
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
habitrpg.controller("GuildsCtrl", ['$scope', 'Groups', 'User', 'Challenges', '$rootScope', '$state', '$location', '$compile', 'Analytics',
|
||||
function($scope, Groups, User, Challenges, $rootScope, $state, $location, $compile, Analytics) {
|
||||
habitrpg.controller("GuildsCtrl", ['$scope', 'Groups', 'User', 'Challenges', '$rootScope', '$state', '$location', '$compile', 'Analytics', 'Pusher',
|
||||
function($scope, Groups, User, Challenges, $rootScope, $state, $location, $compile, Analytics, Pusher) {
|
||||
$scope.groups = {
|
||||
guilds: [],
|
||||
public: [],
|
||||
@@ -34,11 +34,6 @@ habitrpg.controller("GuildsCtrl", ['$scope', 'Groups', 'User', 'Challenges', '$r
|
||||
Groups.Group.create(group)
|
||||
.then(function (response) {
|
||||
var createdGroup = response.data.data;
|
||||
if (createdGroup.privacy == 'public') {
|
||||
Analytics.track({'hitType':'event', 'eventCategory':'behavior', 'eventAction':'join group', 'owner':true, 'groupType':'guild', 'privacy': createdGroup.privacy, 'groupName':createdGroup.name})
|
||||
} else {
|
||||
Analytics.track({'hitType':'event', 'eventCategory':'behavior', 'eventAction':'join group', 'owner':true, 'groupType':'guild', 'privacy': createdGroup.privacy})
|
||||
}
|
||||
$rootScope.hardRedirect('/#/options/groups/guilds/' + createdGroup._id);
|
||||
});
|
||||
}
|
||||
@@ -59,12 +54,6 @@ habitrpg.controller("GuildsCtrl", ['$scope', 'Groups', 'User', 'Challenges', '$r
|
||||
|
||||
User.user.guilds.push(joinedGroup._id);
|
||||
|
||||
if (joinedGroup.privacy == 'public') {
|
||||
Analytics.track({'hitType':'event', 'eventCategory':'behavior', 'eventAction':'join group', 'owner':false, 'groupType':'guild','privacy': joinedGroup.privacy, 'groupName': joinedGroup.name})
|
||||
} else {
|
||||
Analytics.track({'hitType':'event', 'eventCategory':'behavior', 'eventAction':'join group', 'owner':false, 'groupType':'guild','privacy': joinedGroup.privacy})
|
||||
}
|
||||
|
||||
_.pull(User.user.invitations.guilds, group);
|
||||
|
||||
$location.path('/options/groups/guilds/' + joinedGroup._id);
|
||||
|
||||
@@ -62,6 +62,16 @@ habitrpg.controller("InventoryCtrl",
|
||||
|
||||
var item = Content.gear.flat[key];
|
||||
|
||||
var bonusMultiplier = 1;
|
||||
if (_isClassItem(item)) {
|
||||
bonusMultiplier = 1.5;
|
||||
}
|
||||
|
||||
item._effectiveStr = item.str * bonusMultiplier;
|
||||
item._effectiveCon = item.con * bonusMultiplier;
|
||||
item._effectivePer = item.per * bonusMultiplier;
|
||||
item._effectiveInt = item.int * bonusMultiplier;
|
||||
|
||||
if (!$scope.gearByClass[item.klass]) {
|
||||
$scope.gearByClass[item.klass] = [];
|
||||
}
|
||||
@@ -307,6 +317,12 @@ habitrpg.controller("InventoryCtrl",
|
||||
});
|
||||
};
|
||||
|
||||
$scope.classBonusNotes = function (item) {
|
||||
if (_isClassItem(item)) {
|
||||
return window.env.t('classBonus');
|
||||
}
|
||||
};
|
||||
|
||||
$scope.hasAllTimeTravelerItems = function() {
|
||||
return ($scope.hasAllTimeTravelerItemsOfType('mystery') &&
|
||||
$scope.hasAllTimeTravelerItemsOfType('pets') &&
|
||||
@@ -336,6 +352,11 @@ habitrpg.controller("InventoryCtrl",
|
||||
User.hourglassPurchase({params:{type:type,key:key}});
|
||||
};
|
||||
|
||||
$scope.marketShopCategories = Shared.shops.getMarketCategories(user);
|
||||
$scope.questShopCategories = Shared.shops.getQuestShopCategories(user);
|
||||
$scope.timeTravelersCategories = Shared.shops.getTimeTravelersCategories(user);
|
||||
$scope.seasonalShopCategories = Shared.shops.getSeasonalShopCategories(user);
|
||||
|
||||
function _updateDropAnimalCount(items) {
|
||||
$scope.petCount = Shared.count.beastMasterProgress(items.pets);
|
||||
$scope.mountCount = Shared.count.mountMasterProgress(items.mounts);
|
||||
@@ -348,5 +369,11 @@ habitrpg.controller("InventoryCtrl",
|
||||
var selection = Math.floor(random);
|
||||
return env.t(kind + selection);
|
||||
}
|
||||
|
||||
function _isClassItem(item) {
|
||||
var userClass = user.stats.class;
|
||||
|
||||
return item.klass === userClass || item.specialClass === userClass;
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
@@ -29,6 +29,32 @@ angular.module('habitrpg')
|
||||
$scope.clearMessages = Chat.markChatSeen;
|
||||
$scope.clearCards = Chat.clearCards;
|
||||
|
||||
$scope.getNotificationsCount = function() {
|
||||
var count = 0;
|
||||
|
||||
if($scope.user.invitations.party && $scope.user.invitations.party.id){
|
||||
count++;
|
||||
}
|
||||
|
||||
if($scope.user.purchased.plan && $scope.user.purchased.plan.mysteryItems.length){
|
||||
count++;
|
||||
}
|
||||
|
||||
if($scope.user.invitations.guilds){
|
||||
count += $scope.user.invitations.guilds.length;
|
||||
}
|
||||
|
||||
if($scope.user.flags.classSelected && !$scope.user.preferences.disableClasses && $scope.user.stats.points){
|
||||
count += $scope.user.stats.points > 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
if($scope.user.newMessages) {
|
||||
count += Object.keys($scope.user.newMessages).length;
|
||||
}
|
||||
|
||||
return count;
|
||||
};
|
||||
|
||||
$scope.iconClasses = function() {
|
||||
return selectNotificationValue(
|
||||
'glyphicon-gift',
|
||||
|
||||
@@ -97,7 +97,9 @@ habitrpg.controller('NotificationCtrl',
|
||||
$rootScope.openModal('rebirthEnabled');
|
||||
break;
|
||||
case 'WON_CHALLENGE':
|
||||
$rootScope.openModal('wonChallenge', {controller: 'UserCtrl', size: 'sm'});
|
||||
User.sync().then( function() {
|
||||
$rootScope.openModal('wonChallenge', {controller: 'UserCtrl', size: 'sm'});
|
||||
});
|
||||
break;
|
||||
case 'STREAK_ACHIEVEMENT':
|
||||
Notification.streak(User.user.achievements.streak);
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','Challenges','$state','$compile','Analytics','Quests','Social',
|
||||
function($rootScope, $scope, Groups, Chat, User, Challenges, $state, $compile, Analytics, Quests, Social) {
|
||||
habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','Challenges','$state','$compile','Analytics','Quests','Social', 'Pusher',
|
||||
function($rootScope, $scope, Groups, Chat, User, Challenges, $state, $compile, Analytics, Quests, Social, Pusher) {
|
||||
|
||||
var PARTY_LOADING_MESSAGES = 4;
|
||||
|
||||
var user = User.user;
|
||||
|
||||
$scope.type = 'party';
|
||||
$scope.text = window.env.t('party');
|
||||
$scope.group = {loadingParty: true}
|
||||
$scope.group = {loadingParty: true};
|
||||
|
||||
$scope.inviteOrStartParty = Groups.inviteOrStartParty;
|
||||
$scope.loadWidgets = Social.loadWidgets;
|
||||
|
||||
// Random message between 1 and PARTY_LOADING_MESSAGES
|
||||
var partyMessageNumber = Math.floor(Math.random() * PARTY_LOADING_MESSAGES) + 1;
|
||||
$scope.partyLoadingMessage = window.env.t('partyLoading' + partyMessageNumber);
|
||||
|
||||
function handlePartyResponse (group) {
|
||||
$rootScope.party = $scope.group = group;
|
||||
checkForNotifications();
|
||||
@@ -53,7 +59,6 @@ habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','
|
||||
if (!group.name) group.name = env.t('possessiveParty', {name: User.user.profile.name});
|
||||
Groups.Group.create(group)
|
||||
.then(function(response) {
|
||||
Analytics.track({'hitType':'event', 'eventCategory':'behavior', 'eventAction':'join group', 'owner':true, 'groupType':'party', 'privacy':'private'});
|
||||
Analytics.updateUser({'party.id': $scope.group ._id, 'partySize': 1});
|
||||
$rootScope.hardRedirect('/#/options/groups/party');
|
||||
});
|
||||
@@ -64,7 +69,6 @@ habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','
|
||||
.then(function (response) {
|
||||
$rootScope.party = $scope.group = response.data.data;
|
||||
User.sync();
|
||||
Analytics.track({'hitType':'event','eventCategory':'behavior','eventAction':'join group','owner':false,'groupType':'party','privacy':'private'});
|
||||
Analytics.updateUser({'partyID': party.id});
|
||||
$rootScope.hardRedirect('/#/options/groups/party');
|
||||
});
|
||||
|
||||
@@ -7,20 +7,26 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
||||
function($scope, $rootScope, $location, User, $http, $state, $stateParams, Notification, Groups, Shared, Content, $modal, $timeout, ApiUrl, Payments, $sce, $window, Analytics, TAVERN_ID) {
|
||||
var user = User.user;
|
||||
|
||||
var initSticky = _.once(function(){
|
||||
$timeout(function () {
|
||||
if (window.env.IS_MOBILE || User.user.preferences.stickyHeader === false) return;
|
||||
$('.header-wrap').sticky({topSpacing:0});
|
||||
});
|
||||
});
|
||||
// Setup page once user is synced
|
||||
var clearAppLoadedListener = $rootScope.$watch('appLoaded', function (after) {
|
||||
if (after === true) {
|
||||
// Initialize sticky header
|
||||
$timeout(function () {
|
||||
if (window.env.IS_MOBILE || User.user.preferences.stickyHeader === false) return;
|
||||
$('.header-wrap').sticky({topSpacing:0});
|
||||
});
|
||||
|
||||
$rootScope.$on('userUpdated',initSticky);
|
||||
// Remove listener
|
||||
clearAppLoadedListener();
|
||||
}
|
||||
});
|
||||
|
||||
$rootScope.$on('$stateChangeSuccess',
|
||||
function(event, toState, toParams, fromState, fromParams){
|
||||
|
||||
$rootScope.pageTitle = $state.current.title;
|
||||
|
||||
$window.scrollTo(0, 0);
|
||||
|
||||
if (!!fromState.name) Analytics.track({'hitType':'pageview','eventCategory':'navigation','eventAction':'navigate','page':'/#/'+toState.name});
|
||||
if (toState.name=='options.social.inbox' && User.user.inbox && User.user.inbox.newMessages > 0) {
|
||||
User.clearNewMessages();
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
habitrpg.controller('SortableInventoryController', ['$scope',
|
||||
function ($scope) {
|
||||
var attributeSort = {
|
||||
constitution: ['-con', '-(con+int+per+str)'],
|
||||
intelligence: ['-int', '-(con+int+per+str)'],
|
||||
perception: ['-per', '-(con+int+per+str)'],
|
||||
strength: ['-str', '-(con+int+per+str)'],
|
||||
constitution: ['-(_effectiveCon)', '-(_effectiveCon+_effectiveInt+_effectivePer+_effectiveStr)'],
|
||||
intelligence: ['-(_effectiveInt)', '-(_effectiveCon+_effectiveInt+_effectivePer+_effectiveStr)'],
|
||||
perception: ['-(_effectivePer)', '-(_effectiveCon+_effectiveInt+_effectivePer+_effectiveStr)'],
|
||||
strength: ['-(_effectiveStr)', '-(_effectiveCon+_effectiveInt+_effectivePer+_effectiveStr)'],
|
||||
set: 'set'
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
||||
}
|
||||
User.score({params:{task: task, direction:direction}});
|
||||
Analytics.updateUser();
|
||||
Analytics.track({'hitType':'event','eventCategory':'behavior','eventAction':'score task','taskType':task.type,'direction':direction});
|
||||
};
|
||||
|
||||
function addTask(addTo, listDef, tasks) {
|
||||
@@ -68,6 +67,25 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
||||
list.focus = true;
|
||||
};
|
||||
|
||||
$scope.editTask = Tasks.editTask;
|
||||
|
||||
$scope.canEdit = function(task) {
|
||||
// can't edit challenge tasks
|
||||
return !task.challenge.id;
|
||||
}
|
||||
|
||||
$scope.doubleClickTask = function (obj, task) {
|
||||
if (obj._locked) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (task._editing) {
|
||||
$scope.saveTask(task);
|
||||
} else {
|
||||
$scope.editTask(task);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the new task to the actions log
|
||||
*/
|
||||
@@ -98,8 +116,6 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
||||
}
|
||||
};
|
||||
|
||||
$scope.editTask = Tasks.editTask;
|
||||
|
||||
$scope.saveTask = function(task, stayOpen, isSaveAndClose) {
|
||||
angular.copy(task._edit, task);
|
||||
task._edit = undefined;
|
||||
@@ -157,7 +173,11 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
||||
$scope._today = moment().add({days: 1});
|
||||
|
||||
$scope.loadedCompletedTodos = function () {
|
||||
if (Tasks.loadedCompletedTodos === true) return;
|
||||
if (Tasks.loadedCompletedTodos === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
User.user.todos = _.reject(User.user.todos, 'completed')
|
||||
|
||||
Tasks.getUserTasks(true)
|
||||
.then(function (response) {
|
||||
|
||||
Reference in New Issue
Block a user