From bc8be5e217279012cd4dc62e3fc2fe2bd9308b1c Mon Sep 17 00:00:00 2001 From: tkimia Date: Mon, 28 Apr 2014 22:01:00 -0400 Subject: bracket update works --- app/views/brackets/show.html.erb | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'app/views/brackets/show.html.erb') diff --git a/app/views/brackets/show.html.erb b/app/views/brackets/show.html.erb index 64e6e6a..a3eb000 100644 --- a/app/views/brackets/show.html.erb +++ b/app/views/brackets/show.html.erb @@ -21,30 +21,30 @@ %> function chooseWinner(matchNum, teamNum, currentBox){ console.log(matchNum, teamNum); - $id = '#match-'+matchNum+'-pred'; - $($id).val(teamNum); + var id = '#bracket_matches_'+matchNum; + $(id).val(teamNum); if (matchNum != 1) { - $parent = parseFloat(matchNum+<%= @logBase%> -2)/<%=@logBase%>; - $textBox = ($parent - Math.floor($parent)) * <%= @logBase %>; - $parent = Math.floor($parent); - $textBox = Math.round($textBox); - $id = "#svg-match-"+$parent+"-team-"+$textBox; + var parent = parseFloat(matchNum+<%= @logBase%> -2)/<%=@logBase%>; + var textBox = (parent - Math.floor(parent)) * <%= @logBase %>; + var parent = Math.floor(parent); + var textBox = Math.round(textBox); + var id = "#svg-match-"+parent+"-team-"+textBox; - console.log($id); + console.log(id); - $($id).text("Team "+teamNum); - $($id).attr("onclick", "chooseWinner("+$parent+", "+teamNum+", "+$textBox+")"); + $(id).text("Team "+teamNum); + $(id).attr("onclick", "chooseWinner("+parent+", "+teamNum+", "+textBox+")"); } else { console.log("final countdown"); for(var i = 0; i < 3; i++){ - $id = "#svg-match-"+matchNum+"-team-"+i; - $($id).attr("fill", "black"); + id = "#svg-match-"+matchNum+"-team-"+i; + $(id).attr("fill", "black"); } - $id = "#svg-match-"+matchNum+"-team-"+currentBox; - $($id).attr("fill", "green"); + id = "#svg-match-"+matchNum+"-team-"+currentBox; + $(id).attr("fill", "green"); $("#bracket-submit").prop('disabled', false); } } @@ -100,9 +100,9 @@ <%= form_tag(tournament_bracket_path(@tournament, @bracket), method: 'put') do %> <% for i in 1..@matches.length %> - <%= hidden_field_tag('match-'+@matches[i].id.to_s+'-pred', value = nil) %> + <%= hidden_field_tag("bracket[matches][#{@matches[i].id.to_s}]", value = nil) %> <% end %> - <%= submit_tag("Sumit Prediction", disabled: true, id: "bracket-submit") %> + <%= submit_tag("Submit Prediction", disabled: true, id: "bracket-submit") %> <% end %> <%= link_to 'Back', tournaments_path %> -- cgit v1.2.3