<commit_before>/**
 * Service containing functions to log the AJAX error messages.
 *
 * Exported function:
 * - show
 */
angular.module('lastLine.game').factory('showHttpError', [
    function () {
        /**
         * Log errors to the console and display the errors to display.
         *
         * @param {Object} data the response of the server.
         *
         * @returns {undefined}
         */
        var show = function (data) {
            if (data.hasOwnProperty('error_to_display')) {
                alert(data.error_to_display);
            } else {
                console.log(data.error);
            }
        };
        return {
            show: show
        };
    }
]);

/**
 * Service containing functions to interact with the squares.
 *
 * Exported functions:
 * - reset
 * - highlight
 */
angular.module('lastLine.game').factory('squares', [
    function () {
        /**
         * Return the highlighted squares to their normal state.
         *
         * @param {type} highlightedSquares The list of the highlighted squares.
         */
        var reset = function (highlightedSquares) {
            for (var index in highlightedSquares) {
                var id = highlightedSquares[index];
                d3.select('#' + id).classed('highlightedSquare', false);
            }
        };

        /**
         * Add a class to highlight the selected squares.
         *
         * @param {type} highlightedSquares The list of squares to highlight.
         */
        var highlight = function (highlightedSquares) {
            for (var index in highlightedSquares) {
                var id = highlightedSquares[index];
                d3.select('#' + id).classed('highlightedSquare', true);
            }
        };

        return {
            reset: reset,
            highlight: highlight
        };
    }
]);

/**
 * Service containing functions to interact with the player.
 *
 * Exported functions:
 * - move
 * - init
 */
angular.module('lastLine.game').factory('player', [
    function () {
        var playerIdKey = 'id';
        var xCoordCircleKey = 'cx';
        var yCoordCircleKey = 'cy';
        var radiusKey = 'r';
        var transformKey = 'transform';
        var boardLayer = 'boardLayer';

        /**
         * Move the player to a new square.
         *<commit_msg>ref(game-services.js): use forEach method to loop on arrays.<commit_after>/**
 * Service containing functions to log the AJAX error messages.
 *
 * Exported function:
 * - show
 */
angular.module('lastLine.game').factory('showHttpError', [
    function () {
        /**
         * Log errors to the console and display the errors to display.
         *
         * @param {Object} data the response of the server.
         *
         * @returns {undefined}
         */
        var show = function (data) {
            if (data.hasOwnProperty('error_to_display')) {
                alert(data.error_to_display);
            } else {
                console.log(data.error);
            }
        };
        return {
            show: show
        };
    }
]);

/**
 * Service containing functions to interact with the squares.
 *
 * Exported functions:
 * - reset
 * - highlight
 */
angular.module('lastLine.game').factory('squares', [
    function () {
        /**
         * Return the highlighted squares to their normal state.
         *
         * @param {type} highlightedSquares The list of the highlighted squares.
         */
        var reset = function (highlightedSquares) {
            highlightedSquares.forEach(function (value) {
                d3.select('#' + value).classed('highlightedSquare', false);
            });
        };

        /**
         * Add a class to highlight the selected squares.
         *
         * @param {type} highlightedSquares The list of squares to highlight.
         */
        var highlight = function (highlightedSquares) {
            highlightedSquares.forEach(function (value) {
                d3.select('#' + value).classed('highlightedSquare', true);
            });
        };

        return {
            reset: reset,
            highlight: highlight
        };
    }
]);

/**
 * Service containing functions to interact with the player.
 *
 * Exported functions:
 * - move
 * - init
 */
angular.module('lastLine.game').factory('player', [
    function () {
        var playerIdKey = 'id';
        var xCoordCircleKey = 'cx';
        var yCoordCircleKey = 'cy';
        var radiusKey = 'r';
        var transformKey = 'transform';
        var boardLayer = 'boardLayer';

        /**
         * Move the player to a new square.
         *
{'fraction_non_alphanumeric': 0.11449557139771009, 'fraction_numerical': 0.0008641175199827177, 'mean_word_length': 1.7315634218289087, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6195311', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1189, 'n_words': 335}