MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */

// Ticks the main page's stage rotation countdown. // Credits go to AbelToy, Guy Perfect, Espyo. function tickStageCountdown { // Calculate the current and next times expressed in seconds // The 2 added to the current hour here is a synchronization bias var curTime = new Date; var nextTime = ((curTime.getUTCHours + 2 & -4) + 4) * 3600; curTime     = (curTime.getUTCHours + 2) * 3600 + curTime.getMinutes      *   60 + curTime.getSeconds;

// Calculate and format the time remaining until the next stage selection var timeDiff = nextTime - curTime; return ("00" + Math.floor(timeDiff / 3600)    ).slice(-2) + ":" + ("00" + (Math.floor(timeDiff / 60) % 60)).slice(-2) + ":" + ("00" + (timeDiff % 60)                ).slice(-2); }

var stageCountdownSpan = document.getElementById("stageCountdown"); if(stageCountdownSpan){ setInterval(function {    stageCountdownSpan.innerHTML = tickStageCountdown;  }, 1000 ); }