Difference between revisions of "MediaWiki:Common.js"
From CUGC Wiki
(Wait for MathJax before typesetting.) |
(See if MathJax can typeset detached elements.) |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
− | function | + | mw.hook('wikipage.content').add(function ($content) { |
if (typeof MathJax === 'undefined') { | if (typeof MathJax === 'undefined') { | ||
setTimeout(waitForMathJax, 1000); | setTimeout(waitForMathJax, 1000); | ||
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[0]).execute(); |
console.log('Found MathJax; typeset done.'); | console.log('Found MathJax; typeset done.'); | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
}); | }); |
Revision as of 16:52, 12 March 2019
/* Any JavaScript here will be loaded for all users on every page load. */ mw.hook('wikipage.content').add(function ($content) { if (typeof MathJax === 'undefined') { setTimeout(waitForMathJax, 1000); console.log('Waiting for MathJax.'); } else { MathJax.Hub.Queue(["Typeset", MathJax.Hub, $content[0]).execute(); console.log('Found MathJax; typeset done.'); } });