Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* Wikicup Viewer TODO Highlight cells based on who has the most for each type.*/functionwikicupSorter(){if(mw.config.get('wgPageName')!='Wikipedia:WikiCup')returnfalse;mw.util.addCSS('.wikicup-failing td { background-color: #fee; }\ .wikicup-passing td { background-color: #efe; }\ .wikicup-self td { background-color: #ffe; }\ .key-table { float: left; }\ .viewer-information { float: left; margin-left: 2.5em; background-color: #eee; padding: 10px; }\ .viewer-information-header { font-weight: bold; font-size: 1.25em; }\ ');// Script might be broken during the transition periods between roundsvartoday=newDate();varthisYear=today.getFullYear();// Round 1vartopContestants=64;vartopWildcards=0;functionsetCutoff(date,contestants,wildcards){if(today>=newDate(thisYear+'-'+date))topContestants=contestants,topWildcards=wildcards;}setCutoff('03-01',2,16);// Round 2setCutoff('05-01',2,8);// Round 3setCutoff('07-01',2,4);// Round 4setCutoff('09-01',1,0);// Round 5varscore=$('.headerSort[abbr=Score]').click().click();varusername=mw.config.get('wgUserName');// Self: #ffe, passing: #efe, failing: #feescore.each(function(){varcontestantCount=0;$(this).parent().parent().next().children().each(function(){varcontestant=$(this);contestant.addClass('wikicup-contestant');if(contestant.text().match(username))contestant.addClass('wikicup-self');if(contestantCount<topContestants)contestant.addClass('wikicup-passing');// Passingelsecontestant.addClass('wikicup-failing');// FailingcontestantCount++;});});// Now do the wildcardsvarfailingScores=[];$('.wikicup-failing').each(function(){failingScores.push([$(this),$(this).children(':last').text()]);});// Sort failing scores by scorefailingScores.sort(function(a,b){if(parseInt(a[1])<parseInt(b[1]))return1;elseif(parseInt(a[1])==parseInt(b[1]))return0;elsereturn-1;});varwildcards=failingScores.slice(0,topWildcards);varminWildcardScore;if(wildcards.length>=1)minWildcardScore=parseInt(wildcards[wildcards.length-1][1]);elseminWildcardScore='Unknown';for(vari=0;i<wildcards.length;i++){wildcards[i][0].addClass('wikicup-passing');}/* Extra data to add next to the Key for the page */varkeyTable=$('#Key').parent().next();keyTable.addClass('key-table');keyTable.after('<div class="viewer-information"><span class="viewer-information-header">WikiCup Viewer information</span><ul><li><strong>Minimum score required as a wildcard:</strong> '+minWildcardScore+' points</li></ul></div><div style="clear: left;"></div>');}addOnloadHook(wikicupSorter);// addOnloadHook necessary to allow table to be sortable first