@section('page_title')
OSAA - Upload Stats File
@stop
@section('page_sub_title')
Upload Stats File to Bracket
@stop
@section('scripts')
@parent
@stop
@section('jquery_init')
$('.button').button();
// Success bar
$('.success_bar').animate({ 'top' : 32, 'background-color' : 'rgba(176, 255, 190, 1.0)'}, 1600, 'easeOutQuad', function ()
{
$(this).delay(6000).fadeOut(4000);
$(this).hover(function ()
{
$(this).stop(true).css('opacity', '1.0');
},
function ()
{
$(this).fadeOut(4000);
})
});
var divisions = {{ json_encode($info['activity_divisions']) }};
$('#activity').change(function()
{
// Get the selected activity
var select = $(this);
var activity = $('option:selected', select).val();
// Get this newly selected activity's divisions
var options = divisions[activity];
// Get the division select
var div_select = $('select[name="division"]');
// Clear out all options
$('option', div_select).remove();
// Add options from the new list of divisions
$.each(options, function(value, text)
{
$('')
.attr('value', value)
.html(text)
.appendTo(div_select);
});
div_select.focus();
updateMatchups();
});
$('#division').change(function ()
{
updateMatchups();
});
function updateMatchups()
{
var list = $('#matchup');
var activity = $('#activity option:selected').val();
var division = $('#division option:selected').val();
var frame = $('#bracket');
frame.attr('src', 'http://www.osaa.org/activities/' + activity.toLowerCase() + '/brackets?div=' + division);
frame.load(function ()
{
frame.contents().find('#navigation, #masthead, #live_alert_2, .ad, #next_to_leaderboard, #osaa_websites, #footer, #championships, .header, .sub_menu_header, .division_select, .bracket_actions').remove();
frame.contents().find('#full_page_content').css('width', '');
frame.contents().find('.holder').css('width', 'auto');
frame.contents().find('.main_content').css('width', '');
frame.contents().find('.bracket').css({'width':'', 'padding':'0'});
});
// Get a list of JSON matchups
var data = {activity : activity,
division : division};
var matchup_objects;
var jqxhr = $.ajax(
{
type : 'GET',
url : '{{ url('stats/matchups') }}',
data : data,
dataType : 'html'
})
.done(function (returned_data)
{
matchup_objects = $.parseJSON(returned_data);
})
.fail(function (jqXHR, status, error)
{
var response = jqXHR.responseText;
var errorData = $.parseJSON(response);
alert ("There was an error.\n\n" + errorData.error.message + "\n\nPlease try again.");
})
.complete(function ()
{
// Only show results if there is at least one matchup
if (matchup_objects[0] >= 1)
{
// Get the list
var list = $('#matchup');
// Remove all options
$('option', list).remove();
// Add an option for each matchup object
$.each(matchup_objects, function(index, object)
{
// Skip the first element because it's the number of matchups returned
if (index == 0)
{
return;
}
var home = object.contest.home_team_name;
if (!home)
{
home = 'TBD';
}
var away = object.contest.away_team_name;
if (!away)
{
away = 'TBD';
}
var time = object.show_time;
var text = away + ' vs. ' + home + ', ' + time;
list.append($('