[#1397 #1543 #1540] misc bug fixes

This commit is contained in:
Tyler Renelle
2013-09-17 14:44:02 -04:00
parent 082bfd46da
commit 402e2aedb0
2 changed files with 15 additions and 12 deletions

View File

@@ -5,14 +5,15 @@
*/ */
angular.module('guideServices', []). angular.module('guideServices', []).
factory('Guide', ['$rootScope', 'User', function($rootScope, User) { factory('Guide', ['$rootScope', 'User', 'Items', 'Helpers', function($rootScope, User, Items, Helpers) {
/** /**
* Init and show the welcome tour. Note we do it listening to a $rootScope broadcasted 'userLoaded' message, * Init and show the welcome tour. Note we do it listening to a $rootScope broadcasted 'userLoaded' message,
* this because we need to determine whether to show the tour *after* the user has been pulled from the server, * this because we need to determine whether to show the tour *after* the user has been pulled from the server,
* otherwise it's always start off as true, and then get set to false later * otherwise it's always start off as true, and then get set to false later
*/ */
$rootScope.$on('userUpdated', function(){ $rootScope.$on('userUpdated', initTour);
function initTour(){
if (User.user.flags.showTour === false) return; if (User.user.flags.showTour === false) return;
var tourSteps = [ var tourSteps = [
{ {
@@ -64,7 +65,7 @@ angular.module('guideServices', []).
}); });
tour.restart(); // Tour doesn't quite mesh with our handling of flags.showTour, just restart it on page load tour.restart(); // Tour doesn't quite mesh with our handling of flags.showTour, just restart it on page load
//tour.start(true); //tour.start(true);
}) };
var alreadyShown = function(before, after) { var alreadyShown = function(before, after) {
return !(!before && after === true); return !(!before && after === true);
@@ -73,7 +74,8 @@ angular.module('guideServices', []).
var showPopover = function(selector, title, html, placement) { var showPopover = function(selector, title, html, placement) {
if (!placement) placement = 'bottom'; if (!placement) placement = 'bottom';
$(selector).popover('destroy'); $(selector).popover('destroy');
html = "<div><div class='NPC-Justin float-left'></div>" + html + "<br/><a class='btn btn-sm btn-default' href='#' onClick=\"$('" + selector + "').popover('hide');return false;\">Close</a></div>"; var button = "<button class='btn btn-sm btn-default' onClick=\"$('" + selector + "').popover('hide');return false;\">Close</button>";
html = "<div><div class='NPC-Justin float-left'></div>" + html + '<br/>' + button + '</div>';
$(selector).popover({ $(selector).popover({
title: title, title: title,
placement: placement, placement: placement,
@@ -109,7 +111,7 @@ angular.module('guideServices', []).
$rootScope.$watch('user.flags.dropsEnabled', function(after, before) { $rootScope.$watch('user.flags.dropsEnabled', function(after, before) {
if (alreadyShown(before, after)) return; if (alreadyShown(before, after)) return;
var drop = window.helpers.randomVal(window.items.items.pets); var drop = Helpers.randomVal(Items.items.pets);
var eggs = User.user.items.eggs = []; var eggs = User.user.items.eggs = [];
eggs.push(drop); // FIXME put this on server instead eggs.push(drop); // FIXME put this on server instead
User.set('items.eggs', eggs); User.set('items.eggs', eggs);
@@ -146,5 +148,9 @@ angular.module('guideServices', []).
} }
});*/ });*/
return {
initTour:initTour
};
} }
]); ]);

View File

@@ -202,13 +202,10 @@ api.scoreTask = function(req, res, next) {
} }
task = user.tasks[id]; task = user.tasks[id];
delta = algos.score(user, task, direction); delta = algos.score(user, task, direction);
return user.save(function(err, saved) { //user.markModified('flags');
if (err) { user.save(function(err, saved) {
return res.json(500, { if (err) return res.json(500, {err: err});
err: err res.json(200, _.extend({
});
}
return res.json(200, _.extend({
delta: delta delta: delta
}, saved.toJSON().stats)); }, saved.toJSON().stats));
}); });