Merge remote-tracking branch 'upstream/develop' into todos-dated-tab-2014-11-01

This commit is contained in:
Alice Harris
2015-01-19 17:53:48 +10:00
278 changed files with 13878 additions and 12693 deletions
+50
View File
@@ -0,0 +1,50 @@
'use strict';
angular.module('habitrpg').config(['$httpProvider', function($httpProvider){
$httpProvider.interceptors.push(['$q', '$rootScope', function($q, $rootScope){
return {
response: function(response) {
return response;
},
responseError: function(response) {
var mobileApp = !!window.env.appVersion;
// Offline
if (response.status == 0 ||
// don't know why we're getting 404 here, should be 0
(response.status == 404 && _.isEmpty(response.data))) {
if (!mobileApp) // skip mobile, queue actions
$rootScope.$broadcast('responseText', window.env.t('serverUnreach'));
// Needs refresh
} else if (response.needRefresh) {
if (!mobileApp) // skip mobile for now
$rootScope.$broadcast('responseError', "The site has been updated and the page needs to refresh. The last action has not been recorded, please refresh and try again.");
} else if (response.data.code && response.data.code === 'ACCOUNT_SUSPENDED') {
confirm(response.data.err);
localStorage.clear();
window.location.href = mobileApp ? '/app/login' : '/logout'; //location.reload()
// 400 range?
} else if (response.status < 500) {
$rootScope.$broadcast('responseText', response.data.err || response.data);
// Need to reject the prompse so the error is handled correctly
if (response.status === 401)
return $q.reject(response);
// Error
} else {
var error = '<strong>Please reload</strong>, ' +
'"'+window.env.t('error')+' '+(response.data.err || response.data || 'something went wrong')+'" ' +
window.env.t('seeConsole');
if (mobileApp) error = 'Error contacting the server. Please try again in a few minutes.';
$rootScope.$broadcast('responseError', error);
console.error(response);
}
return $q.reject(response);
}
};
}]);
}]);
+44 -1
View File
@@ -766,6 +766,7 @@ api.questEggs =
Spider: text: t('questEggSpiderText'), adjective: t('questEggSpiderAdjective'), canBuy: false
Owl: text: t('questEggOwlText'), adjective: t('questEggOwlAdjective'), canBuy: false
Penguin: text: t('questEggPenguinText'), adjective: t('questEggPenguinAdjective'), canBuy: false
TRex: text: t('questEggTRexText'), adjective: t('questEggTRexAdjective'), canBuy: false
_.each api.questEggs, (egg,key) ->
_.defaults egg,
@@ -918,7 +919,7 @@ api.quests =
title: t("questStressbeastBossRageTitle")
description: t("questStressbeastBossRageDescription")
value: 1450000
healing: .3
stables:t('questStressbeastBossRageStables')
bailey:t('questStressbeastBossRageBailey')
guide:t('questStressbeastBossRageGuide')
@@ -1423,6 +1424,48 @@ api.quests =
gp: 31
exp: 200
trex:
text: t('questTRexText')
notes: t('questTRexNotes')
completion: t('questTRexCompletion')
value: 4
boss:
name: t('questTRexBoss')
hp: 800
str: 2
drop:
items: [
{type: 'eggs', key: 'TRex', text: t('questTRexDropTRexEgg')}
{type: 'eggs', key: 'TRex', text: t('questTRexDropTRexEgg')}
{type: 'eggs', key: 'TRex', text: t('questTRexDropTRexEgg')}
]
gp: 55
exp: 500
trex_undead:
text: t('questTRexUndeadText')
notes: t('questTRexUndeadNotes')
completion: t('questTRexUndeadCompletion')
value: 4
boss:
name: t('questTRexUndeadBoss')
hp: 500
str: 2
rage:
title: t("questTRexUndeadRageTitle")
description: t("questTRexUndeadRageDescription")
value: 50
healing: .3
effect:t('questTRexUndeadRageEffect')
drop:
items: [
{type: 'eggs', key: 'TRex', text: t('questTRexDropTRexEgg')}
{type: 'eggs', key: 'TRex', text: t('questTRexDropTRexEgg')}
{type: 'eggs', key: 'TRex', text: t('questTRexDropTRexEgg')}
]
gp: 55
exp: 500
_.each api.quests, (v,key) ->
_.defaults v, {key,canBuy:true}
b = v.boss
+1 -1
View File
@@ -550,7 +550,7 @@ api.wrap = (user, main=true) ->
updateTask: (req, cb) ->
return cb?({code:404,message:i18n.t('messageTaskNotFound', req.language)}) unless task = user.tasks[req.params?.id]
_.merge task, _.omit(req.body,['checklist','id'])
_.merge task, _.omit(req.body,['checklist','id', 'type'])
task.checklist = req.body.checklist if req.body.checklist
task.markModified? 'tags'
cb? null, task
+6 -6
View File
@@ -1,7 +1,7 @@
'use strict';
angular.module('userServices', [])
.service('ApiUrlService', ['API_URL', function(currentApiUrl){
angular.module('habitrpg')
.service('ApiUrl', ['API_URL', function(currentApiUrl){
this.setApiUrl = function(newUrl){
currentApiUrl = newUrl;
};
@@ -14,8 +14,8 @@ angular.module('userServices', [])
/**
* Services that persists and retrieves user from localStorage.
*/
.factory('User', ['$rootScope', '$http', '$location', '$window', 'STORAGE_USER_ID', 'STORAGE_SETTINGS_ID', 'MOBILE_APP', 'Notification', 'ApiUrlService',
function($rootScope, $http, $location, $window, STORAGE_USER_ID, STORAGE_SETTINGS_ID, MOBILE_APP, Notification, ApiUrlService) {
.factory('User', ['$rootScope', '$http', '$location', '$window', 'STORAGE_USER_ID', 'STORAGE_SETTINGS_ID', 'MOBILE_APP', 'Notification', 'ApiUrl',
function($rootScope, $http, $location, $window, STORAGE_USER_ID, STORAGE_SETTINGS_ID, MOBILE_APP, Notification, ApiUrl) {
var authenticated = false;
var defaultSettings = {
auth: { apiId: '', apiToken: ''},
@@ -68,14 +68,14 @@ angular.module('userServices', [])
// Save the current filters
var current_filters = user.filters;
$http.post(ApiUrlService.get() + '/api/v2/user/batch-update', sent, {params: {data:+new Date, _v:user._v, siteVersion: $window.env && $window.env.siteVersion}})
$http.post(ApiUrl.get() + '/api/v2/user/batch-update', sent, {params: {data:+new Date, _v:user._v, siteVersion: $window.env && $window.env.siteVersion}})
.success(function (data, status, heacreatingders, config) {
//make sure there are no pending actions to sync. If there are any it is not safe to apply model from server as we may overwrite user data.
if (!queue.length) {
//we can't do user=data as it will not update user references in all other angular controllers.
// the user has been modified from another application, sync up
if(data.wasModified) {
if(data && data.wasModified) {
delete data.wasModified;
$rootScope.$emit('userUpdated', user);
}