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

/* articles, includes blogs (#wpTextbox1) keydown, keypress either is reliable

new Wikia blog comments, includes article comments? (#article-comm) keydown, keypress only keypress produces reliable behavior

edits to Wikia blog comments ** unknown ** dynamically generated textarea

new replies to Wikia blog comments (#article-comm-reply-textfield- ) ** unknown ** dynamically generated textarea

edits to replies to Wikia blog comments ** unknown ** dynamically generated textarea

new Wikia threads (#Wall .body) keydown, keypress either is reliable, both eat tabs

edits to Wikia threads ** unknown ** dynamically generated textarea

new replies to Wikia threads (#Wall .replyBody) keydown; keypress if textarea is empty keydown requires stopPropagation

edits to replies to Wikia threads ** unknown ** dynamically generated textarea $(function 	{		// insert tab for tab key event in edit areas		$('#wpTextbox1,'  + // articles '#Wall .body,'  + // new Wikia threads '#Wall .replyBody' // new replies to Wikia threads ).keydown(function (e) {			var s = this.selectionStart, t = this.scrollTop, v = this.value;

if (e.keyCode === 9) {				e.preventDefault; if (typeof e.stopPropagation === 'function') { // required for replies to Wikia threads e.stopPropagation; }				this.value = v.substr(0, s) + '\t' + v.substr(this.selectionEnd); this.scrollTop = t;				this.selectionStart = this.selectionEnd = s + 1; }		});	}); }(mediaWiki, jQuery));