MediaWiki:BoardThreadAlerts.js

/* Forum thread state alerts * * Adds an icon next to threads on the Board: namespace that tells the user if a thread is closed or highlighted. * Credits go to Slyst and Cqm * modified by Dorumin */ $(window).load(function {   if (mw.config.get('wgNamespaceNumber') !== 2000) {        return;    }    $('.ThreadList .thread').each(function { var $this = $(this); // With many thanks to w:User:Cqm! $.get(mw.util.wikiScript('wikia'), {           controller: 'Forum',            method: 'brickHeader',            id: $this.data('id'),            format: 'json'        }, function(data) {            var $thisTime = $this.find('.timestamp.timeago').text;            var isOld = false;            if ( /\d\d days ago/.test($thisTime) ) {                var time = $thisTime.split(' days ago');                if ( Number(time[0]) > 14 ) isOld = true;            } else if ( /month|year/.test($this.find('.timestamp.timeago').text) ) {                isOld = true;            }            if (isOld) {                $this                    .addClass('closed')                    .find('h4 > a').append('  ');            } else if (data.isClosed) { $this .addClass('closed') .find('h4 > a').append('  '); }           if (data.isNotifyeveryone) { $this .addClass('highlight') .find('h4 > a').append('  '); if ( $this.find('.closed-alert').length ) { $this.find('.highlight-alert').css('right', '120px'); }           }        });    });    // For threads that aren't on the first page of the board $('.ThreadList').on('DOMNodeInserted', function(e) {       if (e.target.className == 'thread') {            var $this = $(e.target);            $.get(mw.util.wikiScript('wikia'), { controller: 'Forum', method: 'brickHeader', id: $this.data('id'), format: 'json' }, function(data) { var $thisTime = $this.find('.timestamp.timeago').text; var isOld = false; if ( /\d\d days ago/.test($thisTime) ) { var time = $thisTime.split(' days ago'); if ( Number(time[0]) > 14 ) isOld = true; } else if ( /month|year/.test($this.find('.timestamp.timeago').text) ) { isOld = true; }               if (isOld) { $this .addClass('closed') .find('h4 > a').append('  '); } else if (data.isClosed) { $this .addClass('closed') .find('h4 > a').append('  '); }               if (data.isNotifyeveryone) { $this .addClass('highlight') .find('h4 > a').append('  '); if ( $this.find('.closed-alert').length ) { $this.find('.highlight-alert').css('right', '120px'); }               }            });        }    }); });