MediaWiki:ImportJS-Plus.js

/* ImportJS-Plus by Sophiedp */ /** With code and help from dev.wikia.com, Kocka, and many others **/

//Only run on MediaWiki:ImportJS if (mw.config.get('wgPageName') === 'MediaWiki:ImportJS') { //If editing if (mw.config.get('wgAction') === 'edit') {

$('body').addClass('code-editor'); window.codePageType = 'ruby';

//Load required resources mw.loader.implement('dev.ace', [			mw.config.get('wgServer') + '/resources/Ace/ace.js',			'https://slot1-images.wikia.nocookie.net/__am/1432570822/group/-/ace_editor_js'		], {}, {});

mw.loader.using(['dev.ace'], function {			//Initialise the editor			require(['wikia.editpage.ace.editor'], function(aceEditor) { aceEditor.init;

//Remove stuff we don't need $('.cke_toolbar_source > *, .preview_box, .rail-auto-height, .diff-link').remove; //Fix height on toolbar for wide screens $('.cke_toolbar_source').css({'height':'18px', 'border':'none'}); //Center the edit summary $('#wpSummary').css('margin-top', '5px'); //Make editor take whole screen width $('.mediawiki #WikiaPage').css({'border':'none !important', 'width':'100%'}); //Hide the right rail $(".editpage-widemode-trigger").click; });		});	//If not editing } else {

$('pre').addClass('ruby');

//Import the highlighter var script = document.createElement('script'); script.src = 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js'; document.getElementsByTagName('head')[0].appendChild(script); //Import the styles var style = document.createElement('link'); style.href = 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/vs2015.min.css'; style.type = 'text/css'; style.rel = 'stylesheet'; document.getElementsByTagName('head')[0].appendChild(style); //Initialise the highlighter setTimeout(run, 500); function run { $('pre').each(function(i, block) {				hljs.highlightBlock(block);			}); //Hide syntax colors in the middle of another color $('.hljs-number').css('color', 'inherit'); }		//Fix for light themed wikis $('body:not(.page-dark) > .WikiaSiteWrapper pre:not(span)').css('color', 'black'); //Highlight the end of the line $('pre').html($('pre').html.replace(/(\/(?!span).*\.js|\.js)/g, "$1 ")); } }