diff options
author | tkimia <tkimia@purdue.edu> | 2014-04-07 11:25:24 -0400 |
---|---|---|
committer | tkimia <tkimia@purdue.edu> | 2014-04-07 11:25:24 -0400 |
commit | 0ea678daa091529750cbc9786734db8e1d165bd2 (patch) | |
tree | 3b454eb1f2c051d219fa0f1bbf801b84cf48fa2e /app | |
parent | c8b4045ba1ca02e750d6e8b15a1ced47b1930217 (diff) |
ajax support in match show
Diffstat (limited to 'app')
-rw-r--r-- | app/views/matches/index.html.erb | 9 | ||||
-rw-r--r-- | app/views/matches/show.html.erb | 17 |
2 files changed, 21 insertions, 5 deletions
diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 15b59f4..08d5fd6 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -43,10 +43,10 @@ lastrh = 0 lastrw = 0 %> <defs> - <radialGradient id="gradMatch" cx="50%" cy="50%" r="50%" fx="50%" fy="50%"> + <radialGradient id="gradMatch" cx="50%" cy="50%" r="80%" fx="80%" fy="80%"> <stop offset="0%" style="stop-color:#ffd281; stop-opacity:0" /> - <stop offset="100%" style="stop-color:#EEA236;stop-opacity:1" /> + <stop offset="100%" style="stop-color:#ccc;stop-opacity:1" /> </radialGradient> </defs> <script type="text/ecmascript"><![CDATA[ @@ -55,6 +55,7 @@ } ]]> </script> + <% (1..@matches.count).each do |i| %> <g id="svg-match-<%= i %>" onclick="redirect(<%= @matches[i-1].id %>)" cursor="pointer"> <rect height="<%= rh = 100/(2**(@depth-1)+1) - 5 %>%" @@ -80,7 +81,7 @@ stroke="grey" <% end %> /> - <rect width="<%= rw-5 %>%" height="<%= rh/4 %>%" x="<%= rx + 2.5 %>%" y="<%= ry + rh/6 %>%" fill="<%= @matches[i-1].teams.first and @matches[i-1].teams.first.users.include?(current_user) ? "#BCED91" : "white" %>" stroke="black" /> + <rect width="<%= rw-5 %>%" height="<%= rh/4 %>%" x="<%= rx + 2.5 %>%" y="<%= ry + rh/6 %>%" fill="<%= @matches[i-1].teams.first and @matches[i-1].teams.first.users.include?(current_user) ? "#BCED91" : "white" %>" /> <text x="<%= rx + rw/4 %>%" y="<%= ry + rh/3 %>%" font-size="<%= rh %>"> <% if @matches[i-1].teams.first %> Team <%= @matches[i-1].teams.first.id %> @@ -88,7 +89,7 @@ </text> <text x="<%= rx + 1.3*rw/3 %>%" y="<%= ry + 5.2*rh/9 %>%" font-size="<%= rh %>"> VS </text> - <rect width="<%= rw-5 %>%" height="<%= rh/4 %>%" x="<%= rx + 2.5 %>%" y="<%= ry + 3*rh/5 %>%" fill="<%= @matches[i-1].teams[1] and @matches[i-1].teams[1].users.include?(current_user) ? "#BCED91" : "white" %>" stroke="black" /> + <rect width="<%= rw-5 %>%" height="<%= rh/4 %>%" x="<%= rx + 2.5 %>%" y="<%= ry + 3*rh/5 %>%" fill="<%= @matches[i-1].teams[1] and @matches[i-1].teams[1].users.include?(current_user) ? "#BCED91" : "white" %>" /> <text x="<%= rx + rw/4 %>%" y="<%= ry + 4*rh/5 %>%" font-size="<%= rh %>"> <% if @matches[i-1].teams[1] %> Team <%= @matches[i-1].teams[1].id %> diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb index c92aea3..6be3481 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -1,6 +1,6 @@ <p> <strong>Status:</strong> - <%= @match.status %> + <span id="current-id"> <%= @match.status %></span> </p> <p> <strong>Tournament:</strong> @@ -127,4 +127,19 @@ function score_peers() { $('review_action').value += $('ol#boxes:eq(' + i + ')').text() + comma; } } + + +function donehandle( match ) { + if ( console && console.log ) { + } + + //if match has moved on in status, reload the page. + if (parseInt($("#current-id").text()) != match["status"]) + window.location.reload(true); + + setTimeout(function(){$.ajax({url: "<%= request.original_url %>.json"}).done(donehandle)}, 2000); +} + +$.ajax({url: "<%= request.original_url %>.json"}) + .done(donehandle); </script> |