diff options
author | nfoy <nfoy@purdue.edu> | 2014-04-03 16:15:46 -0400 |
---|---|---|
committer | nfoy <nfoy@purdue.edu> | 2014-04-03 16:15:46 -0400 |
commit | 5169363d6698fb87372efcb7ace552b89953584e (patch) | |
tree | ff42d819be510dfe929b4cd9dbc1cd25f51c9785 /app/views | |
parent | 2b79a033262dfe610eb22b7f6b3614db9cb134b1 (diff) | |
parent | 9f19d0e16d7920e07255c0fbe596c518d1aa415f (diff) |
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'app/views')
-rw-r--r-- | app/views/matches/index.html.erb | 4 | ||||
-rw-r--r-- | app/views/remote_usernames/_form.html.erb | 29 | ||||
-rw-r--r-- | app/views/remote_usernames/edit.html.erb | 6 | ||||
-rw-r--r-- | app/views/remote_usernames/index.html.erb | 31 | ||||
-rw-r--r-- | app/views/remote_usernames/index.json.jbuilder | 4 | ||||
-rw-r--r-- | app/views/remote_usernames/new.html.erb | 5 | ||||
-rw-r--r-- | app/views/remote_usernames/show.html.erb | 19 | ||||
-rw-r--r-- | app/views/remote_usernames/show.json.jbuilder | 1 | ||||
-rw-r--r-- | app/views/tournaments/_form.html.erb | 20 | ||||
-rw-r--r-- | app/views/tournaments/index.json.jbuilder | 2 | ||||
-rw-r--r-- | app/views/tournaments/show.html.erb | 127 | ||||
-rw-r--r-- | app/views/tournaments/show.json.jbuilder | 2 |
12 files changed, 206 insertions, 44 deletions
diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 4193f16..0f86da6 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -36,9 +36,9 @@ width="<%= 300 * @matches.count / 2 + 50 %>" height="<%= 200 * @matches.count + 50 %>" xmlns="http://www.w3.org/2000/svg"> - <% @matches.each do |tournament | %> + <% (1..@matches.count).each do |i| %> <g class="svg-match" > - + </g> <% end %> diff --git a/app/views/remote_usernames/_form.html.erb b/app/views/remote_usernames/_form.html.erb new file mode 100644 index 0000000..5da1f8f --- /dev/null +++ b/app/views/remote_usernames/_form.html.erb @@ -0,0 +1,29 @@ +<%= form_for(@remote_username) do |f| %> + <% if @remote_username.errors.any? %> + <div id="error_explanation"> + <h2><%= pluralize(@remote_username.errors.count, "error") %> prohibited this remote_username from being saved:</h2> + + <ul> + <% @remote_username.errors.full_messages.each do |msg| %> + <li><%= msg %></li> + <% end %> + </ul> + </div> + <% end %> + + <div class="field"> + <%= f.label :game_id %><br> + <%= f.text_field :game_id %> + </div> + <div class="field"> + <%= f.label :user_id %><br> + <%= f.text_field :user_id %> + </div> + <div class="field"> + <%= f.label :user_name %><br> + <%= f.text_field :user_name %> + </div> + <div class="actions"> + <%= f.submit %> + </div> +<% end %> diff --git a/app/views/remote_usernames/edit.html.erb b/app/views/remote_usernames/edit.html.erb new file mode 100644 index 0000000..52d4b37 --- /dev/null +++ b/app/views/remote_usernames/edit.html.erb @@ -0,0 +1,6 @@ +<h1>Editing remote_username</h1> + +<%= render 'form' %> + +<%= link_to 'Show', @remote_username %> | +<%= link_to 'Back', remote_usernames_path %> diff --git a/app/views/remote_usernames/index.html.erb b/app/views/remote_usernames/index.html.erb new file mode 100644 index 0000000..14f5876 --- /dev/null +++ b/app/views/remote_usernames/index.html.erb @@ -0,0 +1,31 @@ +<h1>Listing remote_usernames</h1> + +<table> + <thead> + <tr> + <th>Game</th> + <th>User</th> + <th>User name</th> + <th></th> + <th></th> + <th></th> + </tr> + </thead> + + <tbody> + <% @remote_usernames.each do |remote_username| %> + <tr> + <td><%= remote_username.game %></td> + <td><%= remote_username.user %></td> + <td><%= remote_username.user_name %></td> + <td><%= link_to 'Show', remote_username %></td> + <td><%= link_to 'Edit', edit_remote_username_path(remote_username) %></td> + <td><%= link_to 'Destroy', remote_username, method: :delete, data: { confirm: 'Are you sure?' } %></td> + </tr> + <% end %> + </tbody> +</table> + +<br> + +<%= link_to 'New Remote username', new_remote_username_path %> diff --git a/app/views/remote_usernames/index.json.jbuilder b/app/views/remote_usernames/index.json.jbuilder new file mode 100644 index 0000000..c9fbc0f --- /dev/null +++ b/app/views/remote_usernames/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@remote_usernames) do |remote_username| + json.extract! remote_username, :id, :game_id, :user_id, :user_name + json.url remote_username_url(remote_username, format: :json) +end diff --git a/app/views/remote_usernames/new.html.erb b/app/views/remote_usernames/new.html.erb new file mode 100644 index 0000000..b9cfcf4 --- /dev/null +++ b/app/views/remote_usernames/new.html.erb @@ -0,0 +1,5 @@ +<h1>New remote_username</h1> + +<%= render 'form' %> + +<%= link_to 'Back', remote_usernames_path %> diff --git a/app/views/remote_usernames/show.html.erb b/app/views/remote_usernames/show.html.erb new file mode 100644 index 0000000..416ca9d --- /dev/null +++ b/app/views/remote_usernames/show.html.erb @@ -0,0 +1,19 @@ +<p id="notice"><%= notice %></p> + +<p> + <strong>Game:</strong> + <%= @remote_username.game %> +</p> + +<p> + <strong>User:</strong> + <%= @remote_username.user %> +</p> + +<p> + <strong>User name:</strong> + <%= @remote_username.user_name %> +</p> + +<%= link_to 'Edit', edit_remote_username_path(@remote_username) %> | +<%= link_to 'Back', remote_usernames_path %> diff --git a/app/views/remote_usernames/show.json.jbuilder b/app/views/remote_usernames/show.json.jbuilder new file mode 100644 index 0000000..1a0f6f9 --- /dev/null +++ b/app/views/remote_usernames/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @remote_username, :id, :game_id, :user_id, :user_name, :created_at, :updated_at diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb index 3dadbf7..38855a0 100644 --- a/app/views/tournaments/_form.html.erb +++ b/app/views/tournaments/_form.html.erb @@ -24,6 +24,26 @@ <%= f.number_field :status %> </div> <div class="field"> + <%= f.label :min_players_per_team %><br> + <%= f.number_field :min_players_per_team %> + </div> + <div class="field"> + <%= f.label :max_players_per_team %><br> + <%= f.number_field :max_players_per_team %> + </div> + <div class="field"> + <%= f.label :min_teams_per_match %><br> + <%= f.number_field :min_teams_per_match %> + </div> + <div class="field"> + <%= f.label :max_teams_per_match %><br> + <%= f.number_field :max_teams_per_match %> + </div> + <div class="field"> + <%= f.label :set_rounds %><br> + <%= f.number_field :set_rounds %> + </div> + <div class="field"> <%= f.label :randomized_teams %><br> <%= f.check_box :randomized_teams %> </div> diff --git a/app/views/tournaments/index.json.jbuilder b/app/views/tournaments/index.json.jbuilder index 32587df..4038f04 100644 --- a/app/views/tournaments/index.json.jbuilder +++ b/app/views/tournaments/index.json.jbuilder @@ -1,4 +1,4 @@ json.array!(@tournaments) do |tournament| - json.extract! tournament, :id, :name, :game_id, :status, :randomized_teams + json.extract! tournament, :id, :name, :game_id, :status, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams json.url tournament_url(tournament, format: :json) end diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb index df85dcf..b771701 100644 --- a/app/views/tournaments/show.html.erb +++ b/app/views/tournaments/show.html.erb @@ -3,7 +3,7 @@ </h2> <div class="progress"> - <%= tag("div", {:class => "progress-bar progress-bar-warning", :style => "width: " +(@tournament.players.count * 100 / (@tournament.min_players_per_team * @tournament.min_teams_per_match)).to_s + "%", "aria-valuemax" => "100", "aria-valuemin" => "0", "aria-valuenow" => (@tournament.players.count * 100 / (@tournament.min_players_per_team * @tournament.min_teams_per_match)).to_s, "role" => "progressbar"}) %> + <%= tag("div", {:id => "prog-bar", :class => "progress-bar progress-bar-warning", :style => "width: " +(@tournament.players.count * 100 / (@tournament.min_players_per_team * @tournament.min_teams_per_match)).to_s + "%", "aria-valuemax" => "100", "aria-valuemin" => "0", "aria-valuenow" => (@tournament.players.count * 100 / (@tournament.min_players_per_team * @tournament.min_teams_per_match)).to_s, "role" => "progressbar"}) %> <span class="sr-only">60% Complete (warning)</span> </div> </div> @@ -11,45 +11,70 @@ <span id="tournament-side-params"> +<p> + <strong>Status:</strong> + <% if @tournament.status == 0 %> + Waiting for players... + <% else %> + Started + <% end %> +</p> + +<p> + <strong>Min players per team:</strong> + <%= @tournament.min_players_per_team %> +</p> + +<p> + <strong>Max players per team:</strong> + <%= @tournament.max_players_per_team %> +</p> + +<p> + <strong>Min teams per match:</strong> + <%= @tournament.min_teams_per_match %> +</p> + +<p> + <strong>Max teams per match:</strong> + <%= @tournament.max_teams_per_match %> +</p> + +<p> + <strong>Set rounds:</strong> + <%= @tournament.set_rounds %> +</p> + +<p> + <strong>Min players per team:</strong> + <%= @tournament.min_players_per_team %> +</p> + +<p> + <strong>Max players per team:</strong> + <%= @tournament.max_players_per_team %> +</p> + +<p> + <strong>Min teams per match:</strong> + <%= @tournament.min_teams_per_match %> +</p> + +<p> + <strong>Max teams per match:</strong> + <%= @tournament.max_teams_per_match %> +</p> + +<p> + <strong>Set rounds:</strong> + <%= @tournament.set_rounds %> +</p> + +<p> + <strong>Randomized teams:</strong> + <%= @tournament.randomized_teams %> +</p> - <p> - <strong>Status:</strong> - <% if @tournament.status == 0 %> - Waiting for players... - <% else %> - Started - <% end %> - </p> - - <p> - <strong>Min players per team:</strong> - <%= @tournament.min_players_per_team %> - </p> - - <p> - <strong>Max players per team:</strong> - <%= @tournament.max_players_per_team %> - </p> - - <p> - <strong>Min teams per match:</strong> - <%= @tournament.min_teams_per_match %> - </p> - - <p> - <strong>Max teams per match:</strong> - <%= @tournament.max_teams_per_match %> - </p> - - <p> - <strong>Set rounds:</strong> - <%= @tournament.set_rounds %> - </p> - - <p> - <strong>Randomized teams:</strong> - <%= @tournament.randomized_teams %> - </p> </span> <div > @@ -65,6 +90,7 @@ <h3 div="players-needed">Hmmm.... nobody's here yet! You and your friends should join the tournament.</h3> <% end %> +<div class="leave-buttons"> <%# If user can join, and user hasn't joined already, show the join tournment tag %> <% if @tournament.joinable_by?(current_user) && !@tournament.players.include?(current_user) %> <%= form_tag(tournament_path(@tournament), method: "put") do %> @@ -94,8 +120,29 @@ <%= link_to 'Back', tournaments_path %> | <%= link_to 'Cancel Tournament', @tournament, method: :delete, data: { confirm: 'Are you sure?' } %> <% end %> - +</div> <%end %> </div> +<script> +function donehandle( tournament ) { + if ( console && console.log ) { + var here = tournament["players"].length; + var needed = (tournament["min_teams_per_match"] * tournament["min_players_per_team"]); + var pct_complete = here / needed; + $("#prog-bar").width( (pct_complete * 100) +"%"); + $("#players-needed").text(here + " " + (here==1?"player has":"players have") + " signed up. " + needed + " players needed. "); + players = ""; + for (var i = 0; i < tournament["players"].length; i++) { + players = players+"<li><span class=\"black\">"+tournament["players"][i]["user_name"]+"</span></li>" + } + $("#tournament-users").html(players); + + } + setTimeout(function(){$.ajax({url: "<%= url_for @tournament %>.json"}).done(donehandle)}, 3000); +} + +$.ajax({url: "<%= url_for @tournament %>.json"}) + .done(donehandle); +</script> diff --git a/app/views/tournaments/show.json.jbuilder b/app/views/tournaments/show.json.jbuilder index d543c76..27fd5c0 100644 --- a/app/views/tournaments/show.json.jbuilder +++ b/app/views/tournaments/show.json.jbuilder @@ -1 +1 @@ -json.extract! @tournament, :id, :name, :game_id, :status, :randomized_teams, :created_at, :updated_at +json.extract! @tournament, :id, :name, :game_id, :status, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :created_at, :updated_at |