From 0ea678daa091529750cbc9786734db8e1d165bd2 Mon Sep 17 00:00:00 2001 From: tkimia Date: Mon, 7 Apr 2014 11:25:24 -0400 Subject: ajax support in match show --- app/views/matches/index.html.erb | 9 +++++---- 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 %> - + - + + <% (1..@matches.count).each do |i| %> /> - " stroke="black" /> + " /> <% if @matches[i-1].teams.first %> Team <%= @matches[i-1].teams.first.id %> @@ -88,7 +89,7 @@ VS - " stroke="black" /> + " /> <% 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 @@

Status: - <%= @match.status %> + <%= @match.status %>

Tournament: @@ -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); -- cgit v1.2.3-54-g00ecf