User:Gameuser10/chat.js

/* Made by the nub called User:AnimatedCartoons */ /* Fixed with help from User:452 */ // Recent changes notification (part 1 of 3) var notifyChanges = function (d) { var name = d.query.recentchanges[0].user, title = d.query.recentchanges[0].title, comment = d.query.recentchanges[0].comment, revid = d.query.recentchanges[0].revid, title2 = title.replace(/\?/g, '%3F'), comment2 = comment.replace(/"/g, '\''),           name2;

if (name === mw.config.get('wgUserName')) { name2 = 'You'; } else { name2 = '' + name + ''; }

$('.watchlist').html(name2 + ' changed ' + title + ' (diff)'); };

(function ($, mw) {   "use strict";    // Variables    var un = mw.config.get('wgUserName'),        ttl = 'Chat — Adventure Time Wiki',        wk = 'http://adventuretime.wikia.com',        ytmnthnm = [            'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'        ],        ytname;

if (mw.config.get('wgCanonicalSpecialPageName') === 'Chat') { if (localStorage.getItem('notify') !== 'november') { $.showCustomModal(' Chat stuff is back! :3', ' Additions Notify recent changes from your selected wiki Timestamp now shows seconds

Changes Due to new changes of YouTube comments, embedded comments only show the most popular comments and not the most recent comments Due to new changes of YouTube comments, commenters\' avatars are outdated

#animatedcartoons ', {               id: 'notify', buttons: [ {                       defaultButton: true, message: 'OK', handler: function { $('#notify').closeModal; }                   }                ]            });            localStorage.setItem('notify', 'november');        }

importStylesheet('User:Gameuser10/chat.css');

// Descriptive title document.title = ttl;

// Show own username on the list $('li#user-' + un).attr('style', 'display: block !important');

// Recent changes notification (part 2 of 3) if (!localStorage.getItem('notifyChanges')) { localStorage.setItem('notifyChanges', wk); }

var watchList = function { if (localStorage.getItem('notifyChanges') === wk) { $.getJSON(wk + '/api.php', {                       action: 'query',                        list: 'recentchanges',                        rclimit: 1,                        rcdir: 'older',                        rctype: 'edit',                        rcprop: 'ids|user|title|comment',                        format: 'json'                    }, function (data) {                        var name = data.query.recentchanges[0].user,                            title = data.query.recentchanges[0].title,                            comment = data.query.recentchanges[0].comment,                            revid = data.query.recentchanges[0].revid,                            title2 = title.replace(/\?/g, '%3F'),                            comment2 = comment.replace(/"/g, '\''),                            name2;

if (name === un) { name2 = 'You'; } else { name2 = '' + name + ''; }

$('.watchlist').html(name2 + ' changed ' + title + ' (diff)'); });               } else {                    mw.loader.load(localStorage.getItem('notifyChanges') + '/api.php?action=query&list=recentchanges&rclimit=1&rcprop=ids|user|title|comment&rcdir=older&rctype=edit&format=json&callback=notifyChanges');                }            };

$(function {            $('.ChatHeader').append(' ');            watchList;        });

setInterval(watchList, 20000);

// Messages and users count $('.Rail h1.wordmark').before('         ');

setInterval(function {            // Messages count            $('.messages').html($('#Chat_' + mw.config.get('roomId') + ' .message').length);

// Users count $('.users').html($('.WikiChatList li.User:not(.ui-sortable-placeholder)').length); }, 1);

// Bug fixes var bgfxs = function (chat) { $('.continued:first-child').removeClass('continued'); $('.inline-alert').next('li.continued:not(.inline-alert)').removeClass('continued'); };

mainRoom.model.chats.bind('afteradd', bgfxs);

var rlct = setInterval(function {                if ($('.WikiaSearch').length) {                    $('.WikiaSearch').css('left', '250px');                    clearInterval(rlct);                }            }, 1);

// Removals var rmv = setInterval(function {                if ($('.chattopic').length) {                    $('.chattopic').remove;                    clearInterval(rmv);                }            }, 1);

// Rearrange list of users $('.WikiChatList').wrap(' '); $('.PrivateChatList').wrap(' ');

mw.loader.using('jquery.ui.sortable', function {            $('.WikiChatList').sortable({ revert: true, containment: '#WikiChat', handle: 'img', axis: 'y', cursor: 'ns-resize', start: function (e, ui) { ui.placeholder.height(ui.item.height); }           });

$('.PrivateChatList').sortable({               revert: true,                containment: '#PrivateChat',                handle: 'img',                axis: 'y',                cursor: 'ns-resize',                start: function (e, ui) {                    ui.placeholder.height(ui.item.height);                }            }); });

$('.WikiChatList, .PrivateChatList').on('click', 'li.User', function {            // Link to user's user page            $('.info .username').each(function  { var user = $(this).text, user2 = user.replace(/\?/g, '%3F'); $(this).replaceWith(' ' + user + '</li>'); });

// Link to user's contributions count $('.info .edits').each(function {                var user = $(this).siblings('.username').text,                    user2 = user.replace(/\?/g, '%3F');                $(this).replaceWith(' ' + $(this).text + '</a></li>');            }); });

// Custom actions and links $('.WikiChatList').on('click', 'li#user-' + un, function {            if (!$('.custom').length) {                $(this).children('.UserStatsMenu').children('.actions').prepend(' <li> Ignore users...</a></li><li> Notify changes...</a></li> <li>Recent activity</a></li><li>All activity</a></li><li>Preferences</a></li></ul> ');            }        });

// Ignore users var aa = JSON.parse(localStorage.getItem('block')), bb, i;       if (!localStorage.getItem('block') || localStorage.getItem('block') === 'undefined') { bb = ''; } else { for (i in aa) { if (aa.hasOwnProperty(i)) { $('head').append('<style type="text/css" id="block4">.Chat li[data-user="' + aa[i] + '"]{display: none;}.Rail li[data-user="' + aa[i] + '"] span.username{text-decoration: line-through !important;} '); }           }        }

$('body').on('click', '.ignore', function {            if (localStorage.getItem('block')) {                aa = JSON.parse(localStorage.getItem('block'));                bb = aa.join('\n');            }

$.showCustomModal('Ignore users', ' Please enter the user(s) you want to ignore. Case sensitive; separated by Enter. Ignored users have a strikethrough . <textarea id="block2" autofocus="autofocus" style="height: 300px; width: 400px; resize: none;">' + bb + ' ', {               id: 'block3',                buttons: [                    {                        message: 'Cancel',                        handler: function  {                            $('#block3').closeModal;                        }                    }, {                        message: "Clear",                        handler: function  {                            $('#block2').val('');                        }                    }, {                        defaultButton: true,                        message: 'Ignore',                        handler: function  {                            var a = $('#block2').val, b = a.split('\n'), c;

for (i = b.length; i--;) { if (b[i] === '') { b.splice(i, 1); }

if (b[i] === un) { b.splice(i, 1); }                           }

c = b.filter(function (elem, pos) {                               return b.indexOf(elem) === pos;                            });

localStorage.setItem('block', JSON.stringify(c));

$('head #block4').each(function {                                $(this).remove;                            });

for (var j = 0; j < c.length; j++) { $('head').append('<style type="text/css" id="block4">.Chat li[data-user="' + c[j] + '"]{ display: none; } .Rail li[data-user="' + c[j] + '"] span.username{ text-decoration: line-through !important; } '); }

$('#block3').closeModal; mainRoom.viewDiscussion.scrollToBottom; }                   }                ]            });

// Hide }).on('click', '.info li a, .custom li a', function { $('.UserStatsMenu').hide;

// Recent changes notification (part 3 of 3) }).on('click', '.changes', function { $.showCustomModal('Notify changes', ' Please enter the wiki you want its changes to be notified to you, in lowercase. Notifications from your specified wiki will appear within 20 seconds. <input id="change" autofocus="autofocus" placeholder="' + localStorage.getItem('notifyChanges').replace('http://', ).replace('.wikia.com', ) + '" style="width: 400px;"> ', {               id: 'change2',                buttons: [                    {                        message: 'Cancel',                        handler: function  {                            $('#change2').closeModal;                        }                    }, {                        defaultButton: true,                        message: 'Change',                        handler: function  {                            if ($('#change').val) {                                localStorage.setItem('notifyChanges', 'http://' + $('#change').val + '.wikia.com'); $('#change2').closeModal; }                       }                    }                ]  });  });  }  }(this.jQuery, this.mediaWiki));