{"size": 2232, "ext": "js", "max_stars_repo_path": "components/modules/saisonview/js/saisonview.js", "max_stars_repo_name": "dfernandesnamics/spielerstatistik", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "components/modules/saisonview/js/saisonview.js", "max_issues_repo_name": "dfernandesnamics/spielerstatistik", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "components/modules/saisonview/js/saisonview.js", "max_forks_repo_name": "dfernandesnamics/spielerstatistik", "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": 20.4770642202, "max_line_length": 69, "alphanum_fraction": 0.5201612903}
(function ($) {
	"use strict";
	/**
	 * saisonview module implementation.
	 *
	 * @author Daniel Fernandes <daniel.fernandes@namics.com>
	 * @namespace Tc.Module
	 * @class Saisonview
	 * @extends Tc.Module
	 */
	Tc.Module.Saisonview = Tc.Module.extend({

		init: function ($ctx, sandbox, modId) {
			this._super($ctx, sandbox, modId);


		},

		on: function (callback) {
			var mod = this,
				$ctx = mod.$ctx;

			mod.getPlayerData();
			
			$ctx.on('startProcess', $.proxy(mod.getPlayerData, mod));

			callback();
		},


		getPlayerData: function (evt, data) {
			var mod = this;
			$.ajax({
				url: "/views/data",
				method: "post",
				success: function (response) {
					var player = mod.$ctx.data('player');
					var season = mod.$ctx.data('season');
					if (typeof (response[player].seasons[season]) === 'undefined') {
						alert('not defined');
					}
					mod.processData(response);

				},
				error: function (error) {
					alert(error);
				}
			})
		},

		processData: function (data) {
			var mod = this;
			var player = mod.$ctx.data('player');
			var season = mod.$ctx.data('season');
			$('body').addClass(player);
			$('body').addClass('saison');


			$(data[player].seasons[season].data).each(
				function (index, item) {
					var html = "<tr>";
					html += "<td>";
					html += item.competition;
					html += "</td>";
					html += "<td>";
					html += item.deployments;
					html += "</td>";
					html += "<td>";
					html += item.goals;
					html += "</td>";
					html += "<td>";
					html += item.assists;
					html += "</td>";
					html += "<td>";
					html += item.yellowCards;
					html += "</td>";
					html += "<td>";
					html += item.yellowRedCards;
					html += "</td>";
					html += "<td>";
					html += item.redCards;
					html += "</td>";
					html += "<td>";
					html += item.playMinutes;
					html += "</td>";
					html += "</tr>";


					$(".js-table-content").append(html);
				}
			);
			var clubName = $(data[player].specialAttributes);
			if (season == season) {
				$('.seasonTitle').append("<h3>" + season + "</h3>");
				$('.seasonteam').append("<h3>" + clubName[0].club + "</h3>");
			}
		},


		after: function () {
			var mod = this,
				$ctx = mod.$ctx;


		}

	});
}(Tc.$));
