User:Btoky/MediaWiki:Common.js

function events{ $('.event').each(function{       if($(this).is('[data-start]')) var start = $(this).data('start')*1000, end = $(this).data('end')*1000;        else var start = $(this).closest('[data-start]').data('start')*1000, end = $(this).closest('[data-end]').data('end')*1000;        var cur = new Date*1;        if(cur < start) $(this).removeClass('eventDuring eventAfter').addClass('eventBefore');        else if(start <= cur && cur < end) $(this).removeClass('eventBefore eventAfter').addClass('eventDuring');        else if(end <= cur) $(this).removeClass('eventBefore eventDuring').addClass('eventAfter');

if(!$(this).hasClass('eventTimer')) return true; var text = ''; if($(this).hasClass('eventBefore')) var diff = start-cur; else if($(this).hasClass('eventDuring')) var diff = end-cur; else if($(this).hasClass('eventAfter')) var diff = cur-end; if(temp = Math.floor(diff/86400000)) text = temp + 'day'; text += ('0'+Math.floor(diff%86400000/3600000)).slice(-2); $(this).empty.append(           document.createTextNode(text),            $(' ').addClass('eventTimerFlash').text(':'),            document.createTextNode(('0'+Math.floor(diff%3600000/60000)).slice(-2))        );

});

$('.eventDisplayBefore, .eventDisplayDuring, .eventDisplayAfter').hide; $('.eventDisplayBefore.eventBefore, .eventDisplayDuring.eventDuring, .eventDisplayAfter.eventAfter').show;

setTimeout(events,5000); }