Difference between revisions of "MediaWiki:Common.js"
From CUGC Wiki
(Wait for MathJax; debugging.) |
(Use $content as #wikiPreview is not available when hook is fired.) |
||
Line 2: | Line 2: | ||
// MathJax typesetting in edit previews | // MathJax typesetting in edit previews | ||
− | function mathJaxTypeset() { | + | function mathJaxTypeset($content) { |
function waitForMathJax() { | function waitForMathJax() { | ||
if (typeof MathJax === 'undefined') { | if (typeof MathJax === 'undefined') { | ||
Line 8: | Line 8: | ||
console.log('Waiting for MathJax.'); | console.log('Waiting for MathJax.'); | ||
} else { | } else { | ||
− | MathJax.Hub.Queue(["Typeset", MathJax.Hub, | + | MathJax.Hub.Queue(["Typeset", MathJax.Hub, $content]).execute(); |
alert('Found MathJax; typeset done.'); | alert('Found MathJax; typeset done.'); | ||
} | } |
Revision as of 16:23, 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 { MathJax.Hub.Queue(["Typeset", MathJax.Hub, $content]).execute(); alert('Found MathJax; typeset done.'); } } waitForMathJax(); } mw.hook('wikipage.content').add(mathJaxTypeset);