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');					}				}); });		});	}

/* dynamically generated textarea currently not supported edits to Wikia blog comments new replies to Wikia blog comments (#article-comm-reply-textfield- ) edits to replies to Wikia blog comments edits to Wikia threads edits to replies to Wikia threads // insert tab for tab key event in edit areas // however, because of Event.timeStamp, //  it's broken in IE 8 and earlier //  and might be broken in Chrome 49 and later $(function 	{		var			t = 0;

function tab(textarea) {			var s = textarea.selectionStart, t = textarea.scrollTop, v = textarea.value;

textarea.value = v.substr(0, s) + '\t' + v.substr(textarea.selectionEnd); textarea.scrollTop = t;			textarea.selectionStart = textarea.selectionEnd = s + 1; }

$('#wpTextbox1,'     + // articles, includes Wikia blogs			'#Wall .body,'      + // new Wikia threads			'#Wall .replyBody,' + // new replies to Wikia threads			'#article-comm'       // new Wikia blog comments (and article comments?)		).keydown(function (e)		{			var				epoch = e.timeStamp;

if (e.keyCode === 9) {				e.preventDefault; if (typeof e.stopPropagation === 'function') { // required for replies to Wikia threads e.stopPropagation; }				if (epoch !== t)				{ tab(this); t = epoch; }			}		}).keypress(function (e) {			var epoch = e.timeStamp;

if (e.keyCode === 9) {				e.preventDefault; if (epoch !== t)				{ tab(this); t = epoch; }			}		});	}); }(mediaWiki, jQuery));