User:Superwatery/wikia.js

/*Useful scripts-*/

/*I don't want to add a new topic, I wanted to edit the article talk page, so this one solves the problem*/ (function {   if (mw.config.get('wgNamespaceNumber') !== 1) return;    $('#ca-addsection').each(function { var copy_to = $('#ca-edit').attr('class', 'wds-button').clone(true); var copy_from = $(this).removeAttr('class').clone(true); $('#ca-edit').replaceWith(copy_from); $(this).replaceWith(copy_to); }); }); /*Determines the article area's background color and returns it as a string in the format of a CSS color value.*Determines the article area's background color and returns it as a string in the format of a CSS color value.*/ function getBackgroundColor { var bgColor = $('#WikiaPageBackground').css('background-color'); if (bgColor === 'transparent') { bgColor = $('#WikiaPage').css('background-color'); }   if (bgColor === 'transparent') { bgColor = $('#EditPageHeader').css('background-color'); }   return bgColor; }

/*!bang*/ $('.wds-global-navigation__search-input').on('keyup', function{	var txt = $(this).val,		m = txt.match(/^\!([a-z]+) /),		namespaces;	if (m) {		namespaces = {			t: "Template",			mw: "MediaWiki",			s: "Special",			h: "Help",			m: "Module",			f: "File",			u: "User",			p: "Project",			c: "Category",			me: "Message Wall",			/* Message Wall Greeting is required*/			mwg: "Message Wall Greeting",			/*Adoption is a custom namespace at Community Central*/			a: "Adoption",			b: "Bot scan",			f: "Forum",			ac: "Admin Central"		};		if (namespaces.hasOwnProperty(m[1])) {			$(this).val(namespaces[m[1]] + ":" + txt.substr(m[1].length + 2));		}	} });

/*Random but useless javascripts!-- //var Applemasterexpert = 38; //var RandomPerson = 12; //if (Applemasterexpert > RandomPerson) { //  alert("Applemasterexpert is the winner!") //} if (wgNamespace === 0) { alert("Sorry, Article namespace cannot be edited!") }