User:Saftzie/global.js

// __NOINDEX__

(function (mw, $) {	'use strict';

var wgCanonicalSpecialPageName = mw.config.get('wgCanonicalSpecialPageName'), wgNamespaceNumber = mw.config.get('wgNamespaceNumber'), wgSkin = mw.config.get('skin');

// redirect Specal:Chat to Oasis (function 	{		var			query, t;

if ((wgCanonicalSpecialPageName === 'Chat') &&	(wgSkin !== 'oasis')) {			query = location.search.slice(1).split('&'); if ((query.length === 1) && (query[0].length === 0)) {			 query = []; }			t = query.filter(function (v)			{	 		return (v.search(/^useskin=/) === 0);			}); if ((t.length === 1) && (t[0] === 'useskin=oasis')) {		 	return; // error, prevent infinite loop }			query = query.filter(function (v)			{		 	return (v.search(/^useskin=/) !== 0);			}); query.push('useskin=oasis'); location.search = '?' + query.join('&'); }	});

// add classes to closed and highlighted thread items if (wgNamespaceNumber === 2000) {		$(function 		{			$('.ThreadList > .thread').each(function {				var li = $(this);

$.post(mw.util.wikiScript('wikia'),				{					controller: 'Forum',					method: 'brickHeader',					id: li.data('id'),					format: 'json'				}, function (data)				{					if (data.isClosed)					{						li.addClass('g-closed');					}					if (data.isNotifyeveryone)					{						li.addClass('g-highlight');					}				}); });		});	}

$(function 	{		// insert tab for tab key event in edit areas		$('#wpTextbox1').keydown(function (e) {			var s = this.selectionStart, t = this.scrollTop, v = this.value;

if (e.keyCode === 9) {				e.preventDefault; this.value = v.substr(0, s) + '\t' + v.substr(this.selectionEnd); this.scrollTop = t;				this.selectionStart = this.selectionEnd = s + 1; }		});	}); }(mediaWiki, jQuery));