<commit_before>var underscore = angular.module('underscore', []);




underscore.factory('_', function() {
    return window._; // assumes underscore has already been loaded on the page
});



var GameController = (function(){
    function GameController($scope, $timeout, $window, _, $interval) {
        var _this = this;

        this.$scope = $scope;
        this.$timeout = $timeout;
        this.$window = $window;
        this.$interval = $interval
        this.connection = null;
        this._ = _;
        this.game = {};

        this.$scope.players = [];
        this.$scope.throws = 0;

        this.$scope.url = 'http://' + $window.location.hostname + ':8042/controller';
        this.$scope.time = 30;
        this.$scope.timerStatus = 'Remain';
        this.$scope.timerVisible = false;
        this.$scope.idleVisible = true;

        this.$scope.totalScore = function (){
            var score = 0;
            _this.$scope.players.forEach(function(player){
                if (player.score){
                    score += player.score;
                }
            });
            return score;
        }

        $window.addEventListener("load", function () {
            var connection = new WebSocket("ws://" + $window.location.hostname + ":8043");

            connection.onopen = _this.onopen.bind(_this);
            connection.onclose = _this.onclose.bind(_this);
            connection.onerror = _this.onerror.bind(_this);
            connection.onmessage = _this.onmessage.bind(_this);

            _this.connection = connection;

            _this.game = new Game(_this.$window);

            // fuuuuuuuuujky fujky
            $('#foo').click(function (e){
                _this.game.throw(e);
            });
        });

        function updateTime() {
            _this.$scope.time -= 1;
            _this.$scope.time = _this.$scope.time < 0 ? 30 : _this.$scope.time;
        }


        this.stopTime = $interval(updateTime, 1000);

        // listen on DOM destroy (removal) event, and cancel the next UI update
        // to prevent updating time after the DOM element was removed.
//        this.on('$destroy', function() {
//            $interval.cancel(_this.stopTime);
//        });

        this.messageTypeToFunction = {
            CONTROLLER_NEW: this.onNewController.bind(_this),
            CONTROLLER_CONNECTION_CLOSE: this.onControllerClose.bind(_this),
            CONTROLLER_THROW: this.onControllerThrow.bind(_this)
        };
    }

    GameController.prototype.onopen = function(){
        this.connection.send('I_AM_DISPLAY');
    };<commit_msg>reset hry<commit_after>var underscore = angular.module('underscore', []);




underscore.factory('_', function() {
    return window._; // assumes underscore has already been loaded on the page
});



var GameController = (function(){
    function GameController($scope, $timeout, $window, _, $interval) {
        var _this = this;

        this.$scope = $scope;
        this.$timeout = $timeout;
        this.$window = $window;
        this.$interval = $interval
        this.connection = null;
        this._ = _;
        this.game = {};

        this.$scope.players = [];
        this.$scope.throws = 0;

        this.$scope.url = 'http://' + $window.location.hostname + ':8042/controller';
        this.$scope.time = 30;
        this.$scope.timerStatus = 'Remain';
        this.$scope.timerVisible = false;
        this.$scope.idleVisible = true;
        this.$scope.showtable = false;

        this.$scope.totalScore = function (){
            var score = 0;
            _this.$scope.players.forEach(function(player){
                if (player.score){
                    score += player.score;
                }
            });
            return score;
        }

        $window.addEventListener("load", function () {
            var connection = new WebSocket("ws://" + $window.location.hostname + ":8043");

            connection.onopen = _this.onopen.bind(_this);
            connection.onclose = _this.onclose.bind(_this);
            connection.onerror = _this.onerror.bind(_this);
            connection.onmessage = _this.onmessage.bind(_this);

            _this.connection = connection;

            _this.game = new Game(_this.$window);

            // fuuuuuuuuujky fujky
            $('#foo').click(function (e){
                _this.game.throw(e);
            });
        });

        function updateTime() {
            _this.$scope.time -= 1;

            if (_this.$scope.showtable && _this.$scope.time > 0){
                _this.$scope.timerVisible = true;
                return
            }

            if (_this.$scope.showtable && _this.$scope.time < 0){
                _this.$scope.idleVisible = false;
                _this.$scope.showtable = false;
                _this.$scope.time = 30;
                return
            }

            if(_this.$scope.idleVisible)
                return;

            if(_this.$scope.time < 0){
                _this.$scope.idleVisible = true;
                _this.$scope.timerVisible = true;
                _this.$scope.showtable = true;
                _this.$scope.time = 8;
                _this.resetGame();
                return;
            }

            _this.$scope.time = _this.$scope.time < 0 ? 30 : _this.$scope.time;
        }


        this.stopTime = $interval(updateTime, 1000);

        // listen on DOM destroy (removal) event, and cancel the next UI update
        // to prevent updating time after the DOM element was removed.
//        this.on('$destroy', function() {
//            $interval.cancel(_this.stopTime);
//        });

        this.messageTypeToFunction = {
            CONTROLLER_NEW: this.onNewController.bind(_this),
            CONTROLLER_CONNECTION_CLOSE: this.onControllerClose.bind(_this),
            CONTROLLER_THROW: this.onControllerThrow.bind(_this)
        };
    }

    GameController.prototype.onopen = function(){
        this.connection.send('I_AM_DISPLAY');
    };
{'fraction_non_alphanumeric': 0.1314647981314648, 'fraction_numerical': 0.007674341007674341, 'mean_word_length': 1.77674849467346, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '2161797', 'n_tokens_mistral': 1724, 'n_tokens_neox': 1618, 'n_words': 313}