latexToMathJax.js 988 B

1
  1. function afterLoad(){$("img").each(function(index){if(/^data:image/.test(this.src)){return}if(this.src.indexOf("http://")==-1){}else{if(this.src.indexOf("gif.latex")>=0||this.src.indexOf("mathtex.cgi")>=0||this.src.indexOf(".gif?")>=0){var latex=unescape(this.src.substring(this.src.indexOf("?")+1));$(this).replaceWith("<span class='latex'>\\(\n"+latex.replace(/</,"< ")+"\n\\)</span>")}}});if($(".latex").length==0){return}var script=document.createElement("script");script.type="text/javascript";script.src="/js/min/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML";document.getElementsByTagName("head")[0].appendChild(script);var intervalId=setInterval(function(){var latex=$(".latex");if(latex.length==0){clearInterval(intervalId);$(".mtext").remove();$("#loading").remove();return}latex.each(function(){if($(this).find(".MathJax_Preview").html()==""){var elt=this;$(elt).removeClass("latex")}})},50)}$(function(){$("head").append("<style>.latex{display:none}</style>");afterLoad()});