User:Superwatery/wikia.js

/*I don't want to add a new topic, I wanted to edit the article talk page, so this one solves the problem*/ qwebirc //Please be reminded that talk pages are always odd numbered

(function {   if (mw.config.get('wgNamespaceNumber') !== 1, 3, 5, 7, 9, 11, 13, 119) 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", /* !a seems to not work... */ 			b: "Bot scan",			f: "Forum",			ac: "Admin Central",			m: "Media"			abuse: "Special:AbuseLog"		};		if (namespaces.hasOwnProperty(m[1])) {			$(this).val(namespaces[m[1]] + /*This adds a colon after the namespace*/ ":" + txt.substr(m[1].length + 2));		}	} }); /*Responsive mobile*/

$('head').append('');

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:ContribRC/code.js',        'u:dev:MediaWiki:CodeQuickLinks/code.js',        'u:dev:MediaWiki:CodeSelectAll.js',    ] });

window.customCodeQuickLinks= { replaceAllDefaultLinks: true, linkSet: { siteFiles: [ {               name: "JSPages", href: "/wiki/Special:JSPages" },           {                name: "ImportJS", href: "/wiki/MediaWiki:ImportJS" }       ],        userFiles: [ {               name: "Global.js", href: "//c.wikia.com/wiki/Special:MyPage/global.js" },           {                name: "Global.css", href: "//c.wikia.com/wiki/Special:MyPage/global.css" }       ]    } };

mw.hook("wikipage.content").add(function($content) {   // code to run }); /*Caches a reference to an mw.Api object instance. For more info, see MediaWiki documentation.*/ var api = new mw.Api;

if(mw.config.get('Example_Page')){ //if the page currently loaded on the wiki is named 'Example Page' this code will be ran var inputBox = document.createElement("div");//create the a div element that will store the input box var input = document.createElement("input");//create a input element that will get the input entered input.id = "input";//set the id to the input element to "input" input.style.display = "inline-block";//set the style.display to "inline-block" so it will all be in one line var textParagraph = document.createElement("p");//create a text paragraph textParagraph.innerHTML = "times two is: ";//set the default text to the paragraph textParagraph.style.display="inline-block";//set the style.display to "inline-block" so it will all be in one line textParagraph.id = "textParagraph";//set the id to the textParagraph element to "textParagraph" var newLine = document.createElement("br");//create a br element to start a new line var getAnswer = document.createElement("button");//create the check button getAnswer.innerHTML = "Check";//set the text on the button to "Check" getAnswer.addEventListener("click", function{ document.getElementById("textParagraph").innerHTML= "times two is: "+document.getElementById("input").value*2;  });//add a event listener to the button that will set the text to the textParagraph element to "times two is: (whatever it is)" when it is clicked inputBox.appendChild(textParpendChild(input);//add the input element to the input box inputBox.appendChild(textParagraph);//add the textParagraph element to the input box  inputBox.appendChild(newLine);//add the new line element to the input box  inputBox.appendChild(getAnswer);//add the getAnswer button element to the input box  document.getElementById("mw-content-text").appendChild(inputBox);//add the input box to the main page content }