mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-18 17:54:10 +00:00
use ApiUrlService instead of API_URL; fixed spacing in groupsCtrl.js
This commit is contained in:
parent
7a0883746c
commit
8f468c27ff
7 changed files with 46 additions and 47 deletions
|
|
@ -5,8 +5,8 @@
|
|||
*/
|
||||
|
||||
angular.module('authCtrl', [])
|
||||
.controller("AuthCtrl", ['$scope', '$rootScope', 'User', '$http', '$location', '$window','API_URL', '$modal',
|
||||
function($scope, $rootScope, User, $http, $location, $window, API_URL, $modal) {
|
||||
.controller("AuthCtrl", ['$scope', '$rootScope', 'User', '$http', '$location', '$window','ApiUrlService', '$modal',
|
||||
function($scope, $rootScope, User, $http, $location, $window, ApiUrlService, $modal) {
|
||||
var runAuth;
|
||||
var showedFacebookMessage;
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ angular.module('authCtrl', [])
|
|||
if ($scope.registrationForm.$invalid) {
|
||||
return;
|
||||
}
|
||||
var url = API_URL + "/api/v2/register";
|
||||
var url = ApiUrlService.get() + "/api/v2/register";
|
||||
if($rootScope.selectedLanguage) url = url + '?lang=' + $rootScope.selectedLanguage.code;
|
||||
$http.post(url, $scope.registerVals).success(function(data, status, headers, config) {
|
||||
runAuth(data.id, data.apiToken);
|
||||
|
|
@ -62,7 +62,7 @@ angular.module('authCtrl', [])
|
|||
if ($scope.useUUID) {
|
||||
runAuth($scope.loginUsername, $scope.loginPassword);
|
||||
} else {
|
||||
$http.post(API_URL + "/api/v2/user/auth/local", data)
|
||||
$http.post(ApiUrlService.get() + "/api/v2/user/auth/local", data)
|
||||
.success(function(data, status, headers, config) {
|
||||
runAuth(data.id, data.token);
|
||||
}).error(errorAlert);
|
||||
|
|
@ -82,7 +82,7 @@ angular.module('authCtrl', [])
|
|||
};
|
||||
|
||||
$scope.passwordReset = function(email){
|
||||
$http.post(API_URL + '/api/v2/user/reset-password', {email:email})
|
||||
$http.post(ApiUrlService.get() + '/api/v2/user/reset-password', {email:email})
|
||||
.success(function(){
|
||||
alert(window.env.t('newPassSent'));
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
"use strict";
|
||||
|
||||
(typeof habitrpg !== 'undefined' ? habitrpg : habitrpgStatic)
|
||||
.controller("FooterCtrl", ['$scope', '$rootScope', 'User', '$http', 'Notification', 'API_URL',
|
||||
function($scope, $rootScope, User, $http, Notification, API_URL) {
|
||||
.controller("FooterCtrl", ['$scope', '$rootScope', 'User', '$http', 'Notification', 'ApiUrlService',
|
||||
function($scope, $rootScope, User, $http, Notification, ApiUrlService) {
|
||||
|
||||
if(typeof habitrpg === "undefined"){
|
||||
$scope.languages = env.avalaibleLanguages;
|
||||
|
|
@ -66,7 +66,7 @@
|
|||
Notification.text('-1 day, remember to refresh');
|
||||
}
|
||||
$scope.addTenGems = function(){
|
||||
$http.post(API_URL + '/api/v2/user/addTenGems').success(function(){
|
||||
$http.post(ApiUrlService.get() + '/api/v2/user/addTenGems').success(function(){
|
||||
User.log({});
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,24 @@
|
|||
"use strict";
|
||||
|
||||
habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '$http', 'API_URL', '$q', 'User', 'Members', '$state',
|
||||
function($scope, $rootScope, Shared, Groups, $http, API_URL, $q, User, Members, $state) {
|
||||
habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '$http', '$q', 'User', 'Members', '$state',
|
||||
function($scope, $rootScope, Shared, Groups, $http, $q, User, Members, $state) {
|
||||
$scope.isMemberOfPendingQuest = function(userid, group) {
|
||||
if (!group.quest || !group.quest.members) return false;
|
||||
if (group.quest.active) return false; // quest is started, not pending
|
||||
return userid in group.quest.members && group.quest.members[userid] != false;
|
||||
}
|
||||
|
||||
$scope.isMemberOfPendingQuest = function(userid, group){
|
||||
if (!group.quest || !group.quest.members) return false;
|
||||
if (group.quest.active) return false; // quest is started, not pending
|
||||
return userid in group.quest.members && group.quest.members[userid] != false;
|
||||
}
|
||||
$scope.isMemberOfRunningQuest = function(userid, group) {
|
||||
if (!group.quest || !group.quest.members) return false;
|
||||
if (!group.quest.active) return false; // quest is pending, not started
|
||||
return group.quest.members[userid];
|
||||
}
|
||||
|
||||
$scope.isMemberOfRunningQuest = function(userid, group){
|
||||
if (!group.quest || !group.quest.members) return false;
|
||||
if (!group.quest.active) return false; // quest is pending, not started
|
||||
return group.quest.members[userid];
|
||||
}
|
||||
|
||||
$scope.isMemberOfGroup = function(userid, group){
|
||||
if (!group.members) return false;
|
||||
var memberIds = _.map(group.members, function(x){return x._id});
|
||||
return ~(memberIds.indexOf(userid));
|
||||
}
|
||||
$scope.isMemberOfGroup = function(userid, group){
|
||||
if (!group.members) return false;
|
||||
var memberIds = _.map(group.members, function(x){return x._id});
|
||||
return ~(memberIds.indexOf(userid));
|
||||
}
|
||||
|
||||
$scope.isMember = function(user, group){
|
||||
return ~(group.members.indexOf(user._id));
|
||||
|
|
@ -145,7 +144,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
|
|||
});
|
||||
}])
|
||||
|
||||
.controller('ChatCtrl', ['$scope', 'Groups', 'User', '$http', 'API_URL', 'Notification', function($scope, Groups, User, $http, API_URL, Notification){
|
||||
.controller('ChatCtrl', ['$scope', 'Groups', 'User', '$http', 'ApiUrlService', 'Notification', function($scope, Groups, User, $http, ApiUrlService, Notification){
|
||||
$scope.message = {content:''};
|
||||
$scope._sending = false;
|
||||
|
||||
|
|
@ -207,7 +206,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
|
|||
}
|
||||
//Chat.Chat.like({gid:group._id,mid:message.id});
|
||||
|
||||
$http.post(API_URL + '/api/v2/groups/' + group._id + '/chat/' + message.id + '/like');
|
||||
$http.post(ApiUrlService.get() + '/api/v2/groups/' + group._id + '/chat/' + message.id + '/like');
|
||||
}
|
||||
|
||||
$scope.sync = function(group){
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
"use strict";
|
||||
|
||||
habitrpg.controller("HallHeroesCtrl", ['$scope', '$rootScope', 'User', 'Notification', 'API_URL', '$resource',
|
||||
function($scope, $rootScope, User, Notification, API_URL, $resource) {
|
||||
var Hero = $resource(API_URL + '/api/v2/hall/heroes/:uid', {uid:'@_id'});
|
||||
habitrpg.controller("HallHeroesCtrl", ['$scope', '$rootScope', 'User', 'Notification', 'ApiUrlService', '$resource',
|
||||
function($scope, $rootScope, User, Notification, ApiUrlService, $resource) {
|
||||
var Hero = $resource(ApiUrlService.get() + '/api/v2/hall/heroes/:uid', {uid:'@_id'});
|
||||
$scope.hero = undefined;
|
||||
$scope.loadHero = function(uuid){
|
||||
$scope.hero = Hero.get({uid:uuid});
|
||||
|
|
@ -18,9 +18,9 @@ habitrpg.controller("HallHeroesCtrl", ['$scope', '$rootScope', 'User', 'Notifica
|
|||
$scope.heroes = Hero.query();
|
||||
}]);
|
||||
|
||||
habitrpg.controller("HallPatronsCtrl", ['$scope', '$rootScope', 'User', 'Notification', 'API_URL', '$resource',
|
||||
function($scope, $rootScope, User, Notification, API_URL, $resource) {
|
||||
var Patron = $resource(API_URL + '/api/v2/hall/patrons/:uid', {uid:'@_id'});
|
||||
habitrpg.controller("HallPatronsCtrl", ['$scope', '$rootScope', 'User', 'Notification', 'ApiUrlService', '$resource',
|
||||
function($scope, $rootScope, User, Notification, ApiUrlService, $resource) {
|
||||
var Patron = $resource(ApiUrlService.get() + '/api/v2/hall/patrons/:uid', {uid:'@_id'});
|
||||
|
||||
var page = 0;
|
||||
$scope.patrons = [];
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
/* Make user and settings available for everyone through root scope.
|
||||
*/
|
||||
|
||||
habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$http', '$state', '$stateParams', 'Notification', 'Groups', 'Shared', 'Content', '$modal', '$timeout',
|
||||
function($scope, $rootScope, $location, User, $http, $state, $stateParams, Notification, Groups, Shared, Content, $modal, $timeout) {
|
||||
habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$http', '$state', '$stateParams', 'Notification', 'Groups', 'Shared', 'Content', '$modal', '$timeout', 'ApiUrlService'
|
||||
function($scope, $rootScope, $location, User, $http, $state, $stateParams, Notification, Groups, Shared, Content, $modal, $timeout, ApiUrlService) {
|
||||
var user = User.user;
|
||||
|
||||
var initSticky = _.once(function(){
|
||||
|
|
@ -235,7 +235,7 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
|||
$scope.spell = null;
|
||||
$rootScope.applyingAction = false;
|
||||
|
||||
$http.post('/api/v2/user/class/cast/'+spell.key+'?targetType='+type+'&targetId='+targetId)
|
||||
$http.post(ApiUrlService.get() + '/api/v2/user/class/cast/'+spell.key+'?targetType='+type+'&targetId='+targetId)
|
||||
.success(function(){
|
||||
var msg = window.env.t('youCast', {spell: spell.text()});
|
||||
switch (type) {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
// Make user and settings available for everyone through root scope.
|
||||
habitrpg.controller('SettingsCtrl',
|
||||
['$scope', 'User', '$rootScope', '$http', 'API_URL', 'Guide', '$location', '$timeout', 'Notification',
|
||||
function($scope, User, $rootScope, $http, API_URL, Guide, $location, $timeout, Notification) {
|
||||
['$scope', 'User', '$rootScope', '$http', 'ApiUrlService', 'Guide', '$location', '$timeout', 'Notification',
|
||||
function($scope, User, $rootScope, $http, ApiUrlService, Guide, $location, $timeout, Notification) {
|
||||
|
||||
// FIXME we have this re-declared everywhere, figure which is the canonical version and delete the rest
|
||||
// $scope.auth = function (id, token) {
|
||||
|
|
@ -79,7 +79,7 @@ habitrpg.controller('SettingsCtrl',
|
|||
if (!changeUser.newUsername || !changeUser.password) {
|
||||
return alert(window.env.t('fillAll'));
|
||||
}
|
||||
$http.post(API_URL + '/api/v2/user/change-username', changeUser)
|
||||
$http.post(ApiUrlService.get() + '/api/v2/user/change-username', changeUser)
|
||||
.success(function(){
|
||||
alert(window.env.t('usernameSuccess'));
|
||||
$scope.changeUser = {};
|
||||
|
|
@ -93,7 +93,7 @@ habitrpg.controller('SettingsCtrl',
|
|||
if (!changePass.oldPassword || !changePass.newPassword || !changePass.confirmNewPassword) {
|
||||
return alert(window.env.t('fillAll'));
|
||||
}
|
||||
$http.post(API_URL + '/api/v2/user/change-password', changePass)
|
||||
$http.post(ApiUrlService.get() + '/api/v2/user/change-password', changePass)
|
||||
.success(function(data, status, headers, config){
|
||||
if (data.err) return alert(data.err);
|
||||
alert(window.env.t('passSuccess'));
|
||||
|
|
@ -130,7 +130,7 @@ habitrpg.controller('SettingsCtrl',
|
|||
}
|
||||
|
||||
$scope['delete'] = function(){
|
||||
$http['delete'](API_URL + '/api/v2/user')
|
||||
$http['delete'](ApiUrlService.get() + '/api/v2/user')
|
||||
.success(function(res, code){
|
||||
if (res.err) return alert(res.err);
|
||||
localStorage.clear();
|
||||
|
|
@ -139,14 +139,14 @@ habitrpg.controller('SettingsCtrl',
|
|||
}
|
||||
|
||||
$scope.enterCoupon = function(code) {
|
||||
$http.post(API_URL + '/api/v2/user/coupon/' + code).success(function(res,code){
|
||||
$http.post(ApiUrlService.get() + '/api/v2/user/coupon/' + code).success(function(res,code){
|
||||
if (code!==200) return;
|
||||
User.sync();
|
||||
Notification.text('Coupon applied! Check your inventory');
|
||||
});
|
||||
}
|
||||
$scope.generateCodes = function(codes){
|
||||
$http.post(API_URL + '/api/v2/coupons/generate/'+codes.event+'?count='+(codes.count || 1))
|
||||
$http.post(ApiUrlService.get() + '/api/v2/coupons/generate/'+codes.event+'?count='+(codes.count || 1))
|
||||
.success(function(res,code){
|
||||
$scope._codes = {};
|
||||
if (code!==200) return;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','Notification', '$http', 'API_URL', '$timeout', 'Shared',
|
||||
function($scope, $rootScope, $location, User, Notification, $http, API_URL, $timeout, Shared) {
|
||||
habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','Notification', '$http', 'ApiUrlService', '$timeout', 'Shared',
|
||||
function($scope, $rootScope, $location, User, Notification, $http, ApiUrlService, $timeout, Shared) {
|
||||
$scope.obj = User.user; // used for task-lists
|
||||
$scope.user = User.user;
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
|||
|
||||
$scope.unlink = function(task, keep) {
|
||||
// TODO move this to userServices, turn userSerivces.user into ng-resource
|
||||
$http.post(API_URL + '/api/v2/user/tasks/' + task.id + '/unlink?keep=' + keep)
|
||||
$http.post(ApiUrlService.get() + '/api/v2/user/tasks/' + task.id + '/unlink?keep=' + keep)
|
||||
.success(function(){
|
||||
User.log({});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue