User:Thundercraft5/CodeFiddle.js

mw.loader.using(['mediawiki.widgets', 'mediawiki.widgets.SearchInputWidget'], function {	if (mw.config.get('wgPageName') !== 'Special:CodeFiddle') return;	document.title = 'Wiki Code Fiddle | ' + mw.config.get('wgSiteName') + ' | Fandom';	var wikiHref = mw.config.get('wgServer') + mw.config.get('wgArticlePath').replace(/\$1/, );	var wikiHrefText = wikiHref.replace(/^.*?:\/{2}/, );	var titleInput = new mw.widgets.TitleInputWidget({ id: "code-fiddle-searchtitle", });	var $frame = $(' ', { id: "code-fiddle-output-frame", class: "empty", });	var childWindow;	titleInput.on('enter', => { $frame .removeClass('empty') .attr('src', wikiHref + encodeURIComponent(titleInput.getValue) + '?useskin=FandomDesktop&noexternals=1'); setFrameLoading; });	function setFrameLoading {		$('.code-fiddle-frame-wrapper').addClass('loading');		$frame.one('load', => { childWindow = $frame[0].contentWindow; $('.code-fiddle-frame-wrapper').removeClass('loading'); injectEditorCSS; });	}	function blockFrameLoad {		childWindow.stop;		$('.code-fiddle-frame-wrapper').removeClass('loading');	}	function injectEditorCSS {		var style = $(' ', { text: cssEditor.getValue, type: "text/css", });		$(childWindow.document.head).append(style);	}	$('body')		.find('.main-container, .code-fiddle')			.remove		.end		.prepend($(' ', {			class: "code-fiddle",			html: [				$(' ', { class: "code-fiddle-sidebar", html: [ $(' ', {							class: "code-fiddle-header",							html: [								$(' ', { html: "Wiki Code Fiddle", }),							],						}),						$(' ', {							class: "code-fiddle-editor-wrapper",							html: $(' ', { class: "code-fiddle-editor", }),						}),					],				}),				$(' ', {					class: "code-fiddle-output-wrapper", html: $(' ', {						html: [							$(' ', { class: "code-fiddle-output-header-wrapper", html: $(' ', { 									text: "Code Fiddle Output",									class: "code-fiddle-output-header",								}), }),							$(' ', {								class: "code-fiddle-addressbar", html: [ $(' ', {										class: "code-fiddle-wiki-wrapper",										html: [											$(' ', { class: "code-fiddle-favicon", html: $(' ', { src: $('link[rel="shortcut icon"]').attr('href'), }), }),											$('', { class: "code-fiddle-wiki", href: wikiHref, text: wikiHrefText, title: wikiHref, target: "_blank", }),										],									}),									$(' ', {										class: "code-fiddle-input-wrapper",										html: titleInput.$element,									}), $(' ', {										class: "code-fiddle-addressbar-controls",										html: [											$(' ', { class: "code-fiddle-reload", html: ' ', }),											$(' ', {												class: "code-fiddle-stop", html: ' ', }),										],									}),								],							}),							$(' ', {								class: "code-fiddle-frame-wrapper", html: [ $frame, $(' ', {										class: "code-fiddle-frame-overlay",										html: $(' ', { class: "fandom-spinner code-fiddle-frame-spinner", html: '  ', }),									}),								],							}),						],					}),				}),			],		}));	// Setup editors	var cssEditor = ace.edit($('.code-fiddle-editor')[0]);	ace.config.set('basePath', '/extensions-ucp/CodeEditor/modules/ace');	cssEditor.session.setMode(new (ace.require("ace/mode/css").Mode));	$('.code-fiddle-reload').click(function { childWindow.location.reload; setFrameLoading; });	$('.code-fiddle-stop').click(function { blockFrameLoad; });	cssEditor.resize; });