User:AlyssaTheMusicGeek/chat.js

importScriptPage('MediaWiki:ChatOptions/code.js', 'dev');

importScriptPage('WordFilter/code.js','dev'); // PM notifications, forked from TK-999, Noreplyz and Speedit require(['wikia.window', 'mw'], function (context, mw) {   if (!context.Notification) {        return;    }    // ping variables    var notification = document.createElement('audio');        notification.src = 'http://images.wikia.nocookie.net/speedit/images/0/01/Notification.ogg';        notification.id = 'ChatNotification';        notification.style.display = 'none';    document.body.appendChild(notification);    // pm notification function    function priv(cwpm) {        var privateRoomId = cwpm.attributes.roomId;        var privateRoom = window.mainRoom.chats.privates[privateRoomId];        privateRoom.model.chats.bind('afteradd', function(cwmsg) { user = cwmsg.attributes.name; if ( user === wgUserName || document.getElementById('Chat_' + privateRoomId).style.display !== 'none' && document.hasFocus ) return; msg = cwmsg.attributes.text; var obj = mainRoom.model.users.findByName(name); avatar = cwmsg.attributes.avatarSrc.replace(/28(?!.*28)/, '150'); pmtitle = "PM from " + user; var pmconfig = { body: msg, icon: avatar };           var pmping = new context.Notification(pmtitle, pmconfig), pmnotif = document.getElementById('ChatNotification'); pmnotif.play; setTimeout(function { pmping.close; }, 5000); });   }    // unbind listener if the user didn't allow notifications    Notification.requestPermission(function (response) { if (response !== "granted") { context.mainRoom.model.privateUsers.unbind('add', priv); }   });    context.mainRoom.model.privateUsers.bind('add', priv); });