User:MACH-59330/chat.js

// chat imports importArticles({	type: 'script',	articles: [		'u:kocka:MediaWiki:Emoticons/code.js',		// 'u:dev:Colors/code.js'	] }); // mobile chatskin meta tag $('head').append(mw.html.element('meta', { name: 'viewport', content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' })); // HTML5 desktop notifications +ping class, forked from User:TK-999/chat.js require(['wikia.window', 'mw'], function (context, mw) {	if (!context.Notification) {		return;	}	// ping variables	var pings = new RegExp('(' + ['Speedit', 'Speedy', 'Speedo', 'help', 'CSS', 'template', 'infobox', 'Vanguard'].join('|') + ')', 'gi'),		notification = document.createElement('audio');		notification.src = 'http://images.wikia.nocookie.net/speedit/images/0/01/Notification.ogg';		notification.style.display = 'none';	// notification function	document.body.appendChild(notification);	function notify(message) {		var data = JSON.parse(message.data).attrs;		if (data.isInlineAlert || !pings.test(data.text) || data.name == wgUserName ) {			return;		}		var options = {			body: data.text,			icon: data.avatarSrc		};		document.querySelector('#Chat_' + window.mainRoom.roomId + ' li:last-of-type').classList.add('ping'); notification.play; var ping = new context.Notification(data.name, options); setTimeout(function { ping.close; }, 5000); }	// unbind listener if the user didn't allow notifications Notification.requestPermission(function (response) {		if (response !== "granted") {			context.mainRoom.socket.unbind('chat:add', notify);		}	}); context.mainRoom.socket.bind('chat:add', notify); });