2013-08-28 00:07:28 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
2013-08-29 02:08:59 +00:00
|
|
|
window.habitrpg = angular.module('habitrpg',
|
2015-01-19 20:17:43 +00:00
|
|
|
['ui.bootstrap', 'ui.keypress', 'ui.router', 'chieffancypants.loadingBar', 'At', 'infinite-scroll', 'ui.select2', 'angular.filter', 'ngResource', 'ngSanitize'])
|
2013-08-29 02:08:59 +00:00
|
|
|
|
2014-03-01 06:48:20 +00:00
|
|
|
// @see https://github.com/angular-ui/ui-router/issues/110 and https://github.com/HabitRPG/habitrpg/issues/1705
|
|
|
|
|
// temporary hack until they have a better solution
|
|
|
|
|
|
2013-08-28 01:13:05 +00:00
|
|
|
.constant("API_URL", "")
|
2013-08-29 02:08:59 +00:00
|
|
|
.constant("STORAGE_USER_ID", 'habitrpg-user')
|
|
|
|
|
.constant("STORAGE_SETTINGS_ID", 'habit-mobile-settings')
|
2013-12-16 04:28:59 +00:00
|
|
|
.constant("MOBILE_APP", false)
|
2013-08-29 02:08:59 +00:00
|
|
|
//.constant("STORAGE_GROUPS_ID", "") // if we decide to take groups offline
|
|
|
|
|
|
2015-01-16 23:48:53 +00:00
|
|
|
.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', 'STORAGE_SETTINGS_ID',
|
|
|
|
|
function($stateProvider, $urlRouterProvider, $httpProvider, STORAGE_SETTINGS_ID) {
|
2013-08-29 02:08:59 +00:00
|
|
|
|
2013-10-28 05:27:07 +00:00
|
|
|
$urlRouterProvider
|
|
|
|
|
// Setup default selected tabs
|
|
|
|
|
.when('/options', '/options/profile/avatar')
|
|
|
|
|
.when('/options/profile', '/options/profile/avatar')
|
2014-12-15 02:05:01 +00:00
|
|
|
.when('/options/groups', '/options/groups/tavern')
|
2013-10-29 22:25:50 +00:00
|
|
|
.when('/options/groups/guilds', '/options/groups/guilds/public')
|
2014-01-06 01:03:47 +00:00
|
|
|
.when('/options/groups/hall', '/options/groups/hall/heroes')
|
2013-12-17 23:51:27 +00:00
|
|
|
.when('/options/inventory', '/options/inventory/drops')
|
2013-11-16 00:25:09 +00:00
|
|
|
.when('/options/settings', '/options/settings/settings')
|
2013-10-28 05:27:07 +00:00
|
|
|
|
|
|
|
|
// redirect states that don't match
|
|
|
|
|
.otherwise("/tasks");
|
|
|
|
|
|
|
|
|
|
$stateProvider
|
|
|
|
|
|
|
|
|
|
// Tasks
|
|
|
|
|
.state('tasks', {
|
|
|
|
|
url: "/tasks",
|
|
|
|
|
templateUrl: "partials/main.html"
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// Options
|
|
|
|
|
.state('options', {
|
|
|
|
|
url: "/options",
|
|
|
|
|
templateUrl: "partials/options.html",
|
|
|
|
|
controller: function(){}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// Options > Profile
|
|
|
|
|
.state('options.profile', {
|
|
|
|
|
url: "/profile",
|
|
|
|
|
templateUrl: "partials/options.profile.html",
|
|
|
|
|
controller: 'UserCtrl'
|
|
|
|
|
})
|
|
|
|
|
.state('options.profile.avatar', {
|
|
|
|
|
url: "/avatar",
|
|
|
|
|
templateUrl: "partials/options.profile.avatar.html"
|
|
|
|
|
})
|
2014-06-09 18:59:20 +00:00
|
|
|
.state('options.profile.backgrounds', {
|
|
|
|
|
url: '/backgrounds',
|
|
|
|
|
templateUrl: "partials/options.profile.backgrounds.html"
|
|
|
|
|
})
|
2013-10-28 05:27:07 +00:00
|
|
|
.state('options.profile.stats', {
|
|
|
|
|
url: "/stats",
|
|
|
|
|
templateUrl: "partials/options.profile.stats.html"
|
|
|
|
|
})
|
|
|
|
|
.state('options.profile.profile', {
|
2013-11-04 08:41:16 +00:00
|
|
|
url: "/profile",
|
2013-10-28 05:27:07 +00:00
|
|
|
templateUrl: "partials/options.profile.profile.html"
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// Options > Groups
|
2013-10-31 21:37:04 +00:00
|
|
|
.state('options.social', {
|
2013-10-28 05:27:07 +00:00
|
|
|
url: "/groups",
|
2013-10-31 21:37:04 +00:00
|
|
|
templateUrl: "partials/options.social.html"
|
2013-10-28 05:27:07 +00:00
|
|
|
})
|
2014-01-06 01:03:47 +00:00
|
|
|
|
2014-11-27 10:32:57 +00:00
|
|
|
.state('options.social.inbox', {
|
|
|
|
|
url: "/inbox",
|
|
|
|
|
templateUrl: "partials/options.social.inbox.html"
|
|
|
|
|
})
|
|
|
|
|
|
2013-10-31 21:37:04 +00:00
|
|
|
.state('options.social.tavern', {
|
2013-10-28 05:27:07 +00:00
|
|
|
url: "/tavern",
|
2013-10-31 21:37:04 +00:00
|
|
|
templateUrl: "partials/options.social.tavern.html",
|
2013-10-28 05:27:07 +00:00
|
|
|
controller: 'TavernCtrl'
|
|
|
|
|
})
|
2014-01-06 01:03:47 +00:00
|
|
|
|
2013-10-31 21:37:04 +00:00
|
|
|
.state('options.social.party', {
|
2013-10-28 05:27:07 +00:00
|
|
|
url: '/party',
|
2013-10-31 21:37:04 +00:00
|
|
|
templateUrl: "partials/options.social.party.html",
|
2013-10-28 05:27:07 +00:00
|
|
|
controller: 'PartyCtrl'
|
|
|
|
|
})
|
2014-01-06 01:03:47 +00:00
|
|
|
|
|
|
|
|
.state('options.social.hall', {
|
|
|
|
|
url: '/hall',
|
|
|
|
|
templateUrl: "partials/options.social.hall.html"
|
|
|
|
|
})
|
|
|
|
|
.state('options.social.hall.heroes', {
|
|
|
|
|
url: '/heroes',
|
|
|
|
|
templateUrl: "partials/options.social.hall.heroes.html",
|
|
|
|
|
controller: 'HallHeroesCtrl'
|
|
|
|
|
})
|
|
|
|
|
.state('options.social.hall.patrons', {
|
|
|
|
|
url: '/patrons',
|
|
|
|
|
templateUrl: "partials/options.social.hall.patrons.html",
|
|
|
|
|
controller: 'HallPatronsCtrl'
|
|
|
|
|
})
|
|
|
|
|
|
2013-10-31 21:37:04 +00:00
|
|
|
.state('options.social.guilds', {
|
2013-10-29 19:26:13 +00:00
|
|
|
url: '/guilds',
|
2013-10-31 21:37:04 +00:00
|
|
|
templateUrl: "partials/options.social.guilds.html",
|
2013-10-28 05:27:07 +00:00
|
|
|
controller: 'GuildsCtrl'
|
|
|
|
|
})
|
2013-10-31 21:37:04 +00:00
|
|
|
.state('options.social.guilds.public', {
|
2013-10-29 22:25:50 +00:00
|
|
|
url: '/public',
|
2013-10-31 21:37:04 +00:00
|
|
|
templateUrl: "partials/options.social.guilds.public.html"
|
2013-10-29 22:25:50 +00:00
|
|
|
})
|
2013-10-31 21:37:04 +00:00
|
|
|
.state('options.social.guilds.create', {
|
2013-10-29 22:25:50 +00:00
|
|
|
url: '/create',
|
2013-10-31 21:37:04 +00:00
|
|
|
templateUrl: "partials/options.social.guilds.create.html"
|
2013-10-29 22:25:50 +00:00
|
|
|
})
|
2013-10-31 21:37:04 +00:00
|
|
|
.state('options.social.guilds.detail', {
|
2013-10-29 22:25:50 +00:00
|
|
|
url: '/:gid',
|
2013-10-31 21:37:04 +00:00
|
|
|
templateUrl: 'partials/options.social.guilds.detail.html',
|
2014-02-13 04:20:42 +00:00
|
|
|
controller: ['$scope', 'Groups', '$stateParams',
|
|
|
|
|
function($scope, Groups, $stateParams){
|
|
|
|
|
Groups.Group.get({gid:$stateParams.gid}, function(group){
|
|
|
|
|
$scope.group = group;
|
|
|
|
|
Groups.seenMessage(group._id);
|
|
|
|
|
});
|
2013-10-29 22:25:50 +00:00
|
|
|
}]
|
|
|
|
|
})
|
2013-10-28 05:27:07 +00:00
|
|
|
|
2013-11-02 06:11:28 +00:00
|
|
|
// Options > Social > Challenges
|
2013-10-31 21:37:04 +00:00
|
|
|
.state('options.social.challenges', {
|
2013-10-28 05:27:07 +00:00
|
|
|
url: "/challenges",
|
|
|
|
|
controller: 'ChallengesCtrl',
|
2013-10-31 21:37:04 +00:00
|
|
|
templateUrl: "partials/options.social.challenges.html"
|
2013-10-30 00:49:49 +00:00
|
|
|
})
|
2013-10-31 21:37:04 +00:00
|
|
|
.state('options.social.challenges.detail', {
|
2013-10-30 00:49:49 +00:00
|
|
|
url: '/:cid',
|
2013-10-31 21:37:04 +00:00
|
|
|
templateUrl: 'partials/options.social.challenges.detail.html',
|
2015-04-05 14:43:27 +00:00
|
|
|
controller: ['$scope', 'Challenges', '$stateParams',
|
|
|
|
|
function($scope, Challenges, $stateParams){
|
2015-03-15 17:24:48 +00:00
|
|
|
|
2013-10-30 02:07:39 +00:00
|
|
|
$scope.obj = $scope.challenge = Challenges.Challenge.get({cid:$stateParams.cid}, function(){
|
|
|
|
|
$scope.challenge._locked = true;
|
|
|
|
|
});
|
|
|
|
|
}]
|
2013-10-28 05:27:07 +00:00
|
|
|
})
|
2015-03-28 09:01:44 +00:00
|
|
|
.state('options.social.challenges.edit', {
|
|
|
|
|
url: '/:cid/edit',
|
|
|
|
|
templateUrl: 'partials/options.social.challenges.detail.html',
|
|
|
|
|
controller: ['$scope', 'Challenges', '$stateParams',
|
|
|
|
|
function($scope, Challenges, $stateParams){
|
|
|
|
|
$scope.obj = $scope.challenge = Challenges.Challenge.get({cid:$stateParams.cid}, function(){
|
|
|
|
|
$scope.challenge._locked = false;
|
|
|
|
|
});
|
|
|
|
|
}]
|
|
|
|
|
})
|
2013-11-02 06:11:28 +00:00
|
|
|
.state('options.social.challenges.detail.member', {
|
|
|
|
|
url: '/:uid',
|
|
|
|
|
templateUrl: 'partials/options.social.challenges.detail.member.html',
|
|
|
|
|
controller: ['$scope', 'Challenges', '$stateParams',
|
|
|
|
|
function($scope, Challenges, $stateParams){
|
|
|
|
|
$scope.obj = Challenges.Challenge.getMember({cid:$stateParams.cid, uid:$stateParams.uid}, function(){
|
|
|
|
|
$scope.obj._locked = true;
|
|
|
|
|
});
|
|
|
|
|
}]
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// Options > Inventory
|
|
|
|
|
.state('options.inventory', {
|
|
|
|
|
url: '/inventory',
|
2013-11-10 04:15:55 +00:00
|
|
|
templateUrl: "partials/options.inventory.html",
|
|
|
|
|
controller: 'InventoryCtrl'
|
2013-11-02 06:11:28 +00:00
|
|
|
})
|
2013-12-17 23:51:27 +00:00
|
|
|
.state('options.inventory.drops', {
|
|
|
|
|
url: '/drops',
|
|
|
|
|
templateUrl: "partials/options.inventory.drops.html"
|
2013-11-02 06:11:28 +00:00
|
|
|
})
|
2013-12-17 23:51:27 +00:00
|
|
|
.state('options.inventory.pets', {
|
2013-11-10 19:47:33 +00:00
|
|
|
url: '/pets',
|
2013-12-17 23:51:27 +00:00
|
|
|
templateUrl: "partials/options.inventory.pets.html"
|
2013-11-10 19:47:33 +00:00
|
|
|
})
|
2013-12-17 23:51:27 +00:00
|
|
|
.state('options.inventory.mounts', {
|
2013-11-10 19:47:33 +00:00
|
|
|
url: '/mounts',
|
2013-12-17 23:51:27 +00:00
|
|
|
templateUrl: "partials/options.inventory.mounts.html"
|
|
|
|
|
})
|
|
|
|
|
.state('options.inventory.equipment', {
|
|
|
|
|
url: '/equipment',
|
|
|
|
|
templateUrl: "partials/options.inventory.equipment.html"
|
2013-11-10 19:47:33 +00:00
|
|
|
})
|
2014-11-29 02:24:56 +00:00
|
|
|
.state('options.inventory.timetravelers', {
|
|
|
|
|
url: '/timetravelers',
|
|
|
|
|
templateUrl: "partials/options.inventory.timetravelers.html"
|
|
|
|
|
})
|
2014-12-14 20:01:25 +00:00
|
|
|
.state('options.inventory.seasonalshop', {
|
|
|
|
|
url: '/seasonalshop',
|
|
|
|
|
templateUrl: "partials/options.inventory.seasonalshop.html"
|
|
|
|
|
})
|
2013-10-28 05:27:07 +00:00
|
|
|
|
|
|
|
|
// Options > Settings
|
|
|
|
|
.state('options.settings', {
|
|
|
|
|
url: "/settings",
|
|
|
|
|
controller: 'SettingsCtrl',
|
|
|
|
|
templateUrl: "partials/options.settings.html"
|
|
|
|
|
})
|
2013-11-16 00:25:09 +00:00
|
|
|
.state('options.settings.settings', {
|
|
|
|
|
url: "/settings",
|
|
|
|
|
templateUrl: "partials/options.settings.settings.html"
|
|
|
|
|
})
|
|
|
|
|
.state('options.settings.api', {
|
|
|
|
|
url: "/api",
|
|
|
|
|
templateUrl: "partials/options.settings.api.html"
|
|
|
|
|
})
|
|
|
|
|
.state('options.settings.export', {
|
|
|
|
|
url: "/export",
|
|
|
|
|
templateUrl: "partials/options.settings.export.html"
|
|
|
|
|
})
|
2014-04-16 17:33:03 +00:00
|
|
|
.state('options.settings.coupon', {
|
|
|
|
|
url: "/coupon",
|
|
|
|
|
templateUrl: "partials/options.settings.coupon.html"
|
|
|
|
|
})
|
2014-01-28 00:34:22 +00:00
|
|
|
.state('options.settings.subscription', {
|
|
|
|
|
url: "/subscription",
|
2014-02-12 01:11:21 +00:00
|
|
|
templateUrl: "partials/options.settings.subscription.html"
|
2014-01-28 00:34:22 +00:00
|
|
|
})
|
2015-01-27 14:43:21 +00:00
|
|
|
.state('options.settings.notifications', {
|
|
|
|
|
url: "/notifications",
|
|
|
|
|
templateUrl: "partials/options.settings.notifications.html"
|
|
|
|
|
})
|
2013-08-29 02:08:59 +00:00
|
|
|
|
|
|
|
|
var settings = JSON.parse(localStorage.getItem(STORAGE_SETTINGS_ID));
|
2013-08-29 05:45:19 +00:00
|
|
|
if (settings && settings.auth) {
|
|
|
|
|
$httpProvider.defaults.headers.common['Content-Type'] = 'application/json;charset=utf-8';
|
|
|
|
|
$httpProvider.defaults.headers.common['x-api-user'] = settings.auth.apiId;
|
2013-09-04 03:40:27 +00:00
|
|
|
$httpProvider.defaults.headers.common['x-api-key'] = settings.auth.apiToken;
|
2013-08-29 05:45:19 +00:00
|
|
|
}
|
2014-01-12 23:00:47 +00:00
|
|
|
}])
|