Anonymous

Changes

From CUGC Wiki

MediaWiki:Common.js

39 bytes removed, 16:40, 12 March 2019
Use MutationObserver to detect when $content is added to the DOM.
/* Any JavaScript here will be loaded for all users on every page load. */
// MathJax typesetting in edit previewsmw.hook('wikipage.content').add(function mathJaxTypeset($content) { var observer = new MutationObserver(function waitForMathJax(mutations) { if (typeof MathJax === 'undefined'document.contains($content)) { setTimeoutconsole.log(waitForMathJax, 1000"It's in the DOM!"); console// using $content directly throws errors MathJax.Hub.logQueue('Waiting for ["Typeset", MathJax.'Hub, document.getElementById("wikiPreview")]).execute(); observer.disconnect();
} else {
console.log($content); // delay as wikipage.content is fired before $content is added to the page setTimeout(MathJax.Hub.Queue(["TypesetStill waiting", MathJax.Hub, "wikiPreview"]).execute, 1000); console.log('Found MathJax; typeset done.');
}
}); waitForMathJaxobserver.observe(document, {attributes: false, childList: true, characterData: false, subtree: true});}mw.hook('wikipage.content').add(mathJaxTypeset);