diff options
author | Gard Spreemann <gspreemann@gmail.com> | 2017-10-09 10:49:16 +0200 |
---|---|---|
committer | Gard Spreemann <gspreemann@gmail.com> | 2017-10-09 10:49:16 +0200 |
commit | 45e3a8bfb4fbf73ab9a093fa12816dbe0591e606 (patch) | |
tree | c484e1832e483cd605062b33574d27c62040db4d /doc/common/MathJax.js | |
parent | bb096655608534feb76f275960fe85cefe08c5f0 (diff) | |
parent | 673b6bb63befd7e591e52c13f43e5db53e5b29bd (diff) |
Merge branch 'dfsg/latest' into debian/sid
Diffstat (limited to 'doc/common/MathJax.js')
-rw-r--r-- | doc/common/MathJax.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/doc/common/MathJax.js b/doc/common/MathJax.js new file mode 100644 index 00000000..35e1994e --- /dev/null +++ b/doc/common/MathJax.js @@ -0,0 +1,53 @@ +(function () { + var newMathJax = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js'; + var oldMathJax = 'cdn.mathjax.org/mathjax/latest/MathJax.js'; + + var replaceScript = function (script, src) { + // + // Make redirected script + // + var newScript = document.createElement('script'); + newScript.src = newMathJax + src.replace(/.*?(\?|$)/, '$1'); + // + // Move onload and onerror handlers to new script + // + newScript.onload = script.onload; + newScript.onerror = script.onerror; + script.onload = script.onerror = null; + // + // Move any content (old-style configuration scripts) + // + while (script.firstChild) newScript.appendChild(script.firstChild); + // + // Copy script id + // + if (script.id != null) newScript.id = script.id; + // + // Replace original script with new one + // + script.parentNode.replaceChild(newScript, script); + // + // Issue a console warning + // + console.warn('WARNING: cdn.mathjax.org has been retired. Check https://www.mathjax.org/cdn-shutting-down/ for migration tips.') + } + + if (document.currentScript) { + var script = document.currentScript; + replaceScript(script, script.src); + } else { + // + // Look for current script by searching for one with the right source + // + var n = oldMathJax.length; + var scripts = document.getElementsByTagName('script'); + for (var i = 0; i < scripts.length; i++) { + var script = scripts[i]; + var src = (script.src || '').replace(/.*?:\/\//,''); + if (src.substr(0, n) === oldMathJax) { + replaceScript(script, src); + break; + } + } + } +})();
\ No newline at end of file |