mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
@@ -12,14 +12,12 @@ habitrpg.controller("InventoryCtrl", ['$rootScope', '$scope', 'User', 'API_URL',
|
|||||||
|
|
||||||
// count egg, food, hatchingPotion stack totals
|
// count egg, food, hatchingPotion stack totals
|
||||||
var countStacks = function(items) { return _.reduce(items,function(m,v){return m+v;},0);}
|
var countStacks = function(items) { return _.reduce(items,function(m,v){return m+v;},0);}
|
||||||
// count pets, mounts collected totals
|
|
||||||
var countExists = function(items) { return _.reduce(items,function(m,v){return m+(v ? 1 : 0);},0);}
|
|
||||||
|
|
||||||
$scope.$watch('user.items.pets', function(pets){ $scope.petCount = countExists(pets); });
|
$scope.$watch('user.items.pets', function(pets){ $scope.petCount = $rootScope.countExists(pets); }, true);
|
||||||
$scope.$watch('user.items.mounts', function(mounts){ $scope.mountCount = countExists(mounts); });
|
$scope.$watch('user.items.mounts', function(mounts){ $scope.mountCount = $rootScope.countExists(mounts); }, true);
|
||||||
$scope.$watch('user.items.eggs', function(eggs){ $scope.eggCount = countStacks(eggs); });
|
$scope.$watch('user.items.eggs', function(eggs){ $scope.eggCount = countStacks(eggs); }, true);
|
||||||
$scope.$watch('user.items.hatchingPotions', function(pots){ $scope.potCount = countStacks(pots); });
|
$scope.$watch('user.items.hatchingPotions', function(pots){ $scope.potCount = countStacks(pots); }, true);
|
||||||
$scope.$watch('user.items.food', function(food){ $scope.foodCount = countStacks(food); });
|
$scope.$watch('user.items.food', function(food){ $scope.foodCount = countStacks(food); }, true);
|
||||||
|
|
||||||
$scope.chooseEgg = function(egg){
|
$scope.chooseEgg = function(egg){
|
||||||
if ($scope.selectedEgg && $scope.selectedEgg.name == egg) {
|
if ($scope.selectedEgg && $scope.selectedEgg.name == egg) {
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
|||||||
return haystack && ~haystack.indexOf(needle);
|
return haystack && ~haystack.indexOf(needle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// count pets, mounts collected totals, etc
|
||||||
|
$rootScope.countExists = function(items) {return _.reduce(items,function(m,v){return m+(v?1:0)},0)}
|
||||||
|
|
||||||
$scope.safeApply = function(fn) {
|
$scope.safeApply = function(fn) {
|
||||||
var phase = this.$root.$$phase;
|
var phase = this.$root.$$phase;
|
||||||
if(phase == '$apply' || phase == '$digest') {
|
if(phase == '$apply' || phase == '$digest') {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ script(type='text/ng-template', id='partials/options.inventory.inventory.html')
|
|||||||
|
|
||||||
li.customize-menu
|
li.customize-menu
|
||||||
menu.pets-menu(label='Eggs ({{eggCount}})')
|
menu.pets-menu(label='Eggs ({{eggCount}})')
|
||||||
p(ng-show='user.items.eggs.length < 1') You don't have any eggs yet.
|
p(ng-show='eggCount < 1') You don't have any eggs yet.
|
||||||
div(ng-repeat='(egg,points) in ownedItems(user.items.eggs)')
|
div(ng-repeat='(egg,points) in ownedItems(user.items.eggs)')
|
||||||
//TODO move positioning this styling to css
|
//TODO move positioning this styling to css
|
||||||
button.customize-option(popover='{{Items.eggs[egg].notes}}', popover-title='{{Items.eggs[egg].text}} Egg', popover-trigger='mouseenter', popover-placement='right', ng-click='chooseEgg(egg)', class='Pet_Egg_{{egg}}', ng-class='{selectableInventory: selectedPotion && !user.items.pets[egg+"-"+selectedPotion.name]}')
|
button.customize-option(popover='{{Items.eggs[egg].notes}}', popover-title='{{Items.eggs[egg].text}} Egg', popover-trigger='mouseenter', popover-placement='right', ng-click='chooseEgg(egg)', class='Pet_Egg_{{egg}}', ng-class='{selectableInventory: selectedPotion && !user.items.pets[egg+"-"+selectedPotion.name]}')
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ p
|
|||||||
| : {{userDef(profile.stats.lvl)}}
|
| : {{userDef(profile.stats.lvl)}}
|
||||||
p
|
p
|
||||||
strong Pets Found
|
strong Pets Found
|
||||||
| : {{profile.items.pets.length || 0}}
|
| : {{countExists(profile.items.pets)}}
|
||||||
hr
|
hr
|
||||||
p
|
p
|
||||||
strong Total Strength
|
strong Total Strength
|
||||||
|
|||||||
Reference in New Issue
Block a user