User:Thundercraft5/ModuleIDE.js

/* jshint undef:true */ $.when(	$.get('/load.php?mode=articles&only=styles&articles=User:Thundercraft5/ModuleIDE.css/active.css'),	$.get('/load.php?mode=articles&only=styles&articles=User:Thundercraft5/ModuleIDE.css'),	$.Deferred(def => { let int = setInterval( => {			if ($('#debugConsole').length) def.resolve, clearInterval(int);			}); }) ).then((activeStyles, styles) => {	let style = $(mw.util.addCSS(activeStyles[0]).ownerNode).remove;	mw.util.addCSS(styles[0]);	let oldX, oldY;	mw.hook('dev.cgnb.change').add(collapsed => { let interval = setInterval( => {			ace.editor.resize;		}, 0); ace.editor.interval = interval; });	$('.global-navigation').on('trasitionend', => { clearInterval(ace.editor.interval); delete ace.editor.interval; });	let bodyStyles = getComputedStyle(document.documentElement);	let height = bodyStyles.getPropertyValue("--codeEditor-height").trim;

ui: { $('.page-side-tools').append($(' ', { html: $(' ', {				class: "wds-icon",				html: $(" ", { "xlink:href": "#wds-icons-zoom-in", html: ' ', }),			}),			click { oldX = window.scrollX; oldY = window.scrollY; window.scrollTo(0, 0); $([ace.editor.container, $('.ui-resizable')[0]]).css({					position: "absolute",					height,				}); style.appendTo('head'); ace.editor.resize; },			title: "Enter Code Editor fullscreen", class: "page-side-tool codeeditor-fullscreen", "data-wds-tooltip": "Collapse", "data-wds-tooltip-position": "right", "data-tooltip-attached": 1, }));		$('.codeEditor-status-message').append($(' ', { for: "codeeditor-consoletoggle", class: "codeeditor-consoletoggle-label", title: "Toggle Debug Console [alt-shift-d]", accesskey: "d", }));		$('#mw-scribunto-console').before($(' ', { id: "codeeditor-consoletoggle", name: "codeeditor-consoletoggle", type: "checkbox", class: "wds-is-hidden", change { $('.mw-editform').toggleClass('codeeditor-console-open'); },		}));	}	events: { $(window).on('keyup', e => {			if (e.key.toLowerCase === "escape") {				window.scrollTo(oldX, oldY);				style.remove;				$([ace.editor.container, $('.ui-resizable')[0]]).css({ position: "relative", height, });				ace.editor.resize;			}		}); }	scrollStyles: { let styles = window.getComputedStyle($('#mw-scribunto-output')[0]); let borderHeight = parseInt(styles.borderTopWidth) + parseInt(styles.borderBottomWidth); $('#mw-scribunto-output')[0].addEventListener('scroll', function {			let $this = $(this);			if (-Math.floor(this.scrollTop) < 5) 				$this.addClass('scroll-bottom').removeClass('scroll-top');			else if (Math.ceil(Math.floor((-$this.scrollTop)) + borderHeight + $this.innerHeight) + 5 > this.scrollHeight) 				$this.addClass('scroll-top').removeClass('scroll-bottom');			else $this.removeClass('scroll-bottom').removeClass('scroll-top');		}, { passive: true }); }	var worker = new Worker('https://hypixel-skyblock.fandom.com/wiki/User:Thundercraft5/ModuleIDE.js/formatter-worker.js?action=raw&ctype=text/javascript');

$('.ve-fd-header__title').after($(' ', { class: "LT-format", title: "Format the code in this Module", click { let text = ace.editor.getValue; let curLine = ace.editor.getCursorPosition; var options = { lineWidth: 120, indentCount: 1, useTabs: true, };			worker.postMessage({ type: "format", text, options }); worker.addEventListener('message', e => {				ace.editor.setValue(e.data.text);				ace.editor.clearSelection;				ace.editor.moveCursorToPosition(curLine);				ace.editor.scrollToLine(curLine.row, true, true, function {});			}, { once: true }); },	}));	let el = document.getElementById('mw-scribunto-output'); let $el = $(el); new MutationObserver(function(mutations, observer) {		if (el.scrollHeight > el.clientHeight) $el.addClass('scroll-visible');		else $el.removeClass('scroll-visible');	}).observe(el, {		subtree: true,		childList: true,	}); });