Advertisement
Koviko

BattleINF Tower Floor Selector

Dec 4th, 2015
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function goToTower(floor) {
  2.   'use strict';
  3.  
  4.   /*globals angular*/
  5.   if (floor > 0) {
  6.     var $body = angular.element(document.body),
  7.       $injector = $body.injector(),
  8.       $scope = $body.scope(),
  9.       $http = $injector.get('$http'),
  10.       $location = $injector.get('$location');
  11.  
  12.     if ($http && $scope && $scope.g) {
  13.       $http({
  14.         method: 'POST',
  15.         url: '/user/setStage',
  16.         data: {
  17.           stageArgs: {
  18.             areaId: '0',
  19.             stageIndex: floor - 1
  20.           }
  21.         }
  22.       }).success(function (data) {
  23.         $scope.g.stage = {
  24.           name: data.stageName,
  25.           activity: data.activity,
  26.           monsters: data.monsters,
  27.           requirements: data.requirements,
  28.           messages: []
  29.         };
  30.  
  31.         $scope.user.lastStageId = data.stageId;
  32.  
  33.         if ($location) {
  34.           $location.path('world/location');
  35.         }
  36.       });
  37.     }
  38.   }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement