diff options
author | mcarrier <mcarrier@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-11-07 09:10:45 +0000 |
---|---|---|
committer | mcarrier <mcarrier@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-11-07 09:10:45 +0000 |
commit | 3182c852e0cfbb772dfe27e30647034d9fa35a32 (patch) | |
tree | 38238e83ae2b13bc1d2c9c728a6da4a2dffee7c0 /src/common/doc/MathJax.js | |
parent | 9cb300d538a4466df50927cf31de3c06e914cb90 (diff) | |
parent | 20dce046a003850f49c4e1d995348bc8e4cef85b (diff) |
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/Nerve_GIC@2838 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: aa674c458f110c5c7cc3f5c987b921fcc96e3e7e
Diffstat (limited to 'src/common/doc/MathJax.js')
-rw-r--r-- | src/common/doc/MathJax.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/common/doc/MathJax.js b/src/common/doc/MathJax.js new file mode 100644 index 00000000..35e1994e --- /dev/null +++ b/src/common/doc/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 |