Commit 3e865e02 authored by Hermann Mayer's avatar Hermann Mayer

[Frontend] Added statistics for matches.

parent b4a0b5da
......@@ -89,3 +89,7 @@ padding: 0;
text-shadow: 0.1em 0.1em 7px #fff;
}
.content {
padding: 10px;
}
......@@ -3,6 +3,17 @@ class MatchesController < ApplicationController
# GET /matches.json
def index
@matches = Match.all(:include => [:teamA, :teamB, :winner])
@stats = {}
# Init stats hash table
Team.all.each do |team|
@stats[team.name] = 0
end
# Iterate all matches and count winners
@matches.each do |match|
@stats[match.winner.name] += 1
end
respond_to do |format|
format.html # index.html.erb
......
......@@ -5,7 +5,7 @@
Trackt eure Kicker Sessions! Denn für genau dieses Anliegen,<br> wurde diese Applikation geschrieben.
</p>
<%= link_to new_match_path, :class => "btn btn-success btn-large" do %>
<i class="icon-pencil icon-white"></i> Match jetzt eintragen
<i class="icon-pencil icon-white"></i> Jetzt Match eintragen
<% end %>
</div>
......@@ -44,11 +44,31 @@
<div class="navbar-inner">
<div class="container">
<ul class="nav">
<li class="<%= 'active' if params[:controller] == 'application' and params[:action] == 'index' %>"><%= link_to "Home", :controller => "application" %></li>
<li class="<%= 'active' if params[:controller] == 'teams' %>"><%= link_to "Teams", :controller => "teams" %></li>
<li class="<%= 'active' if params[:controller] == 'players' %>"><%= link_to "Spieler", :controller => "players" %></li>
<li class="<%= 'active' if params[:controller] == 'matches' %>"><%= link_to "Matches", :controller => "matches" %></li>
<li class="<%= 'active' if params[:controller] == 'application' and params[:action] == 'about' %>"><%= link_to "Über das Projekt", :controller => "application", :action => "about" %></li>
<li class="<%= 'active' if params[:controller] == 'application' and params[:action] == 'index' %>">
<%= link_to :controller => "application" do %>
<i class="icon icon-home"></i> Home
<% end %>
</li>
<li class="<%= 'active' if params[:controller] == 'teams' %>">
<%= link_to :controller => "teams" do %>
<i class="icon icon-th-large"></i> Teams
<% end %>
</li>
<li class="<%= 'active' if params[:controller] == 'players' %>">
<%= link_to :controller => "players" do %>
<i class="icon icon-user"></i> Spieler
<% end %>
</li>
<li class="<%= 'active' if params[:controller] == 'matches' %>">
<%= link_to :controller => "matches" do %>
<i class="icon icon-flag"></i> Matches
<% end %>
</li>
<li class="<%= 'active' if params[:controller] == 'application' and params[:action] == 'about' %>">
<%= link_to :controller => "application", :action => "about" do %>
<i class="icon icon-info-sign"></i> Über das Projekt
<% end %>
</li>
</ul>
</div>
</div>
......@@ -56,7 +76,7 @@
</div>
<div class="row-fluid">
<div class="span12">
<div class="span12 content">
<%= bootstrap_flash %>
<%= yield %>
</div>
......@@ -64,8 +84,12 @@
<hr>
<div class="footer">
<p>&copy; Hermann Mayer 2013</p>
<div style="line-height: 34px;" class="footer">
<div class="masthead">&copy; <a href="http://hermann-mayer.net">Hermann Mayer</a> 2013
<ul class="nav nav-pills pull-right">
<li><a href="https://gitorious.hermann-mayer.net/kickertracker"><i class="icon icon-folder-open"></i> Projekt Quellcode</a></li>
</ul>
</div>
</div>
</div> <!-- /container -->
......
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Team', 'Overall Wins'],
<% @stats.each do |team, wins| %>
["<%= team %>", <%= wins%>],
<% end %>
]);
var options = {
backgroundColor: '#EEEEEE',
chartArea: {
left: -5,
top: 10,
height: 180
}
};
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
<div class="hero-unit">
<h2>Matches Statistik</h2>
<div id="chart_div" style="width: 600px; height: 200px;"></div>
</div>
<%= render 'stats' %>
<div>
<h2 class="">
Matches Auflistung
......
This diff is collapsed.
......@@ -11,8 +11,8 @@ theaser.xcf: theaser-dea533b2ed378c30542eb125baf59221.xcf
theaser/index.xcf: theaser-dea533b2ed378c30542eb125baf59221.xcf
application.js: application-34857f189c2d7d6e27b8fcad37e1b238.js
application/index.js: application-34857f189c2d7d6e27b8fcad37e1b238.js
application.css: application-af9b28bdd8095d2eb72357ca5d32d162.css
application/index.css: application-af9b28bdd8095d2eb72357ca5d32d162.css
application.css: application-a304f57cc96f9751566e216109aa6995.css
application/index.css: application-a304f57cc96f9751566e216109aa6995.css
fontawesome-webfont.eot: fontawesome-webfont-635909f146e208b3509acdf3b154bf0d.eot
fontawesome-webfont/index.eot: fontawesome-webfont-635909f146e208b3509acdf3b154bf0d.eot
fontawesome-webfont.ttf: fontawesome-webfont-6a4e273908b7e43d9e479d38b8ae5957.ttf
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment