User:Sir No/common.js

/* Match Details - Adapted from Liquipedia - http://wiki.teamliquid.net/dota2/MediaWiki:Common.js	var bracketGame; $(document).ready(function {		$('.bracket-game').each( function { if ($(this).find('.bracket-game-details').length > 0) { var margin = $(this).find(':first-child').height - 6; $(this).prepend(' '); }		});		$('.match-row').each( function { if ($(this).find('.bracket-game-details').length > 0) { $(this).find('td:eq(2)').prepend('  '); }		});		$('.bracket-team-top, .bracket-team-bottom, .bracket-team-top-oldschool, .bracket-team-bottom-oldschool, .bracket-game .icon').click( function (event) { var bracket = $(this).closest('.bracket'), detailsHeight, detailsWidth, spaceOnTheRight; if (bracketGame != null) { bracketGame.children('.bracket-game-details').toggle; if (bracketGame[0] === $(this).closest('.bracket-game')[0]) { bracketGame = null; return; }			}			bracketGame = $(this).closest('.bracket-game'); detailsHeight= bracketGame.children('.bracket-game-details').height; detailsWidth = bracketGame.children('.bracket-game-details').width; bracketGame.children('.bracket-game-details').css('margin-top', -detailsHeight / 2); spaceOnTheRight = Math.max($(window).width, bracket.offset.left + bracket.outerWidth) - (bracketGame.offset.left + bracketGame.outerWidth); if (spaceOnTheRight < detailsWidth && bracketGame.offset.left > detailsWidth) { bracketGame.children('.bracket-game-details').css('margin-left', -detailsWidth - 1); } else { bracketGame.children('.bracket-game-details').css('margin-left', bracketGame.width); }			bracketGame.children('.bracket-game-details').toggle; event.stopPropagation; });		$('.match-row').click(function (event) { if (bracketGame != null) { bracketGame.find('.bracket-game-details').toggle; if (bracketGame[0] === $(this)[0]) { bracketGame = null; return; }			}			bracketGame = $(this); var height = bracketGame.find('.bracket-game-details').height; bracketGame.find('.bracket-game-details').css('margin-top', 3); bracketGame.find('.bracket-game-details').toggle; event.stopPropagation; });

$('.bracket-game-details').click(function (event) {			event.stopPropagation;		}); });	 End Match Details

Team Highlighting - Adapted from Liquipedia - http://wiki.teamliquid.net/dota2/MediaWiki:Common.js 	var highlighted; $.fn.justtext = function { var searchname = null; var results = $(this).children('.highlightName'); if(results.length > 0){ searchname = results[0].id; }	 return searchname; };	$(document).ready(function {		$('.bracket-team-top, .bracket-team-top-oldschool, .bracket-team-bottom, .bracket-team-bottom-oldschool, .bracket-game .icon, .matchlistslot, .grouptableslot').hover(function { var t = $(this), text = t.justtext; if ((text) && (text.toUpperCase != 'BYE')) { highlighted = $(document).find('.bracket-team-top, .bracket-team-bottom, .bracket-team-top-oldschool, .bracket-team-bottom-oldschool, .matchlistslot, .grouptableslot').filter(function {					return $(this).justtext == text;				}); highlighted.not('.colorWin, .colorUpwithbye, .colorUp, .colorStayup, .colorStay, .colorStaydown, .colorDown, .colorAutorelegate, .colorDraw').css('background-color', '#cecece'); highlighted.filter('.colorWin').addClass("colorWinHL").removeClass("colorWin"); highlighted.filter('.colorUpwithbye').addClass("colorUpwithbyeHL").removeClass("colorUpwithbye"); highlighted.filter('.colorUp').addClass("colorUpHL").removeClass("colorUp"); highlighted.filter('.colorStayup').addClass("colorStayupHL").removeClass("colorStayup"); highlighted.filter('.colorStay').addClass("colorStayHL").removeClass("colorStay"); highlighted.filter('.colorStaydown').addClass("colorStaydownHL").removeClass("colorStaydown"); highlighted.filter('.colorDown').addClass("colorDownHL").removeClass("colorDown"); highlighted.filter('.colorAutorelegate').addClass("colorAutorelegateHL").removeClass("colorAutorelegate"); highlighted.filter('.colorDraw').addClass("colorDrawHL").removeClass("colorDraw"); }			if (t.closest('.bracket-game').children('.bracket-game-details').length) { t.css('cursor', 'pointer'); }		},		function { if (highlighted != null){ highlighted.not('.colorWinHL, .colorUpwithbyeHL, .colorUpHL, .colorStayupHL, .colorStayHL, .colorStaydownHL, .colorDownHL, .colorAutorelegateHL, .colorDrawHL').css('background-color', ''); highlighted.filter('.colorWinHL').addClass("colorWin").removeClass("colorWinHL"); highlighted.filter('.colorUpwithbyeHL').addClass("colorUpwithbye").removeClass("colorUpwithbyeHL"); highlighted.filter('.colorUpHL').addClass("colorUp").removeClass("colorUpHL"); highlighted.filter('.colorStayupHL').addClass("colorStayup").removeClass("colorStayupHL"); highlighted.filter('.colorStayHL').addClass("colorStay").removeClass("colorStayHL"); highlighted.filter('.colorStaydownHL').addClass("colorStaydown").removeClass("colorStaydownHL"); highlighted.filter('.colorDownHL').addClass("colorDown").removeClass("colorDownHL"); highlighted.filter('.colorAutorelegateHL').addClass("colorAutorelegate").removeClass("colorAutorelegateHL"); highlighted.filter('.colorDrawHL').addClass("colorDraw").removeClass("colorDrawHL"); }		});	});	 End Team Highlighting */