mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
272 lines
11 KiB
Plaintext
272 lines
11 KiB
Plaintext
<%= form_for(@match) do |f| %>
|
|
<% if @match.errors.any? %>
|
|
<div id="error_explanation">
|
|
<h2><%= pluralize(@match.errors.count, "error") %> prohibited this match from being saved:</h2>
|
|
|
|
<ul>
|
|
<% @match.errors.full_messages.each do |msg| %>
|
|
<li><%= msg %></li>
|
|
<% end %>
|
|
</ul>
|
|
</div>
|
|
<% end %>
|
|
<h4>Bout <strong><%= @match.bout_number %></strong></h4>
|
|
<h4>Bracket Position: <strong><%= @match.bracket_position %></strong></h4>
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>Name: <%= @wrestler1_name %> <select id="w1-color" onchange="changeW1Color(this)">
|
|
<option value="green">Green</option>
|
|
<option value="red">Red</option>
|
|
</select>
|
|
<br>School: <%= @wrestler1_school_name %>
|
|
<br>Last Match: <%= @wrestler1_last_match ? time_ago_in_words(@wrestler1_last_match.updated_at) : "N/A" %></th>
|
|
<th>Name: <%= @wrestler2_name %> <select id="w2-color" onchange="changeW2Color(this)">
|
|
<option value="red">Red</option>
|
|
<option value="green">Green</option>
|
|
</select>
|
|
<br>School: <%= @wrestler2_school_name %>
|
|
<br>Last Match: <%= @wrestler2_last_match ? time_ago_in_words(@wrestler2_last_match.updated_at) : "N/A" %></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td><%= @wrestler1_name %> Stats: <br><%= f.text_area :w1_stat, cols: "30", rows: "10" %></td>
|
|
<td><%= @wrestler2_name %> Stats: <br><%= f.text_area :w2_stat, cols: "30", rows: "10" %></td>
|
|
</tr>
|
|
<tr>
|
|
<td><%= @wrestler1_name %> Scoring <br><button id="w1-takedown" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'T2')">T2</button>
|
|
<button id="w1-escape" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'E1')">E1</button>
|
|
<button id="w1-reversal" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'R2')">R2</button>
|
|
<button id="w1-nf2" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'N2')">N2 </button>
|
|
<button id="w1-nf3" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'N3')">N3</button>
|
|
<button id="w1-nf4" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'N4')">N4</button>
|
|
<button id="w1-penalty" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'P1')">P1</button>
|
|
<button id="w1-penalty2" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'P2')">P2</button></td>
|
|
<td><%= @wrestler2_name %> Scoring <br><button id="w2-takedown" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'T2')">T2</button>
|
|
<button id="w2-escape" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'E1')">E1</button>
|
|
<button id="w2-reversal" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'R2')">R2</button>
|
|
<button id="w2-nf2" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'N2')">N2</button>
|
|
<button id="w2-nf3" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'N3')">N3</button>
|
|
<button id="w2-nf4" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'N4')">N4</button>
|
|
<button id="w2-penalty" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'P1')">P1</button>
|
|
<button id="w2-penalty2" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'P2')">P2</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td><%= @wrestler1_name %> Choice <br><button id="w1-top" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'|Chose Top|')">Chose Top</button>
|
|
<button id="w1-bottom" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'|Chose Bottom|')">Chose Bottom</button>
|
|
<button id="w1-nuetral" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'|Chose Nuetral|')">Chose Nuetral</button>
|
|
<button id="w1-defer" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'|Deferred|')">Deferred</button></td>
|
|
<td><%= @wrestler2_name %> Choice <br><button id="w2-top" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'|Chose Top|')">Chose Top</button>
|
|
<button id="w2-bottom" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'|Chose Bottom|')">Chose Bottom</button>
|
|
<button id="w2-nuetral" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'|Chose Nuetral|')">Chose Nuetral</button>
|
|
<button id="w2-defer" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'|Deferred|')">Deferred</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td><%= @wrestler1_name %> Warnings <br><button id="w1-stalling" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'S')">Stalling</button>
|
|
<button id="w1-caution" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'C')">Caution</button></td>
|
|
<td><%= @wrestler2_name %> Warnings <br><button id="w2-stalling" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'S')">Stalling</button>
|
|
<button id="w2-caution" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'C')">Caution</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Match Options <br><button type="button" class="btn btn-primary btn-sm" onclick="updateStats(w2,'|End Period|');updateStats(w1,'|End Period|')">End Period</button></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<br>
|
|
<br>
|
|
<br>
|
|
<h4>Match Results</h4>
|
|
<br>
|
|
<div class="field">
|
|
<%= f.label "Win Type" %><br>
|
|
<%= f.select(:win_type, Match::WIN_TYPES) %>
|
|
</div>
|
|
<br>
|
|
<div class="field">
|
|
<%= f.label "Overtime Type" %> Leave blank if not overtime. For High School the 1st overtime is SV-1, second overtime is TB-1, third overtime is UTB.<br>
|
|
<%= f.select(:overtime_type, Match::OVERTIME_TYPES) %>
|
|
</div>
|
|
<br>
|
|
<div class="field">
|
|
<%= f.label "Winner" %> Please choose the winner<br>
|
|
<%= f.collection_select :winner_id, @wrestlers, :id, :name, include_blank: true %>
|
|
</div>
|
|
<br>
|
|
<div class="field">
|
|
<%= f.label "Final Score" %> For decision, major, or tech fall put the score here in Number-Number format. If pin, put the accumulated pin time in the format MM:SS. If default, injury default, dq, bye, or forfeit, leave blank. Examples: 7-2, 17-2, 0:30, or 2:34.<br>
|
|
<%= f.text_field :score %>
|
|
</div>
|
|
<br>
|
|
|
|
<%= f.hidden_field :finished, :value => 1 %>
|
|
<%= f.hidden_field :round, :value => @match.round %>
|
|
|
|
<br>
|
|
|
|
<div class="actions">
|
|
<%= f.submit onclick: "return confirm('Is the name of the winner ' + document.getElementById('match_winner_id').options[document.getElementById('match_winner_id').selectedIndex].text + '?')", :class=>"btn btn-success" %>
|
|
|
|
</div>
|
|
<% end %>
|
|
|
|
<script>
|
|
// Localstorage
|
|
// https://stackoverflow.com/questions/12806198/how-do-i-save-data-on-localstorage-in-ruby-on-rails-3-2-8
|
|
|
|
//Create person object
|
|
function Person(stats){
|
|
this.stats=stats;
|
|
}
|
|
|
|
//Declare variables
|
|
var w1=new Person("");
|
|
var w2=new Person("");
|
|
updatejsvalues();
|
|
|
|
// Get variables
|
|
var tournament=<%= @match.tournament.id %>;
|
|
var bout=<%= @match.bout_number %>;
|
|
|
|
// if localstorage tournament id and bout number are the same and the html stat values are blank
|
|
// if the html stat values are not blank we want to honor what came from the db
|
|
if (localStorage.getItem('wrestler1') && localStorage.tournament == tournament && localStorage.bout == bout && document.getElementById("match_w1_stat").value == "" && document.getElementById("match_w2_stat").value == "") {
|
|
w1.stats = localStorage.getItem('wrestler1');
|
|
w2.stats = localStorage.getItem('wrestler2');
|
|
updatehtmlvalues();
|
|
} else {
|
|
updateLocalStorage();
|
|
}
|
|
|
|
|
|
function updatehtmlvalues(){
|
|
document.getElementById("match_w1_stat").value = w1.stats;
|
|
document.getElementById("match_w2_stat").value = w2.stats;
|
|
}
|
|
|
|
function updatejsvalues(){
|
|
w1.stats=document.getElementById("match_w1_stat").value;
|
|
w2.stats=document.getElementById("match_w2_stat").value;
|
|
}
|
|
|
|
function takedown(wrestler){
|
|
updateStats(wrestler,"T2")
|
|
}
|
|
|
|
function updateStats(wrestler,text){
|
|
updatejsvalues();
|
|
wrestler.stats = wrestler.stats + text + " ";
|
|
updatehtmlvalues();
|
|
updateLocalStorage();
|
|
}
|
|
|
|
function updateLocalStorage(){
|
|
localStorage.setItem("wrestler1",w1.stats);
|
|
localStorage.setItem("wrestler2",w2.stats);
|
|
localStorage.setItem("bout", bout);
|
|
localStorage.setItem("tournament", tournament);
|
|
}
|
|
|
|
//For Changing button colors
|
|
function changeW1Color(color){
|
|
if (color.value == "red") {
|
|
w1Red();
|
|
w2Green();
|
|
document.getElementById("w2-color").value = "green";
|
|
}
|
|
if (color.value == "green") {
|
|
w1Green();
|
|
w2Red();
|
|
document.getElementById("w2-color").value = "red";
|
|
}
|
|
}
|
|
|
|
function changeW2Color(color){
|
|
if (color.value == "red") {
|
|
w2Red();
|
|
w1Green();
|
|
document.getElementById("w1-color").value = "green";
|
|
}
|
|
if (color.value == "green") {
|
|
w2Green();
|
|
w1Red();
|
|
document.getElementById("w1-color").value = "red";
|
|
}
|
|
}
|
|
|
|
function redColor(id){
|
|
document.getElementById(id).className = "btn btn-danger btn-sm";
|
|
}
|
|
|
|
function greenColor(id){
|
|
document.getElementById(id).className = "btn btn-success btn-sm";
|
|
}
|
|
|
|
function w1Red(){
|
|
redColor("w1-takedown");
|
|
redColor("w1-escape");
|
|
redColor("w1-reversal");
|
|
redColor("w1-penalty");
|
|
redColor("w1-penalty2");
|
|
redColor("w1-nf4");
|
|
redColor("w1-nf3");
|
|
redColor("w1-nf2");
|
|
redColor("w1-top");
|
|
redColor("w1-bottom");
|
|
redColor("w1-nuetral");
|
|
redColor("w1-defer");
|
|
redColor("w1-stalling");
|
|
redColor("w1-caution");
|
|
}
|
|
|
|
function w1Green(){
|
|
greenColor("w1-takedown");
|
|
greenColor("w1-escape");
|
|
greenColor("w1-reversal");
|
|
greenColor("w1-penalty");
|
|
greenColor("w1-penalty2");
|
|
greenColor("w1-nf4");
|
|
greenColor("w1-nf3");
|
|
greenColor("w1-nf2");
|
|
greenColor("w1-top");
|
|
greenColor("w1-bottom");
|
|
greenColor("w1-nuetral");
|
|
greenColor("w1-defer");
|
|
greenColor("w1-stalling");
|
|
greenColor("w1-caution");
|
|
}
|
|
|
|
function w2Red(){
|
|
redColor("w2-takedown");
|
|
redColor("w2-escape");
|
|
redColor("w2-reversal");
|
|
redColor("w2-penalty");
|
|
redColor("w2-penalty2");
|
|
redColor("w2-nf4");
|
|
redColor("w2-nf3");
|
|
redColor("w2-nf2");
|
|
redColor("w2-top");
|
|
redColor("w2-bottom");
|
|
redColor("w2-nuetral");
|
|
redColor("w2-defer");
|
|
redColor("w2-stalling");
|
|
redColor("w2-caution");
|
|
}
|
|
|
|
function w2Green(){
|
|
greenColor("w2-takedown");
|
|
greenColor("w2-escape");
|
|
greenColor("w2-reversal");
|
|
greenColor("w2-penalty");
|
|
greenColor("w2-penalty2");
|
|
greenColor("w2-nf4");
|
|
greenColor("w2-nf3");
|
|
greenColor("w2-nf2");
|
|
greenColor("w2-top");
|
|
greenColor("w2-bottom");
|
|
greenColor("w2-nuetral");
|
|
greenColor("w2-defer");
|
|
greenColor("w2-stalling");
|
|
greenColor("w2-caution");
|
|
}
|
|
</script> |