User:TheOneFootTallBrickWall/wikia.js

importScriptPage('MediaWiki:Chatconnect.js','ozank');

//

// removes listings entries from a json tree // and also makes it into an easy array function removeListings (data) { filteredList = data.filter(function(element) {       if ((element.title).indexOf('/') !== -1) {            return element;        }    }); return filteredList; }

function renderStamp (iso) { date = new Date(iso); return date.getDate + ' ' + wgMonthNames[date.getMonth+1] + ' ' + date.getFullYear; }

function createCommentCounts ($this, admins, commentLink) { var count = 0, myusercount = 0, allmyusercount = 0, admincount = 0; $.get('/api.php', {       action: 'query',        list: 'allpages',        apnamespace: '501',        apfrom: commentLink,        aplimit: '80',        format: 'json'    }).done(function(d) {        var adminList = [];        for (var j = 0; j < 80; j++) {            var w = d.query.allpages[j].title;            if (w.indexOf(commentLink) !== -1) {                count++;                var rgxend = new RegExp('@comment-' + wgUserName + '-\\d*$', 'g'),                    rgxany = new RegExp('@comment-' + wgUserName + '-\\d*', 'g');                if (w.match(rgxend)) {                    myusercount++;                }                if (w.match(rgxany)) {                    allmyusercount++;                }                for (var k = 0; k < admins.length; k++) {                    if (w.indexOf("@comment-" + admins[k]) !== -1) {                        admincount++;                        if (adminList.indexOf(admins[k]) === -1) { adminList.push(admins[k]); }                   }                }            }            else { break; }       }

$this.prepend(' ' + count + ' ' +            '' + admincount + ' ' +             '' + myusercount + ' ' +             '' + (allmyusercount - myusercount) + '  ' +             ' ' + $this.attr('data-timestamp') + ' '); if (adminList.length) { $this.append(' Replies from ' + adminList.join(", ") + ' '); } else if (!count) { $this.append(' No comments! '); }       $this.append('');

if (count === 0) { $this.addClass("no-comments"); } else { $this.addClass("many-comments"); }       if (myusercount === 0) { $this.addClass("no-own-comments"); } else { $this.addClass("many-own-comments"); }       if (admincount === 0) { $this.addClass("no-admin-comments"); } else { $this.addClass("many-admin-comments"); }   }); }

if (mw.config.get('wgCanonicalSpecialPageName') === "Blankpage" && $.getUrlVar('blankspecial') === "blogreport") { $('#mw-content-text p').html(' '); $('.header-column.header-title h1').text('Blog Report Interface'); }   if ($('#CC-blog-interface').length === -1 || mw.config.get("wgCityId") !== "177") { return; }   importStylesheetURI('http://internal.community.wikia.com/index.php?title=MediaWiki:BlogReport.css&action=raw&ctype=text/css'); $('#CC-blog-interface').empty; $.getJSON('/api.php', {        action: 'query',         list: 'recentchanges',         rcnamespace: '500',         rctype: 'new',         rclimit: '500',         rcprop: 'user|title|timestamp|ids|sizes|redirect',         format: 'json'     }, function (blogData) {         var newBlogs = removeListings(blogData.query.recentchanges);         for (var i = 0; i < newBlogs.length; i++) {            var $newBlog = $(' ' + '' + newBlogs[i].title + '' + ' ');           if (typeof newBlogs[i].redirect !== "undefined") {                var $newBlog = $(' ' + '' + newBlogs[i].title + '#redirect' + '' + ' ');           }
 * (function($, mw) {

$('#CC-blog-interface').append($newBlog); }       $('.new-blog').each(function {            var admins = ['2Actimv','AdorableDarling','Callofduty4','Jr Mime','Noreplyz','Sactage','Slyst','Spongebob456','TheOneFootTallBrickWall','TyA','Yatalu','Sannse', 'Kirkburn', 'BertH'],                $this = $(this).find('a'),                newBlogTitle = $(this).find('a').text,                commentLink = newBlogTitle.replace('User blog','');                if (newBlogTitle.indexOf("#redirect") !== -1) {                    $.getJSON('/api.php', { action: 'query', prop: 'info', inprop: 'redirect', titles: newBlogTitle.slice(0, -9), format: 'json' }, function (redirectInfo) { redirectInfo = redirectInfo.query.pages; for (var keyname in redirectInfo) { commentLink = redirectInfo[keyname]["redirectto"].replace('User_blog','').replace(/_/g,' '); $this.find('a').html(redirectInfo[keyname]["redirectto"].replace(/_/g,' ')); createCommentCounts ($this, admins, commentLink); }                    });                } else {                    createCommentCounts ($this, admins, commentLink);                }        }); }); })(this.jQuery, this.mediaWiki); //