Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
importArticles({
type: 'script',
articles: [
'u:dev:ChatOptions/code.js',
'u:dev:WordFilter/code.js'
]
});
// 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);
});