MediaWiki:Common.js/warbandstimer.js

//

function f(d) { d = new Date(d); var day = d.getDay, diff = new Date; diff.setDate(d.getDate - day); diff.setUTCHours(5, 0, 0, 0); return 7 * 60 * 60 - Math.floor((d.valueOf - diff.valueOf)/1000) % (7 * 60 * 60); }

var counter, count; reset;

function reset { clearInterval(counter); count = f(new Date); counter=setInterval(timer, 1000); $('#wb-timer').css("background", "#FFFF55"); $('#wb-active').text("The next warband begins in"); } function timer { count--; if(count % 10 == 0) count = f(new Date); if (count <= 0) {   clearInterval(counter); counter = setInterval(reset, 1000 * 60 * 1); $('#wb-countdown').text("Active"); $('#wb-timer').css("background", "#55FF55"); $('#wb-active').text("Wilderness Warbands is currently"); return; }

var hours = Math.floor(count/(60*60)), mins = Math.floor((count%(60*60))/60), seconds = count % 60; $('#wb-countdown').html(hours + ":" +                         (mins.toString.length === 1 ? "0" : "") + mins + ":" +                         (seconds.toString.length === 1 ? "0" : "") + seconds); }

//