/**/ 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: \ \
\
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 = $('
') .addClass('line') .addClass(lineclass) .css({ 'position': 'absolute', 'width': '1px' }) .height(Math.ceil( Math.abs(y1-y2) ) + 1) .offset({left: x1+tabx, top: Math.min(y1,y2)+taby}); line.appendTo(element); return line; } function popupBoChoice(object) { var bochoice = $('
bo1bo3bo5bo7
') .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 = $('
  • '+ team + '
  • ').appendTo("#teampoolcontainer .teampool"); $(".competingteam").draggable({revert:true}); return ans; } function connectMatch(match1, match2, winner,team, element,drawing) { var offset=0; if(team==1) offset=-15; if(team==2) offset=15; var xOffset = 0; var yOffset=0; if (drawing) { xOffset=-10; yOffset=-100; } if(winner!=undefined) winner= winner.replace(/\W/g, ''); createLine(match1.position()['left']+115+xOffset,match1.position()['top']+27+yOffset,match1.position()['left']+135+xOffset,match1.position()['top']+27+yOffset,"lineteam-"+winner, element); createVerticalLine(match1.position()['left']+135+xOffset,match1.position()['top']+27+yOffset,match1.position()['left']+135,match2.position()['top']+27+offset+yOffset,"verlineteam-"+winner, element); createLine(match1.position()['left']+135+xOffset,match2.position()['top']+27+yOffset+offset,match2.position()['left']-0+xOffset, match2.position()['top']+27+offset+yOffset,"lineteam-"+winner, element); } function createMatch(x,y, team1, team2, score1, score2, bo, round, id, element, image, short, team1id, team2id, bIsChildMatch, strMatchText) { if (team1==undefined) team1=" "; if (team2==undefined) team2=" "; var classteam1= 'matchteam team-'+ team1.replace(/\W/g, '') + ' '; var classteam2= 'matchteam team-'+ team2.replace(/\W/g, '') + ' '; if(score1 > bo/2) classteam1+= "winner"; if(score2 > bo/2) classteam2+= "winner"; var match; var team1imgtext = ""; var team2imgtext = ""; if( team1 != " " && team1id != 0 ) { team1imgtext = ''; } if( team2 != " " && team2id != 0 ) { team2imgtext = ''; } if( score1 == 0 && score2 == 0) { score1 = ""; score2 = ""; } var bSubstitute = false; if( bIsChildMatch && team1 == " " ) { team1 = strMatchText.toUpperCase(); bSubstitute = true; } if(short==undefined) { match = $( '
    Stage
    Loser gets 4th place
    ' + id + '
    bo3
    L
    ' + team1 + '
    ' + score1 + '
    \
    ' + team2 + '
    ' + score2 + '
    ' ) .offset( {left: x, top: y} ) .appendTo( element ); } else { if( bSubstitute ) { match = $('
    ' + team1imgtext + team1 + '
    ' + score1 + '
    \
    ' + team2imgtext + team2 + '
    ' + score2 + '
    ') .offset({left:x, top:y}) .appendTo(element); } else { match = $('
    ' + team1imgtext + team1 + '
    ' + score1 + '
    \
    ' + team2imgtext + team2 + '
    ' + score2 + '
    ') .offset({left:x, top:y}) .appendTo(element); } } if( y > 430 ) { if ( rgTeamPlace[team1id] ) { if( rgTeamPlace[team1id] != 0 ) { var strCurPrizePool = Number( rgPlacePercentages[rgTeamPlace[team1id]] * unPrizePool ).toFixed( 0 ); $( '' ).appendTo( match ); rgTeamPlace[team1id] = null; } else { var strCurPrizePool = Number( rgPlacePercentages[rgTeamPlace[team1id]] * unPrizePool ).toFixed( 0 ); $( '' ).appendTo( match ); rgTeamPlace[team1id] = null; } } if ( rgTeamPlace[team2id] != null ) { if( rgTeamPlace[team2id] != 0 ) { var strCurPrizePool = Number( rgPlacePercentages[rgTeamPlace[team2id]] * unPrizePool ).toFixed( 0 ); $( '' ).appendTo( match ); rgTeamPlace[team2id] = null; } else { var strCurPrizePool = Number( rgPlacePercentages[rgTeamPlace[team2id]] * unPrizePool ).toFixed( 0 ); $( '' ).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 ) { $( '
    ' + strLetter + '
    ' ).appendTo( '.ReplaysWildCardAreaUpperBracketArea' ); } if( bestOftracker == 0 ) { bestOfData[0] = []; bestOfData[0]['bo'] = depth[i][j]["bo"]; bestOfData[0]['left'] = depth[i][j]["left"]; bestOfData[0]['top'] = depth[i][j]["top"]; bestOfData[0]['bot'] = depth[i][j]["top"]; bestOfData[0]['stage_name'] = depth[i][j]["stage_name"]; bestOfData[0]['numElements'] = 1; bestOftracker++; } else { if( bestOfData[bestOftracker - 1]['bo'] != depth[i][j]["bo"] ) { bestOfData[bestOftracker] = []; bestOfData[bestOftracker]['bo'] = depth[i][j]["bo"]; bestOfData[bestOftracker]['left'] = depth[i][j]["left"]; bestOfData[bestOftracker]['top'] = depth[i][j]["top"]; bestOfData[bestOftracker]['bot'] = depth[i][j]["top"]; bestOfData[bestOftracker]['numElements'] = 1; bestOftracker++; } else { bestOfData[bestOftracker - 1]['left'] = depth[i][j]["left"]; if( bestOfData[bestOftracker - 1]['top'] > depth[i][j]["top"] ) { bestOfData[bestOftracker - 1]['top'] = depth[i][j]["top"]; } if( bestOfData[bestOftracker - 1]['bot'] < depth[i][j]["top"] ) { bestOfData[bestOftracker - 1]['bot'] = depth[i][j]["top"]; } bestOfData[bestOftracker - 1]['numElements']++; } } if(depth[i][j]["parent"]!=undefined) { var unTeam = 0; if( depth[i][j]["parent"]['team2O'] ) { if( depth[i][j + 1] && depth[i][j + 1]["parent"] != depth[i][j]["parent"] && depth[i][j - 1] && depth[i][j - 1]["parent"] != depth[i][j]["parent"] ) { var strWhichMatch = depth[i][j]["parent"]['team2O'].substring( 0, 1 ); var unWhichMatchID = parseInt( depth[i][j]["parent"]['team2O'].substring( 1, depth[i][j]["parent"]['team2O'].length ) ); if ( strWhichMatch == "W" && unWhichMatchID == parseInt( depth[i][j]["id"] ) ) { unTeam = 2; } } else if( !depth[i][j-1] && depth[i][j + 1] && depth[i][j + 1]["parent"] != depth[i][j]["parent"] ) { var strWhichMatch = depth[i][j]["parent"]['team2O'].substring( 0, 1 ); var unWhichMatchID = parseInt( depth[i][j]["parent"]['team2O'].substring( 1, depth[i][j]["parent"]['team2O'].length ) ); if ( strWhichMatch == "W" && unWhichMatchID == parseInt( depth[i][j]["id"] ) ) { unTeam = 2; } } else if( !depth[i][j+1] && depth[i][j - 1] && depth[i][j - 1]["parent"] != depth[i][j]["parent"] ) { var strWhichMatch = depth[i][j]["parent"]['team2O'].substring( 0, 1 ); var unWhichMatchID = parseInt( depth[i][j]["parent"]['team2O'].substring( 1, depth[i][j]["parent"]['team2O'].length ) ); if ( strWhichMatch == "W" && unWhichMatchID == parseInt( depth[i][j]["id"] ) ) { unTeam = 2; } } else if( !depth[i][j - 1] && !depth[i][j + 1] ) { var strWhichMatch = depth[i][j]["parent"]['team2O'].substring( 0, 1 ); var unWhichMatchID = parseInt( depth[i][j]["parent"]['team2O'].substring( 1, depth[i][j]["parent"]['team2O'].length ) ); if ( strWhichMatch == "W" && unWhichMatchID == parseInt( depth[i][j]["id"] ) ) { unTeam = 2; } } } connectMatch( $( "#match" + depth[i][j]["id"] ), $( "#match" + depth[i][j]["parent"]["id"] ), depth[i][j]["winner"], unTeam, element ); } } } for( var x = 0; x < bestOfData.length; x++ ) { var right = 0; var top = 0; if( bestOfData[x - 1] ) { right = bestOfData[x - 1]['left']; } if( right == 0 ) { var width = 0; if( ( rightBracket - bestOfData[x]['left'] ) == 0 ) { width = 125; } else { width = 125 + ( ( rightBracket - bestOfData[x]['left'] ) ); } if( bestOfData[x]['numElements'] == 1 ) { $( '
    ' + rgLocalizedStrings["DOTA_TournamentBracket_GrandFinals"] + '
    ' + rgLocalizedStrings["TI2015_Overview_BestOf"] + ' ' + rgGameNums[parseInt( bestOfData[x]['bo'] )] + '
    ' ).appendTo( '.ReplaysWildCardAreaUpperBracketArea' ); } else { $( '
    ' + rgLocalizedStrings["TI2015_Overview_BestOf"] + ' ' + rgGameNums[parseInt( bestOfData[x]['bo'] )] + '
    ' ).appendTo( '.ReplaysWildCardAreaUpperBracketArea' ); $( '
    ' + rgLocalizedStrings["TI2015_Overview_BestOf"] + ' ' + rgGameNums[parseInt( bestOfData[x]['bo'] )] + '
    ' ).appendTo( '.ReplaysWildCardAreaUpperBracketArea' ); } } else { var width = right - bestOfData[x]['left'] - 25; if( x == bestOfData.length / 2 || x == Math.ceil( bestOfData.length / 2 ) ) { $( '
    ' + rgLocalizedStrings["TI2015_Overview_BestOf"] + ' ' + rgGameNums[parseInt( bestOfData[x]['bo'] )] + '
    ' ).appendTo( '.ReplaysWildCardAreaUpperBracketArea' ); } else { $( '
    ' + rgLocalizedStrings["TI2015_Overview_BestOf"] + ' ' + rgGameNums[parseInt( bestOfData[x]['bo'] )] + '
    ' + rgLocalizedStrings["TI2015_Overview_LowerBracket"] + '
    ' ).appendTo( '.ReplaysWildCardAreaUpperBracketArea' ); $( '
    ' + rgLocalizedStrings["TI2015_Overview_UpperBracket"] + '
    ' + rgLocalizedStrings["TI2015_Overview_BestOf"] + ' ' + rgGameNums[parseInt( bestOfData[x]['bo'] )] + '
    ' ).appendTo( '.ReplaysWildCardAreaUpperBracketArea' ); } } } if( maxdepth > 3 ) { var unPrizePoolOffset = 0; for ( var i = 0; i <= maxdepth + 1; i++ ) { var unOffset = 0; if ( i == 1 ) { unOffset = 30; unPrizePoolOffset--; } var strCurPrizePool = Number( rgPlacePercentages[i] * unPrizePool ).toFixed( 0 ); $( '
    ' + rgPlaces[i] + '
    $' + Number( strCurPrizePool ).toLocaleString( 'en') + '
    ' ).appendTo( '.ReplaysWildCardAreaUpperBracketArea' ); } } $( ".ReplaysWildCardAreaUpperBracketArea" ).css( "height", ( ( botBracket - topBracket ) + 225 + unBottomBOOffset ) ); $( ".ReplaysWildCardAreaUpperBracketArea" ).css( "width", ( rightBracket - leftBracket ) * 2 ); $( ".ReplaysWildCardAreaUpperBracketArea" ).css( "margin-top", ( ( topBracket * -1 ) + 20 ) + 10 ); }