HEX
Server: Apache
System: Linux 4485441ca2e2 6.8.0-1039-aws #41~22.04.1-Ubuntu SMP Thu Sep 11 11:03:07 UTC 2025 aarch64
User: (1000)
PHP: 8.2.24
Disabled: NONE
Upload Files
File: /var/www/html/assets/js/angular/controllers/fighter.js
(function() {
  if (typeof App !== "undefined" && App !== null) {
    App.controller('FighterCtrl', [
      '$scope', '$sce', '$http', '$timeout', function($scope, $sce, $http, $timeout) {

        $scope.loadingFlg = false;
        $scope.loadingAllPages = false;
        $scope.page = 1;
        $scope.selectedWeight = '';
        $scope.selectedBaseField = '';
        var current_page = location.hash.replace(/#/g, '');

        $scope.init = function(){
          $http({
            method: 'GET',
            url: $scope.api,
            params: {
              'type' : 'grjm_fighter',
              'filter[meta_key]' : 'en_name',
              'filter[orderby]' : 'meta_value',
              'filter[order]' : 'ASC',
              'filter[posts_per_page]' : 16,
              'page' : $scope.page
            }
          }).
          success(function(data, status, headers, config) {
            $scope.fighters = data;
            for(var i in $scope.fighters) {
              $scope.fighters[i].en_name = $scope.fighters[i].acf.en_name;
              $scope.fighters[i].weight = $scope.fighters[i].acf.weight_class;
              $scope.fighters[i].base = $scope.fighters[i].acf.base_field;
            }
            if (current_page > 1 ){
              for (var i=0; i < current_page-1; i++) {
                $scope.paginate('firstLoading');
              }
            }
          }).
          error(function(data, status, headers, config) {
          });

          $http({
            method: 'GET',
            url: $scope.site+'/wp-json/taxonomies/fighter-weight/terms'
          }).
          success(function(data, status, headers, config) {
            $scope.weight = data;
          }).
          error(function(data, status, headers, config) {
          });

          $http({
            method: 'GET',
            url: $scope.site+'/wp-json/taxonomies/fighter-base/terms'
          }).
          success(function(data, status, headers, config) {
            $scope.base_field = data;
          }).
          error(function(data, status, headers, config) {
          });

        };

        $scope.paginate = function(loadingType){
          $scope.loadingFlg = true;
          $scope.page += 1;

          $http({
            method: 'GET',
            url: $scope.api,
            params: {
              'type' : 'grjm_fighter',
              'filter[meta_key]' : 'en_name',
              'filter[orderby]' : 'meta_value',
              'filter[order]' : 'ASC',
              'filter[posts_per_page]' : 16,
              'page' : $scope.page
            }
          }).
          success(function(data, status, headers, config) {
            if (data.length > 0) {
              $scope.fighters = $scope.fighters.concat(data);
              for(var i in $scope.fighters) {
                $scope.fighters[i].en_name = $scope.fighters[i].acf.en_name;
                $scope.fighters[i].weight = $scope.fighters[i].acf.weight_class;
                $scope.fighters[i].base = $scope.fighters[i].acf.base_field;
              }
            } else {
              $scope.loadingAllPages = true;
            }
            $scope.loadingFlg = false;
            if (!loadingType){
              location.hash = $scope.page;
            }
            if (current_page == $scope.page ){
              $timeout(function() {
                var position = jQuery('#footer').offset().top;
                jQuery('body, html').animate({scrollTop: position}, 40, 'swing');
              }, 1000);
            }
          }).
          error(function(data, status, headers, config) {
            $scope.loadingFlg = false;
          });
        };

      }
    ]);
  }
}).call(this);