MediaWiki:Chat.js

/** * This file loads for every user the wiki chat. * For skin specific variants see MediaWiki:Chat.css * for oasis respectively * * Please test any changes made to this file. * Jshint  can catch syntax errors to help testing. * Alternatively, Wikia's code editor has jshint embedded to make life extra simple. * */

/* global mw, importArticle, importArticles, ChatView, EmoticonMapping, wgUserName */

/* jshint bitwise:true, browser:true, curly:true, devel:false, eqeqeq:true, es3:false, forin:true, jquery:true, latedef:true, noarg:true, nonew:true, onevar:false, plusplus:false, undef:true, unused:true, strict:true, trailing:true

window.chatags = { images: true, videos: true };

window.chatAnnouncementsAll = true;

importArticles({   type: 'script',    articles: [        // ...        'u:dev:MediaWiki:ChatAnnouncements/code.js',        'u:dev:MediaWiki:ChatOptions/code.js',        'u:dev:MediaWiki:IsTyping/code.js',        'MediaWiki:Chat.js/inline.js',        'MediaWiki:Chat.js/multiPM.js',        'MediaWiki:Chat.js/multiKick.js',        'u:shining-armor:MediaWiki:ChatTags/code.js'        // ...    ] });

importArticle({   type: 'style',    article: 'MediaWiki:ChatResizeEmoticons.css' });

/*	auto refresh emoticons and css all credit goes to Penguin-Pal $(function {	var gap = 30,		css = $('');	$(css).appendTo('head');	function request {		$.getJSON('/api.php?action=query&format=json&prop=revisions&titles=MediaWiki:Emoticons|MediaWiki:ChatResizeEmoticons.css&rvprop=content&cb=' + new Date.getTime, function(data) { var a = data.query.pages; for (var pageid in a) { if (a[pageid].title === 'MediaWiki:ChatResizeEmoticons.css') { $(css).text(a[pageid].revisions[0]['*']); } else if (a[pageid].title === 'MediaWiki:Emoticons') { updateEmoticons(a[pageid].revisions[0]['*']); }			}		});	}	function updateEmoticons(newEmoticons) {		mw.config.set('wgChatEmoticons', newEmoticons);		ChatView.prototype.emoticonMapping = new EmoticonMapping;		ChatView.prototype.emoticonMapping.loadFromWikiText(newEmoticons);	}	// make first request when joining the room	request;	// request again every every 'gap' seconds	setInterval(request, gap * 1000); });

/* Start Custom Chat Stars */

$('#ChatHeader .User').attr('data-user', wgUserName.replace(' ', '_').replace(/["']/g, ''));  setInterval(function {        'use strict';        $('.User').each(function{            $(this).removeClass('chatmoderator');            if ($(this).attr('data-user').match(/(AkioTheOne|Bobnekaro|Hypercane|Money Hurricane|StrawberryMaster|VileMaster)/)) {                $(this).addClass('bureaucrat');            }            $(this).removeClass('chatmoderator');            if ($(this).attr('data-user').match(/(Brickcraft1|Cooper7579|Farm River|MonseurRoussil1997|TropicalStormChapsteck)/)) {                 $(this).addClass('admin');            }            $(this).removeClass('chatmoderator');            if ($(this).attr('data-user').match(/Prism55Writes/)) {                $(this).addClass('junioradmin');            }            $(this).removeClass('chatmoderator');            if ($(this).attr('data-user').match(/GaryKJR/)) { $(this).addClass('rollback'); }           $(this).removeClass('chatmoderator'); if ($(this).attr('data-user').match(/ArrDFe25/)) { $(this).addClass('moderator'); }           $(this).removeClass('chatmoderator'); if ($(this).attr('data-user').match(/Sjmaven1993/)) { $(this).addClass('founder'); }           $(this).removeClass('chatmoderator'); if ($(this).attr('data-user').match(/(RansomTime|Callofduty4|VegaDark|VSTF Bot|TyA|Laundry Machine|Lady Lostris|Riptoze|Cyanide3|White torch|Jr Mime|Noreplyz|DeXart|Matheus Leonardo|Kopcap94|Wiki-o-slay|Minato826)/)) { $(this).addClass('vstf'); }           $(this).removeClass('chatmoderator'); if ($(this).attr('data-user').match(/(Bluetiger0824|Cane Harvey)/)) { $(this).addClass('autopatrol'); }           $(this).removeClass('chatmoderator'); if ($(this).attr('data-user').match(/(Baron Kobe|ChapDurianBot|Hypercane Bot|Money Bot|PassionFruitMaster)/)) { $(this).addClass('bot'); }   });	}, 1500);

/* End Custom Chat Stars */