<commit_before>angular.module('badminton').controller('matchPageController', function ($scope, $rootScope, $state, $uibModal, $stateParams, $login, usSpinnerService, $localStorage) {
    'use strict'


    $scope.games = $localStorage.games;
    $scope.isPlay = false;
    $scope.teamBpoints = 0;
    $scope.teamApoints = 0;
    $scope.isStart = false;
    $scope.activePlayer = null;
    $scope.teamAId = "playerA2";
    $scope.teamBId = "playerB1";
    $scope.serveTeam = "";
    $scope.receiveTeam = "";
    $scope.courtDisable = false; 
    $scope.setActivePlayer = function(id){
        if(id == "playerA2"){
            if ($scope.teamApoints==0 && $scope.teamBpoints==0) {
                $scope.activePlayer = $scope.playerA2;
                $scope.serveTeam = "teamA";
                $scope.receiveTeam = "teamB";
                $("#playerA2").addClass("activePlayer");
            }
        }else if(id == "playerB1"){
            if ($scope.teamApoints==0 && $scope.teamBpoints==0) {
                $scope.activePlayer = $scope.playerB1;
                $("#playerB1").addClass("activePlayer");
                $scope.serveTeam = "teamB";
                $scope.receiveTeam = "teamA";
            }

        }
            
            

    }
    


        
    $scope.startSpin = function () {
        usSpinnerService.spin('spinner-1');
    }
    $scope.stopSpin = function () {
        usSpinnerService.stop('spinner-1');
    }



    $scope.getClass = function (index) {
        if ((index + 1) % 2 == 0) {
            return "even-card";
        } else {
            return "odd-card";
        }
    }



    $scope.play = function (number) {

        $scope.isPlay = true;
        $scope.gamesDetails = {};
        $scope.gamesDetails = $scope.games[number - 1];
        console.log($scope.gamesDetails);
        $scope.playerA1 = $scope.gamesDetails.teams[0].players[0];
        $scope.playerA2 = $scope.gamesDetails.teams[0].players[1];

        $scope.playerB1 = $scope.gamesDetails.teams[1].players[0];
        $scope.playerB2 = $scope.gamesDetails.teams[1].players[1];
    }

    $scope.swapA = function () {
        var temp = $scope.playerA1;
        $scope.playerA1 = $scope.playerA2;
        $scope.playerA2 = temp;

    }
    $scope.swapB = function () {
        var temp = $scope.playerB1;
        $scope.playerB1 = $scope.playerB2;
        $scope.playerB2 = temp;
    }



    $scope.start = function () {
        $scope.isStart = true;

    }

    $scope.teamApointsUpdate = function () {
        
        $scope.teamApoints = $scope.teamApoints + 1;
        if($scope.teamApoints > 20 ){
            alert("game won by Bulldozers");
            window.location.reload();
        }
        $scope.courtDisable = true; 
        $('.court > div').css('cursor','not-allowed');
        if($scope.receiveTeam != "teamA"){
            $scope.swapA();
        }
        $scope.serveTeam = "teamA";
        $scope.receiveTeam = "teamB";
        
        // var ele = document.getElementsByClassName("activePlayer");
        var ele =$(".activePlayer");
        ele.removeClass("activePlayer");
        if(ele.attr('id') == "playerA2"){
             $("#playerA1").addClass("activePlayer");
        }
        else if(ele.attr('id') == "playerA1"){
            $("#playerA2").addClass("activePlayer");
        }else {
            if($scope.teamApoints % 2 == 0){   
                $("#playerA2").addClass("activePlayer");
            }else{
                $("#playerA1").addClass("activePlayer");

            }
        }
        
        
    }
    $scope.teamBpointsUpdate = function () {
        
        $scope.teamBpoints = $scope.teamBpoints + 1;
        if($scope.teamBpoints > 20 ){
            
            alert("game won by smashDroppers");
            window.location.reload();
        }
        $scope.courtDisable = true; 
        $('.court > div').css('cursor','not-allowed');
        if($scope.receiveTeam != "teamB"){
            $scope.swapB();
        }
        $scope.serveTeam = "teamB";
        $scope.receiveTeam = "teamA";
        // var ele = document.getElementsByClassName("activePlayer");
        var ele =$(".activePlayer");
        ele.removeClass("activePlayer");
        if(ele.attr('id') == "playerB2"){
            $("#playerB1").addClass("activePlayer");
        }
        else if(ele.attr('id') == "playerB1"){
            $("#playerB2").addClass("activePlayer");
        }else {
            if($scope.teamBpoints % 2 == 0){   
                $("#playerB1").addClass("activePlayer");
            }else{
                $("#playerB2").addClass("activePlayer");

            }
        }
        
    }

    $scope.gotoHome = function () {
        $state.go("homePage");
    }
    $scope.gotoPlayers = function () {
        $state.go("playersPage");
    }
    $scope.gotoAuction = function () {
        $state.go("auctionPage");
    }
    $scope.gotoFixtures = function () {
        $state.go("fixturesPage");
    }

})
<commit_msg>fix on setting active player<commit_after>angular.module('badminton').controller('matchPageController', function ($scope, $rootScope, $state, $uibModal, $stateParams, $login, usSpinnerService, $localStorage) {
    'use strict'


    $scope.games = $localStorage.games;
    $scope.isPlay = false;
    $scope.teamBpoints = 0;
    $scope.teamApoints = 0;
    $scope.isStart = false;
    $scope.activePlayer = null;
    $scope.teamAId = "playerA2";
    $scope.teamBId = "playerB1";
    $scope.serveTeam = "";
    $scope.receiveTeam = "";
    $scope.courtDisable = false; 

    $scope.setActivePlayer = function(id){
        if(id == "playerA2"){
            if ($scope.teamApoints==0 && $scope.teamBpoints==0) {
                $scope.activePlayer = $scope.playerA2;
                $scope.serveTeam = "teamA";
                $scope.receiveTeam = "teamB";
                $(".activePlayer").removeClass('activePlayer');
                $("#playerA2").addClass("activePlayer");
            }
        }else if(id == "playerB1"){
            if ($scope.teamApoints==0 && $scope.teamBpoints==0) {
                $scope.activePlayer = $scope.playerB1;
                $(".activePlayer").removeClass('activePlayer');
                $("#playerB1").addClass("activePlayer");
                $scope.serveTeam = "teamB";
                $scope.receiveTeam = "teamA";
            }

        }
            
            

    }
    


        
    $scope.startSpin = function () {
        usSpinnerService.spin('spinner-1');
    }
    $scope.stopSpin = function () {
        usSpinnerService.stop('spinner-1');
    }



    $scope.getClass = function (index) {
        if ((index + 1) % 2 == 0) {
            return "even-card";
        } else {
            return "odd-card";
        }
    }



    $scope.play = function (number) {

        $scope.isPlay = true;
        $scope.gamesDetails = {};
        $scope.gamesDetails = $scope.games[number - 1];
        console.log($scope.gamesDetails);
        $scope.playerA1 = $scope.gamesDetails.teams[0].players[0];
        $scope.playerA2 = $scope.gamesDetails.teams[0].players[1];

        $scope.playerB1 = $scope.gamesDetails.teams[1].players[0];
        $scope.playerB2 = $scope.gamesDetails.teams[1].players[1];
    }

    $scope.swapA = function () {
        var temp = $scope.playerA1;
        $scope.playerA1 = $scope.playerA2;
        $scope.playerA2 = temp;

    }
    $scope.swapB = function () {
        var temp = $scope.playerB1;
        $scope.playerB1 = $scope.playerB2;
        $scope.playerB2 = temp;
    }



    $scope.start = function () {
        $scope.isStart = true;

    }

    $scope.teamApointsUpdate = function () {
        
        $scope.teamApoints = $scope.teamApoints + 1;
        if($scope.teamApoints > 20 ){
            alert("game won by Bulldozers");
            window.location.reload();
        }
        $scope.courtDisable = true; 
        $('.court > div').css('cursor','not-allowed');
        if($scope.receiveTeam != "teamA"){
            $scope.swapA();
        }
        $scope.serveTeam = "teamA";
        $scope.receiveTeam = "teamB";
        
        // var ele = document.getElementsByClassName("activePlayer");
        var ele =$(".activePlayer");
        ele.removeClass("activePlayer");
        if(ele.attr('id') == "playerA2"){
             $("#playerA1").addClass("activePlayer");
        }
        else if(ele.attr('id') == "playerA1"){
            $("#playerA2").addClass("activePlayer");
        }else {
            if($scope.teamApoints % 2 == 0){   
                $("#playerA2").addClass("activePlayer");
            }else{
                $("#playerA1").addClass("activePlayer");

            }
        }
        
        
    }
    $scope.teamBpointsUpdate = function () {
        
        $scope.teamBpoints = $scope.teamBpoints + 1;
        if($scope.teamBpoints > 20 ){
            
            alert("game won by smashDroppers");
            window.location.reload();
        }
        $scope.courtDisable = true; 
        $('.court > div').css('cursor','not-allowed');
        if($scope.receiveTeam != "teamB"){
            $scope.swapB();
        }
        $scope.serveTeam = "teamB";
        $scope.receiveTeam = "teamA";
        // var ele = document.getElementsByClassName("activePlayer");
        var ele =$(".activePlayer");
        ele.removeClass("activePlayer");
        if(ele.attr('id') == "playerB2"){
            $("#playerB1").addClass("activePlayer");
        }
        else if(ele.attr('id') == "playerB1"){
            $("#playerB2").addClass("activePlayer");
        }else {
            if($scope.teamBpoints % 2 == 0){   
                $("#playerB1").addClass("activePlayer");
            }else{
                $("#playerB2").addClass("activePlayer");

            }
        }
        
    }

    $scope.gotoHome = function () {
        $state.go("homePage");
    }
    $scope.gotoPlayers = function () {
        $state.go("playersPage");
    }
    $scope.gotoAuction = function () {
        $state.go("auctionPage");
    }
    $scope.gotoFixtures = function () {
        $state.go("fixturesPage");
    }

})

{'fraction_non_alphanumeric': 0.16446199407699902, 'fraction_numerical': 0.012240868706811452, 'mean_word_length': 1.866723259762309, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '669925', 'n_tokens_mistral': 3182, 'n_tokens_neox': 3036, 'n_words': 442}