/**/
if (!Array.prototype.filter)
{
Array.prototype.filter = function(fun /*, thisp */)
{
"use strict";
if (this === void 0 || this === null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function")
throw new TypeError();
var res = [];
var thisp = arguments[1];
for (var i = 0; i < len; i++)
{
if (i in t)
{
var val = t[i]; // in case fun mutates this
if (fun.call(thisp, val, i, t))
res.push(val);
}
}
return res;
};
}
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
"use strict";
if (this == null) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (len === 0) {
return -1;
}
var n = 0;
if (arguments.length > 0) {
n = Number(arguments[1]);
if (n != n) { // shortcut for verifying if it's NaN
n = 0;
} else if (n != 0 && n != Infinity && n != -Infinity) {
n = (n > 0 || -1) * Math.floor(Math.abs(n));
}
}
if (n >= len) {
return -1;
}
var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
for (; k < len; k++) {
if (k in t && t[k] === searchElement) {
return k;
}
}
return -1;
}
}
function addGroupstageHTML(length)
{
$('
\
Stage name
\
\
\
GSL group \
Match format: Not all the same \
Scoring scheme: \
\
\
\
First 2 matches: \
Winner vs Winner: \
Loser vs Loser: \
2nd place decider: \
Iterations \
').appendTo($("#tabs"));
}
function addPlayoffsHTML(length)
{
$('
Stage name
').appendTo($("#tabs"));
}
function createGroup(x,y,groupname, element)
{
var group = $('
Group ' + groupname + '
')
.appendTo(element)
.offset({left:x, top:y});
return group;
}
function addTeamToGroup(groupname, teamname, rank, score, points, qualifiedrule, isteamlocked)
{
var teamcolor = isteamlocked?('style="background-color:'+ qualifiedrule+'"'):'';
var team = $('
' +rank + '
'+teamname+'
'+ score+'
'+points+'pts
')
.appendTo('#grouptable'+groupname);
return team;
}
function renderGroups(groupstage, teamscores, element)
{
for(var i=0;i0)
{
tabx= $("#tabs").position().left+1;
taby= $("#tabs").position().top+1
}
var line = $('
')
.addClass('line')
.addClass(lineclass)
.css({
'position': 'absolute',
'transform': transform
})
.width(length)
.offset({left: x1+tabx, top: y1+taby});
if ( $.browser.mozilla == true && angle<0) { //Fix for firefox transform-origin being all weird.
line.css('transform-origin','-'+ (width/2+1) + 'px ' + '-' + (width/2+1) + 'px')
}
line.appendTo(element);
return line;
}
function createVerticalLine(x1,y1, x2,y2, lineclass, element){
var tabx=0;
var taby=0;
if($("#tabs").length>0)
{
tabx= $("#tabs").position().left+1;
taby= $("#tabs").position().top+1
}
var line = $('
')
.appendTo(object.parent())
.offset({left:object.parent().position().left,top:object.parent().position().top-40});
}
function setBoChoice(owner, t)
{
$(".botable").remove();
$(owner).text($(t).text());
}
function addTeamToPool(team, myclass)
{
var ans = $('
' ).appendTo( match );
rgTeamPlace[team2id] = null;
}
}
}
return match;
}
function highlightOnHover()
{
var teamclass = $(this).attr("class").split(" ").filter(function(value){return value.indexOf("team-")>=0});
if(teamclass=="team-")
return;
$("."+teamclass).addClass("matchhover");
$(".line"+teamclass).css("height","1px");
$(".verline"+teamclass).css("width","1px");
$(".line"+teamclass).addClass("linehover");
$(".verline"+teamclass).addClass("linehover");
$( ".PrizePoolPayout-"+teamclass ).show();
}
function highlightOnHoverOut()
{
var teamclass = $(this).attr("class").split(" ").filter(function(value){return value.indexOf("team-")>=0});
if(teamclass=="team-")
return;
$("."+teamclass).removeClass("matchhover");
$(".line"+teamclass).css("height","1px");
$(".line"+teamclass).removeClass("linehover");
$(".verline"+teamclass).css("width","1px");
$(".verline"+teamclass).removeClass("linehover");
$( ".PrizePoolPayout-"+teamclass ).hide();
}
function createSchedule(x,y, id, element)
{
var schedule = $('
')
.appendTo(element)
.offset({left:x, top:y});
return schedule;
}
function addDayToSchedule(scheduleid,day)
{
var d = new Date(day);
var daycolumn = $('
'+ d.toLocaleDateString()+'
')
.appendTo('#schedule'+scheduleid+' .scheduledayrow');
return daycolumn;
}
function addMatchToDaySchedule(scheduleid, matchid, time, team1, team2, score1, score2, bo)
{
if (score1 > bo/2)
score1 = "" +score1 + "";
if (score2 > bo/2)
score2 = "" +score2 + "";
var d = new Date(time);
var matchline = $('
'+ d.toLocaleTimeString() +'
'+ team1 +'
' +
'
'+ score1 + ':' + score2 + '
'+ team2 + '
')
.appendTo('#schedule' +scheduleid);
matchline.hide();
return matchline;
}
function addGameToMatch(scheduleid, matchid, gamenumber, score1, score2, winner, heroes1, heroes2)
{
var game = '
Game '+ gamenumber +'
';
for (var i=0;i';
}
game+='
'+score1+'-'+score2+'
';
for (var i=0;i';
}
game+='
';
game = $(game).appendTo("#match"+matchid);
game.hide();
return game;
}
var rgPlacePercentages = [];
var rgPlaces = [];
var rgTeamPlace = [];
function drawBracket(bracket, depth, maxdepth, yoffset, element)
{
rgPlacePercentages = [ 0.44, 0.165, 0.105, 0.07, 0.045, 0.025, 0.015, 0.005 ];
rgPlaces = [ rgLocalizedStrings['Winner'], rgLocalizedStrings['TI6_RunnerUp'], '3rd', '4th', '5th/6th', '7th/8th', '9th-12th', '13th-16th' ];
rgTeamPlace = [];
var topBracket = 99999;
var leftBracket = 99999;
var rightBracket = 0;
var botBracket = 0;
var bestOfData = [];
var bestOfData = [];
var bestOftracker = 0;
var rgLetters = [ 'D', 'C', 'B', 'A', 'F', 'E', 'G' ];
var unWhichLetter = 6;
var rgChildMatchIDs = [];
var unBottomBOOffset = 0;
if( maxdepth > 3 )
{
unBottomBOOffset = 32;
}
//Draw from right to left
for (var i=0; i<=maxdepth; i++)
{
for (var j=0; j rightBracket )
{
rightBracket = depth[i][j]["left"];
}
depth[i][j]["top"] = 30+ 90 * findHigherLeaves(depth[i][j],bracket)+200*depth[i][j]['order'];
if( depth[i][j]["top"] < topBracket )
{
topBracket = depth[i][j]["top"];
}
if( depth[i][j]["top"] > botBracket )
{
botBracket = depth[i][j]["top"];
}
var strMatchText = "";
if( rgChildMatchIDs[parseInt( unCurMatchID )] && depth.length > 3 )
{
bIsChildMatch = true;
strMatchText = rgChildMatchIDs[parseInt( unCurMatchID )]['which_match'];
}
var curMatch = createMatch(depth[i][j]["left"],depth[i][j]["top"]+yoffset*500,depth[i][j]["team1"],depth[i][j]["team2"],depth[i][j]["score1"],depth[i][j]["score2"],depth[i][j]["bo"],depth[i][j]["round"], "",element,'',true, depth[i][j]["team1id"], depth[i][j]["team2id"], bIsChildMatch, strMatchText).attr("id","match"+depth[i][j]["id"], element );
if( bIsParentMatch && depth.length > 3 )
{
$( '