1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-24 17:04:43 +00:00
Files
wrestlingdev.com/app/views/tournaments/all_brackets.html.erb

76 lines
2.3 KiB
Plaintext

<style>
@page {
size: 8.5in 11in;
margin: 0.5in;
}
.page {
width: 7.5in;
height: 10in;
margin: auto;
overflow: hidden;
position: relative;
}
.page-landscape {
height: 7.5in;
width: 10in;
margin: auto;
overflow: hidden;
position: relative;
}
.bracket-container {
width: 100%;
height: auto;
transform-origin: top left;
}
@media print {
.page {
page-break-after: always;
}
.page-landscape {
page-break-after: always;
}
}
</style>
<script>
window.onload = function () {
document.querySelectorAll('.page').forEach(page => {
const container = page.querySelector('.bracket-container');
const isLandscape = page.classList.contains('landscape');
const availableWidth = isLandscape ? 10 * 96 : 7.5 * 96; // Convert inches to px
const availableHeight = isLandscape ? 7.5 * 96 : 10 * 96;
const scaleX = availableWidth / container.scrollWidth;
const scaleY = availableHeight / container.scrollHeight;
const scale = Math.min(scaleX, scaleY); // Choose the smaller scale to fit
container.style.transform = `scale(${scale})`;
});
};
</script>
<% cache ["#{@tournament.id}_all_brackets", @tournament] do %>
<div class="page">
<div class="bracket-container">
<%= render :template => 'tournaments/team_scores' %>
</div>
</div>
<% @weights.sort_by{|w| w.max}.each do |weight| %>
<% if @tournament.tournament_type == "Pool to bracket" %>
<!-- Need to define what the tournaments#bracket controller defines -->
<% @matches = @tournament.matches.select{|m| m.weight_id == weight.id} %>
<% @wrestlers = Wrestler.where(weight_id: weight.id) %>
<% @pools = weight.pool_rounds(@matches) %>
<% @weight = weight %>
<%= render 'bracket_partial' %>
<% elsif @tournament.tournament_type.include? "Modified 16 Man Double Elimination" or @tournament.tournament_type.include? "Regular Double Elimination" %>
<!-- Need to define what the tournaments#bracket controller defines -->
<% @matches = weight.matches %>
<% @weight = weight %>
<%= render 'bracket_partial' %>
<% end %>
<% end %>
<% end %>