{"size": 809, "ext": "js", "max_stars_repo_path": "public/modules/core/directives/board.client.directive.js", "max_stars_repo_name": "schafer14/Chess4", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/modules/core/directives/board.client.directive.js", "max_issues_repo_name": "schafer14/Chess4", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/modules/core/directives/board.client.directive.js", "max_forks_repo_name": "schafer14/Chess4", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.5151515152, "max_line_length": 68, "alphanum_fraction": 0.6131025958}
'use strict';

angular.module('core').directive('board', [
	function() {
		return {
			templateUrl: 'modules/core/templates/board.client.template.html',
			restrict: 'E',
			scope: {
				provider: '=',
			},
			link: function postLink(scope, element, attrs) {
				scope.squareIter = new Array(scope.provider.squaresPerSide)				
				var groupsOfFourRegex = /..../g;

				scope.drawBoard = function(board) {
					if (angular.isUndefined(board)) {
						return false;
					}

					scope.squares = {};
					var pieces = board.match(groupsOfFourRegex);
					angular.forEach(pieces, function(piece) {
						scope.squares[piece.substring(0, 2)] = piece[2] + piece[3];
					});
				};

				scope.$watch('provider.toString()', function(value) {
					scope.drawBoard(scope.provider.toString());
				});
			}
		};
	}
]);