MediaWiki:Common.js

From comp.tf
Revision as of 19:44, 7 September 2013 by Kaneco (talk | contribs) (added brackets code)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Any JavaScript here will be loaded for all users on every page load. */
	
/* brackets code */
    var highlighted;
    jQuery.fn.justtext = function () {
            return $(this).clone().children().remove('div').end().text().trim();
    };
    var bracketGame;
    $(document).ready(function () {
            $('.bracket-player-top, .bracket-player-bottom, .bracket-game .icon').hover(function () {
                    t = $(this);
                    var text = t.justtext();
                    if (text) {
                            highlighted = t.
                                    parents('.bracket').find('.bracket-player-top, .bracket-player-bottom').filter(function () {
                                            return $(this).justtext() == text
                                    });
                            highlighted.addClass('bracket-hover');
                            highlighted.each(function () {
                                    $(this).data('bgcolor', $(this).css('background-color'));
                                    switch ($(this).data('bgcolor')) {
                                    case 'rgb(242, 184, 184)':
                                            $(this).css('background-color', 'rgb(250,217,217)');
                                            break;
                                    case 'rgb(184, 242, 184)':
                                            $(this).css('background-color', 'rgb(217,250,217)');
                                            break;
                                    case 'rgb(184, 184, 242)':
                                            $(this).css('background-color', 'rgb(217,217,250)');
                                            break;
                                    default:
                                            $(this).css('background-color', 'rgb(250,250,250)');
                                            break;
                                    }
                            });
                    }
            }, function () {
                    highlighted.removeClass('bracket-hover');
                    highlighted.each(function () {
                            $(this).css('background-color', $(this).data('bgcolor'));
                    });
            });
    });