%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/waritko/jHackHistory/ROOT/static/js/
Upload File :
Create Path :
Current File : //home/waritko/jHackHistory/ROOT/static/js/controllers.js

'use strict';

if(!pageLen) var pageLen = 10;

var hackHistoryApp = angular.module('hackHistoryApp', []);

hackHistoryApp.controller('HackHistoryCtrl', function ($scope, $http)
{
    $scope.page = 1;
    // Flags if to show prev and next buttons
    $scope.showPrev = false;
    $scope.showNext = true;

    $scope.setData = function(pageNo)
    {
        $http.post('helloworld', {format: 'json', page: pageNo}, {xsrfHeaderName: 'X-WHH-XSRF-Token', xsrfCookieName: 'WHH-XSRF-Token'}).success(function(data)
        {
            $scope.hacks = data;
            // Handle showing of prev/next buttons
            $scope.showPrev = pageNo != 1;
            $scope.showNext = $scope.hacks.length >= pageLen;
        });
    };

    $scope.showDetail = function(hackId)
    {
        $scope.hacks.forEach(function(item)
        {
            if(item.id == hackId)
            {
                if(item.showBonus)
                {
                    item.showBonus = false;
                    item.style = 'glyphicon glyphicon-zoom-in';
                }
                else
                {
                    item.showBonus = true;
                    item.style = 'glyphicon glyphicon-zoom-out';
                }
            }
        });
    };

    $scope.nextPage = function()
    {
        $scope.page++;
        $scope.setData($scope.page);
    };

    $scope.prevPage = function()
    {
        $scope.page--;
        $scope.setData($scope.page);
    };

    $scope.reloadPage = function()
    {
        $scope.setData($scope.page);
    };

    $scope.formatDate = function(date)
    {
        return new Date(date).toLocaleString();
    };

    $scope.getItemCount = function(list)
    {
        var cnt = 0;
        list.forEach(function(item)
        {
            cnt += item.count;
        });
        return cnt;
    };

    $scope.getItemType = function(item)
    {
        switch(item)
        {
            case "CAPSULE":
            {
                return "Capsule";
            }
            case "EMITTER_A":
            {
                return "Resonator";
            }
            case "EMP_BURSTER":
            {
                return "XMP Burster";
            }
            case "ADA":
            {
                return "ADA Refactor";
            }
            case "JARVIS":
            {
                return "JARVIS Virus";
            }
            case "FORCE_AMP":
            {
                return "Force Amplifier";
            }
            case "HEATSINK":
            {
                return "Heatsink";
            }
            case "LINK_AMPLIFIER":
            {
                return "Link Amplifier";
            }
            case "MULTIHACK":
            {
                return "Multi Hack";
            }
            case "PORTAL_LINK_KEY":
            {
                return "Portal Key";
            }
            case "POWER_CUBE":
            {
                return "Power Cube";
            }
            case "RES_SHIELD":
            {
                return "Portal Shield";
            }
            case "TURRET":
            {
                return "Turret";
            }
            case "ULTRA_STRIKE":
            {
                return "Ultra Strike";
            }
            case "MEDIA":
            {
                return "Media";
            }
            case "EXTRA_SHIELD":
            {
                return "AXA Shield";
            }
            case "INTEREST_CAPSULE":
            {
                return "MUFG Capsule";
            }
            case "ULTRA_LINK_AMP":
            {
                return "SoftBank Ultra Link";
            }
            case "BOOSTED_POWER_CUBE":
            {
                return "Lawson Power Cube";
            }
            default :
            {
                return item;
            }
        }
    };

    $scope.setData($scope.page);

});

Zerion Mini Shell 1.0