Difference between revisions of "MediaWiki:Common.js"
From CUGC Wiki
(Wait for $content to be added to page.) |
(Don't use $content as there are errors in MathJax using it (TypeError: c.nodeName is undefined).) |
||
Line 10: | Line 10: | ||
console.log($content); | console.log($content); | ||
// delay as wikipage.content is fired before $content is added to the page | // delay as wikipage.content is fired before $content is added to the page | ||
− | setTimeout(MathJax.Hub.Queue(["Typeset", MathJax.Hub, | + | setTimeout(MathJax.Hub.Queue(["Typeset", MathJax.Hub, "wikiPreview"]).execute, 1000); |
console.log('Found MathJax; typeset done.'); | console.log('Found MathJax; typeset done.'); | ||
} | } |
Revision as of 16:27, 12 March 2019
/* Any JavaScript here will be loaded for all users on every page load. */ // MathJax typesetting in edit previews function mathJaxTypeset($content) { function waitForMathJax() { if (typeof MathJax === 'undefined') { setTimeout(waitForMathJax, 1000); console.log('Waiting for MathJax.'); } else { console.log($content); // delay as wikipage.content is fired before $content is added to the page setTimeout(MathJax.Hub.Queue(["Typeset", MathJax.Hub, "wikiPreview"]).execute, 1000); console.log('Found MathJax; typeset done.'); } } waitForMathJax(); } mw.hook('wikipage.content').add(mathJaxTypeset);