diff --git a/MathJax.js b/MathJax.js index c045efe85..8d81dfe39 100644 --- a/MathJax.js +++ b/MathJax.js @@ -26,5 +26,5 @@ if (!window.MathJax) {window.MathJax = {}} MathJax.isPacked = true; -if(document.getElementById&&document.childNodes&&document.createElement){if(!window.MathJax){window.MathJax={}}if(!MathJax.Hub){MathJax.version="1.1.5";(function(d){var b=window[d];if(!b){b=window[d]={}}var f=[];var c=function(g){var h=g.constructor;if(!h){h=new Function("")}for(var i in g){if(i!=="constructor"&&g.hasOwnProperty(i)){h[i]=g[i]}}return h};var a=function(){return new Function("return arguments.callee.Init.call(this,arguments)")};var e=a();e.prototype={bug_test:1};if(!e.prototype.bug_test){a=function(){return function(){return arguments.callee.Init.call(this,arguments)}}}b.Object=c({constructor:a(),Subclass:function(g,i){var h=a();h.SUPER=this;h.Init=this.Init;h.Subclass=this.Subclass;h.Augment=this.Augment;h.protoFunction=this.protoFunction;h.can=this.can;h.has=this.has;h.isa=this.isa;h.prototype=new this(f);h.prototype.constructor=h;h.Augment(g,i);return h},Init:function(g){var h=this;if(g.length===1&&g[0]===f){return h}if(!(h instanceof g.callee)){h=new g.callee(f)}return h.Init.apply(h,g)||h},Augment:function(g,h){var i;if(g!=null){for(i in g){if(g.hasOwnProperty(i)){this.protoFunction(i,g[i])}}if(g.toString!==this.prototype.toString&&g.toString!=={}.toString){this.protoFunction("toString",g.toString)}}if(h!=null){for(i in h){if(h.hasOwnProperty(i)){this[i]=h[i]}}}return this},protoFunction:function(h,g){this.prototype[h]=g;if(typeof g==="function"){g.SUPER=this.SUPER.prototype}},prototype:{Init:function(){},SUPER:function(g){return g.callee.SUPER},can:function(g){return typeof(this[g])==="function"},has:function(g){return typeof(this[g])!=="undefined"},isa:function(g){return(g instanceof Object)&&(this instanceof g)}},can:function(g){return this.prototype.can.call(this,g)},has:function(g){return this.prototype.has.call(this,g)},isa:function(h){var g=this;while(g){if(g===h){return true}else{g=g.SUPER}}return false},SimpleSUPER:c({constructor:function(g){return this.SimpleSUPER.define(g)},define:function(g){var i={};if(g!=null){for(var h in g){if(g.hasOwnProperty(h)){this.protoFunction(h,g[h])}}if(g.toString!==this.prototype.toString&&g.toString!=={}.toString){this.protoFunction("toString",g.toString)}}return i},wrap:function(i,h){if(typeof(h)==="function"&&h.toString().match(/\.\s*SUPER\s*\(/)){var g=new Function(this.wrapper);g.label=i;g.original=h;h=g;g.toString=this.stringify}return h},wrapper:function(){var h=arguments.callee;this.SUPER=h.SUPER[h.label];try{var g=h.original.apply(this,arguments)}catch(i){delete this.SUPER;throw i}delete this.SUPER;return g}.toString().replace(/^\s*function \(\)\s*\{\s*/i,"").replace(/\s*\}\s*$/i,""),toString:function(){return this.original.toString.apply(this.original,arguments)}})})})("MathJax");(function(BASENAME){var BASE=window[BASENAME];if(!BASE){BASE=window[BASENAME]={}}var CALLBACK=function(data){var cb=new Function("return arguments.callee.execute.apply(arguments.callee,arguments)");for(var id in CALLBACK.prototype){if(CALLBACK.prototype.hasOwnProperty(id)){if(typeof(data[id])!=="undefined"){cb[id]=data[id]}else{cb[id]=CALLBACK.prototype[id]}}}cb.toString=CALLBACK.prototype.toString;return cb};CALLBACK.prototype={isCallback:true,hook:function(){},data:[],object:window,execute:function(){if(!this.called||this.autoReset){this.called=!this.autoReset;return this.hook.apply(this.object,this.data.concat([].slice.call(arguments,0)))}},reset:function(){delete this.called},toString:function(){return this.hook.toString.apply(this.hook,arguments)}};var ISCALLBACK=function(f){return(typeof(f)==="function"&&f.isCallback)};var EVAL=function(code){return eval.call(window,code)};EVAL("var __TeSt_VaR__ = 1");if(window.__TeSt_VaR__){try{delete window.__TeSt_VaR__}catch(error){window.__TeSt_VaR__=null}}else{if(window.execScript){EVAL=function(code){BASE.__code=code;code="try {"+BASENAME+".__result = eval("+BASENAME+".__code)} catch(err) {"+BASENAME+".__result = err}";window.execScript(code);var result=BASE.__result;delete BASE.__result;delete BASE.__code;if(result instanceof Error){throw result}return result}}else{EVAL=function(code){BASE.__code=code;code="try {"+BASENAME+".__result = eval("+BASENAME+".__code)} catch(err) {"+BASENAME+".__result = err}";var head=(document.getElementsByTagName("head"))[0];if(!head){head=document.body}var script=document.createElement("script");script.appendChild(document.createTextNode(code));head.appendChild(script);head.removeChild(script);var result=BASE.__result;delete BASE.__result;delete BASE.__code;if(result instanceof Error){throw result}return result}}}var USING=function(args,i){if(arguments.length>1){if(arguments.length===2&&!(typeof arguments[0]==="function")&&arguments[0] instanceof Object&&typeof arguments[1]==="number"){args=[].slice.call(args,i)}else{args=[].slice.call(arguments,0)}}if(args instanceof Array&&args.length===1){args=args[0]}if(typeof args==="function"){if(args.execute===CALLBACK.prototype.execute){return args}return CALLBACK({hook:args})}else{if(args instanceof Array){if(typeof(args[0])==="string"&&args[1] instanceof Object&&typeof args[1][args[0]]==="function"){return CALLBACK({hook:args[1][args[0]],object:args[1],data:args.slice(2)})}else{if(typeof args[0]==="function"){return CALLBACK({hook:args[0],data:args.slice(1)})}else{if(typeof args[1]==="function"){return CALLBACK({hook:args[1],object:args[0],data:args.slice(2)})}}}}else{if(typeof(args)==="string"){return CALLBACK({hook:EVAL,data:[args]})}else{if(args instanceof Object){return CALLBACK(args)}else{if(typeof(args)==="undefined"){return CALLBACK({})}}}}}throw Error("Can't make callback from given data")};var DELAY=function(time,callback){callback=USING(callback);callback.timeout=setTimeout(callback,time);return callback};var WAITFOR=function(callback,signal){callback=USING(callback);if(!callback.called){WAITSIGNAL(callback,signal);signal.pending++}};var WAITEXECUTE=function(){var signals=this.signal;delete this.signal;this.execute=this.oldExecute;delete this.oldExecute;var result=this.execute.apply(this,arguments);if(ISCALLBACK(result)&&!result.called){WAITSIGNAL(result,signals)}else{for(var i=0,m=signals.length;i0&&priorityf){f=document.styleSheets.length}if(!h){h=(document.getElementsByTagName("head"))[0];if(!h){h=document.body}}return h};var e=[];var b=function(){for(var j=0,h=e.length;j=this.timeout){h(this.STATUS.ERROR);return 1}return 0},file:function(i,h){if(h<0){a.Ajax.loadTimeout(i)}else{a.Ajax.loadComplete(i)}},execute:function(){this.hook.call(this.object,this,this.data[0],this.data[1])},checkSafari2:function(h,i,j){if(h.time(j)){return}if(document.styleSheets.length>i&&document.styleSheets[i].cssRules&&document.styleSheets[i].cssRules.length){j(h.STATUS.OK)}else{setTimeout(h,h.delay)}},checkLength:function(h,k,m){if(h.time(m)){return}var l=0;var i=(k.sheet||k.styleSheet);try{if((i.cssRules||i.rules||[]).length>0){l=1}}catch(j){if(j.message.match(/protected variable|restricted URI/)){l=1}else{if(j.message.match(/Security error/)){l=1}}}if(l){setTimeout(a.Callback([m,h.STATUS.OK]),0)}else{setTimeout(h,h.delay)}}},loadComplete:function(h){h=this.fileURL(h);var i=this.loading[h];if(i&&!i.preloaded){a.Message.Clear(i.message);clearTimeout(i.timeout);if(i.script){if(e.length===0){setTimeout(b,0)}e.push(i.script)}this.loaded[h]=i.status;delete this.loading[h];this.addHook(h,i.callback)}else{this.loaded[h]=this.STATUS.OK;i={status:this.STATUS.OK}}if(!this.loadHooks[h]){return null}return this.loadHooks[h].Execute(i.status)},loadTimeout:function(h){if(this.loading[h].timeout){clearTimeout(this.loading[h].timeout)}this.loading[h].status=this.STATUS.ERROR;this.loadError(h);this.loadComplete(h)},loadError:function(h){a.Message.Set("File failed to load: "+h,null,2000)},Styles:function(j,k){var h=this.StyleString(j);if(h===""){k=a.Callback(k);k()}else{var i=document.createElement("style");i.type="text/css";this.head=g(this.head);this.head.appendChild(i);if(i.styleSheet&&typeof(i.styleSheet.cssText)!=="undefined"){i.styleSheet.cssText=h}else{i.appendChild(document.createTextNode(h))}k=this.timer.create.call(this,k,i)}return k},StyleString:function(m){if(typeof(m)==="string"){return m}var j="",n,l;for(n in m){if(m.hasOwnProperty(n)){if(typeof m[n]==="string"){j+=n+" {"+m[n]+"}\n"}else{if(m[n] instanceof Array){for(var k=0;k1?d[1]:""));g=null}if(f&&(!b.preJax||d)){c.nodeValue=c.nodeValue.replace(b.postJax,(f.length>1?f[1]:""))}if(g&&!g.nodeValue.match(/\S/)){g=g.previousSibling}}if(b.preRemoveClass&&g&&g.className==b.preRemoveClass){try{g.innerHTML=""}catch(e){}g.style.display="none"}if(a.MathJax){a.MathJax.checked=1}},processInput:function(e,a,b){if(arguments.callee.disabled){return null}if(!a){a=new Date().getTime()}var k,j=MathJax.ElementJax.STATE;var f=0,h,c;try{while(fthis.processUpdateTime&&fthis.processUpdateTime&&g=0;o--){if(b[o].src.match(d)){q.script=b[o].innerHTML;if(RegExp.$2){var r=RegExp.$2.substr(1).split(/\&/);for(var n=0,h=r.length;n=parseInt(x[y])}}return true},Select:function(j){var i=j[c.Browser];if(i){return i(c.Browser)}return null}};var g=navigator.userAgent.replace(/^Mozilla\/(\d+\.)+\d+ /,"").replace(/[a-z][-a-z0-9._: ]+\/\d+[^ ]*-[^ ]*\.([a-z][a-z])?\d+ /i,"").replace(/Gentoo |Ubuntu\/(\d+\.)*\d+ (\([^)]*\) )?/,"");c.Browser=c.Insert(c.Insert(new String("Unknown"),{version:"0.0"}),a);for(var t in a){if(a.hasOwnProperty(t)){if(a[t]&&t.substr(0,2)==="is"){t=t.slice(2);if(t==="Mac"||t==="PC"){continue}c.Browser=c.Insert(new String(t),a);var p=new RegExp(".*(Version)/((?:\\d+\\.)+\\d+)|.*("+t+")"+(t=="MSIE"?" ":"/")+"((?:\\d+\\.)*\\d+)|(?:^|\\(| )([a-z][-a-z0-9._: ]+|(?:Apple)?WebKit)/((?:\\d+\\.)+\\d+)");var s=p.exec(g)||["","","","unknown","0.0"];c.Browser.name=(s[1]=="Version"?t:(s[3]||s[5]));c.Browser.version=s[2]||s[4]||s[6];break}}}c.Browser.Select({Safari:function(j){var i=parseInt((String(j.version).split("."))[0]);if(i>85){j.webkit=j.version}if(i>=533){j.version="5.0"}else{if(i>=526){j.version="4.0"}else{if(i>=525){j.version="3.1"}else{if(i>500){j.version="3.0"}else{if(i>400){j.version="2.0"}else{if(i>85){j.version="1.0"}}}}}}},Firefox:function(j){if(j.version==="0.0"&&navigator.product==="Gecko"&&navigator.productSub){var i=navigator.productSub.substr(0,8);if(i>="20090630"){j.version="3.5"}else{if(i>="20080617"){j.version="3.0"}else{if(i>="20061024"){j.version="2.0"}}}}},Opera:function(i){i.version=opera.version()},MSIE:function(i){i.isIE9=!!(document.documentMode&&(window.performance||window.msPerformance));MathJax.HTML.setScriptBug=!i.isIE9||document.documentMode<9}});c.Browser.Select(MathJax.Message.browsers);c.queue=f.Callback.Queue();c.queue.Push(["Post",q.signal,"Begin"],["Config",q],["Cookie",q],["Styles",q],function(){var i=f.Callback.Queue(q.Jax(),q.Extensions());return i.Push({})},["Menu",q],q.onLoad(),function(){MathJax.isReady=true},["Typeset",q],["Post",q.signal,"End"])})("MathJax")}}; +if(document.getElementById&&document.childNodes&&document.createElement){if(!window.MathJax){window.MathJax={}}if(!MathJax.Hub){MathJax.version="1.1.5";(function(d){var b=window[d];if(!b){b=window[d]={}}var f=[];var c=function(g){var h=g.constructor;if(!h){h=new Function("")}for(var i in g){if(i!=="constructor"&&g.hasOwnProperty(i)){h[i]=g[i]}}return h};var a=function(){return new Function("return arguments.callee.Init.call(this,arguments)")};var e=a();e.prototype={bug_test:1};if(!e.prototype.bug_test){a=function(){return function(){return arguments.callee.Init.call(this,arguments)}}}b.Object=c({constructor:a(),Subclass:function(g,i){var h=a();h.SUPER=this;h.Init=this.Init;h.Subclass=this.Subclass;h.Augment=this.Augment;h.protoFunction=this.protoFunction;h.can=this.can;h.has=this.has;h.isa=this.isa;h.prototype=new this(f);h.prototype.constructor=h;h.Augment(g,i);return h},Init:function(g){var h=this;if(g.length===1&&g[0]===f){return h}if(!(h instanceof g.callee)){h=new g.callee(f)}return h.Init.apply(h,g)||h},Augment:function(g,h){var i;if(g!=null){for(i in g){if(g.hasOwnProperty(i)){this.protoFunction(i,g[i])}}if(g.toString!==this.prototype.toString&&g.toString!=={}.toString){this.protoFunction("toString",g.toString)}}if(h!=null){for(i in h){if(h.hasOwnProperty(i)){this[i]=h[i]}}}return this},protoFunction:function(h,g){this.prototype[h]=g;if(typeof g==="function"){g.SUPER=this.SUPER.prototype}},prototype:{Init:function(){},SUPER:function(g){return g.callee.SUPER},can:function(g){return typeof(this[g])==="function"},has:function(g){return typeof(this[g])!=="undefined"},isa:function(g){return(g instanceof Object)&&(this instanceof g)}},can:function(g){return this.prototype.can.call(this,g)},has:function(g){return this.prototype.has.call(this,g)},isa:function(h){var g=this;while(g){if(g===h){return true}else{g=g.SUPER}}return false},SimpleSUPER:c({constructor:function(g){return this.SimpleSUPER.define(g)},define:function(g){var i={};if(g!=null){for(var h in g){if(g.hasOwnProperty(h)){this.protoFunction(h,g[h])}}if(g.toString!==this.prototype.toString&&g.toString!=={}.toString){this.protoFunction("toString",g.toString)}}return i},wrap:function(i,h){if(typeof(h)==="function"&&h.toString().match(/\.\s*SUPER\s*\(/)){var g=new Function(this.wrapper);g.label=i;g.original=h;h=g;g.toString=this.stringify}return h},wrapper:function(){var h=arguments.callee;this.SUPER=h.SUPER[h.label];try{var g=h.original.apply(this,arguments)}catch(i){delete this.SUPER;throw i}delete this.SUPER;return g}.toString().replace(/^\s*function \(\)\s*\{\s*/i,"").replace(/\s*\}\s*$/i,""),toString:function(){return this.original.toString.apply(this.original,arguments)}})})})("MathJax");(function(BASENAME){var BASE=window[BASENAME];if(!BASE){BASE=window[BASENAME]={}}var CALLBACK=function(data){var cb=new Function("return arguments.callee.execute.apply(arguments.callee,arguments)");for(var id in CALLBACK.prototype){if(CALLBACK.prototype.hasOwnProperty(id)){if(typeof(data[id])!=="undefined"){cb[id]=data[id]}else{cb[id]=CALLBACK.prototype[id]}}}cb.toString=CALLBACK.prototype.toString;return cb};CALLBACK.prototype={isCallback:true,hook:function(){},data:[],object:window,execute:function(){if(!this.called||this.autoReset){this.called=!this.autoReset;return this.hook.apply(this.object,this.data.concat([].slice.call(arguments,0)))}},reset:function(){delete this.called},toString:function(){return this.hook.toString.apply(this.hook,arguments)}};var ISCALLBACK=function(f){return(typeof(f)==="function"&&f.isCallback)};var EVAL=function(code){return eval.call(window,code)};EVAL("var __TeSt_VaR__ = 1");if(window.__TeSt_VaR__){try{delete window.__TeSt_VaR__}catch(error){window.__TeSt_VaR__=null}}else{if(window.execScript){EVAL=function(code){BASE.__code=code;code="try {"+BASENAME+".__result = eval("+BASENAME+".__code)} catch(err) {"+BASENAME+".__result = err}";window.execScript(code);var result=BASE.__result;delete BASE.__result;delete BASE.__code;if(result instanceof Error){throw result}return result}}else{EVAL=function(code){BASE.__code=code;code="try {"+BASENAME+".__result = eval("+BASENAME+".__code)} catch(err) {"+BASENAME+".__result = err}";var head=(document.getElementsByTagName("head"))[0];if(!head){head=document.body}var script=document.createElement("script");script.appendChild(document.createTextNode(code));head.appendChild(script);head.removeChild(script);var result=BASE.__result;delete BASE.__result;delete BASE.__code;if(result instanceof Error){throw result}return result}}}var USING=function(args,i){if(arguments.length>1){if(arguments.length===2&&!(typeof arguments[0]==="function")&&arguments[0] instanceof Object&&typeof arguments[1]==="number"){args=[].slice.call(args,i)}else{args=[].slice.call(arguments,0)}}if(args instanceof Array&&args.length===1){args=args[0]}if(typeof args==="function"){if(args.execute===CALLBACK.prototype.execute){return args}return CALLBACK({hook:args})}else{if(args instanceof Array){if(typeof(args[0])==="string"&&args[1] instanceof Object&&typeof args[1][args[0]]==="function"){return CALLBACK({hook:args[1][args[0]],object:args[1],data:args.slice(2)})}else{if(typeof args[0]==="function"){return CALLBACK({hook:args[0],data:args.slice(1)})}else{if(typeof args[1]==="function"){return CALLBACK({hook:args[1],object:args[0],data:args.slice(2)})}}}}else{if(typeof(args)==="string"){return CALLBACK({hook:EVAL,data:[args]})}else{if(args instanceof Object){return CALLBACK(args)}else{if(typeof(args)==="undefined"){return CALLBACK({})}}}}}throw Error("Can't make callback from given data")};var DELAY=function(time,callback){callback=USING(callback);callback.timeout=setTimeout(callback,time);return callback};var WAITFOR=function(callback,signal){callback=USING(callback);if(!callback.called){WAITSIGNAL(callback,signal);signal.pending++}};var WAITEXECUTE=function(){var signals=this.signal;delete this.signal;this.execute=this.oldExecute;delete this.oldExecute;var result=this.execute.apply(this,arguments);if(ISCALLBACK(result)&&!result.called){WAITSIGNAL(result,signals)}else{for(var i=0,m=signals.length;i0&&priorityf){f=document.styleSheets.length}if(!h){h=(document.getElementsByTagName("head"))[0];if(!h){h=document.body}}return h};var e=[];var b=function(){for(var j=0,h=e.length;j=this.timeout){h(this.STATUS.ERROR);return 1}return 0},file:function(i,h){if(h<0){a.Ajax.loadTimeout(i)}else{a.Ajax.loadComplete(i)}},execute:function(){this.hook.call(this.object,this,this.data[0],this.data[1])},checkSafari2:function(h,i,j){if(h.time(j)){return}if(document.styleSheets.length>i&&document.styleSheets[i].cssRules&&document.styleSheets[i].cssRules.length){j(h.STATUS.OK)}else{setTimeout(h,h.delay)}},checkLength:function(h,k,m){if(h.time(m)){return}var l=0;var i=(k.sheet||k.styleSheet);try{if((i.cssRules||i.rules||[]).length>0){l=1}}catch(j){if(j.message.match(/protected variable|restricted URI/)){l=1}else{if(j.message.match(/Security error/)){l=1}}}if(l){setTimeout(a.Callback([m,h.STATUS.OK]),0)}else{setTimeout(h,h.delay)}}},loadComplete:function(h){h=this.fileURL(h);var i=this.loading[h];if(i&&!i.preloaded){a.Message.Clear(i.message);clearTimeout(i.timeout);if(i.script){if(e.length===0){setTimeout(b,0)}e.push(i.script)}this.loaded[h]=i.status;delete this.loading[h];this.addHook(h,i.callback)}else{this.loaded[h]=this.STATUS.OK;i={status:this.STATUS.OK}}if(!this.loadHooks[h]){return null}return this.loadHooks[h].Execute(i.status)},loadTimeout:function(h){if(this.loading[h].timeout){clearTimeout(this.loading[h].timeout)}this.loading[h].status=this.STATUS.ERROR;this.loadError(h);this.loadComplete(h)},loadError:function(h){a.Message.Set("File failed to load: "+h,null,2000)},Styles:function(j,k){var h=this.StyleString(j);if(h===""){k=a.Callback(k);k()}else{var i=document.createElement("style");i.type="text/css";this.head=g(this.head);this.head.appendChild(i);if(i.styleSheet&&typeof(i.styleSheet.cssText)!=="undefined"){i.styleSheet.cssText=h}else{i.appendChild(document.createTextNode(h))}k=this.timer.create.call(this,k,i)}return k},StyleString:function(m){if(typeof(m)==="string"){return m}var j="",n,l;for(n in m){if(m.hasOwnProperty(n)){if(typeof m[n]==="string"){j+=n+" {"+m[n]+"}\n"}else{if(m[n] instanceof Array){for(var k=0;k1?d[1]:""));f=null}if(e&&(!b.preJax||d)){c.nodeValue=c.nodeValue.replace(b.postJax,(e.length>1?e[1]:""))}if(f&&!f.nodeValue.match(/\S/)){f=f.previousSibling}}if(b.preRemoveClass&&f&&f.className===b.preRemoveClass){a.MathJax.preview=f}a.MathJax.checked=1},processInput:function(a){var b,i=MathJax.ElementJax.STATE;var h,e,d=a.scripts.length;try{while(a.ithis.processUpdateTime&&a.ithis.processUpdateTime&&h.i=0;o--){if(b[o].src.match(d)){q.script=b[o].innerHTML;if(RegExp.$2){var r=RegExp.$2.substr(1).split(/\&/);for(var n=0,h=r.length;n=parseInt(x[y])}}return true},Select:function(j){var i=j[c.Browser];if(i){return i(c.Browser)}return null}};var g=navigator.userAgent.replace(/^Mozilla\/(\d+\.)+\d+ /,"").replace(/[a-z][-a-z0-9._: ]+\/\d+[^ ]*-[^ ]*\.([a-z][a-z])?\d+ /i,"").replace(/Gentoo |Ubuntu\/(\d+\.)*\d+ (\([^)]*\) )?/,"");c.Browser=c.Insert(c.Insert(new String("Unknown"),{version:"0.0"}),a);for(var t in a){if(a.hasOwnProperty(t)){if(a[t]&&t.substr(0,2)==="is"){t=t.slice(2);if(t==="Mac"||t==="PC"){continue}c.Browser=c.Insert(new String(t),a);var p=new RegExp(".*(Version)/((?:\\d+\\.)+\\d+)|.*("+t+")"+(t=="MSIE"?" ":"/")+"((?:\\d+\\.)*\\d+)|(?:^|\\(| )([a-z][-a-z0-9._: ]+|(?:Apple)?WebKit)/((?:\\d+\\.)+\\d+)");var s=p.exec(g)||["","","","unknown","0.0"];c.Browser.name=(s[1]=="Version"?t:(s[3]||s[5]));c.Browser.version=s[2]||s[4]||s[6];break}}}c.Browser.Select({Safari:function(j){var i=parseInt((String(j.version).split("."))[0]);if(i>85){j.webkit=j.version}if(i>=533){j.version="5.0"}else{if(i>=526){j.version="4.0"}else{if(i>=525){j.version="3.1"}else{if(i>500){j.version="3.0"}else{if(i>400){j.version="2.0"}else{if(i>85){j.version="1.0"}}}}}}},Firefox:function(j){if(j.version==="0.0"&&navigator.product==="Gecko"&&navigator.productSub){var i=navigator.productSub.substr(0,8);if(i>="20090630"){j.version="3.5"}else{if(i>="20080617"){j.version="3.0"}else{if(i>="20061024"){j.version="2.0"}}}}},Opera:function(i){i.version=opera.version()},MSIE:function(i){i.isIE9=!!(document.documentMode&&(window.performance||window.msPerformance));MathJax.HTML.setScriptBug=!i.isIE9||document.documentMode<9}});c.Browser.Select(MathJax.Message.browsers);c.queue=f.Callback.Queue();c.queue.Push(["Post",q.signal,"Begin"],["Config",q],["Cookie",q],["Styles",q],function(){var i=f.Callback.Queue(q.Jax(),q.Extensions());return i.Push({})},["Menu",q],q.onLoad(),function(){MathJax.isReady=true},["Typeset",q],["Post",q.signal,"End"])})("MathJax")}}; diff --git a/unpacked/MathJax.js b/unpacked/MathJax.js index 94fd722b2..c0d3a0784 100644 --- a/unpacked/MathJax.js +++ b/unpacked/MathJax.js @@ -1137,7 +1137,7 @@ MathJax.Message = { this.status = true; } } - if (clearDelay) {setTimeout(MathJax.Callback(["Clear",this,n]),clearDelay)} + if (clearDelay) {setTimeout(MathJax.Callback(["Clear",this,n,0]),clearDelay)} return n; }, @@ -1149,8 +1149,9 @@ MathJax.Message = { if (this.text) { if (this.div.parentNode == null) {this.Init()} // see ASCIIMathML comments above if (this.current == null) { - if (this.timer) {clearTimeout(this.timer)} - this.timer = setTimeout(MathJax.Callback(["Remove",this]),(delay||600)); + if (this.timer) {clearTimeout(this.timer); delete this.timer} + if (delay === 0) {this.Remove()} + else {this.timer = setTimeout(MathJax.Callback(["Remove",this]),(delay||600))} } else if (this.textNodeBug) {this.div.innerHTML = this.log[this.current].text} else {this.text.nodeValue = this.log[this.current].text} if (this.status) {window.status = ""; delete this.status} @@ -1343,18 +1344,25 @@ MathJax.Hub = { var queue = MathJax.Callback.Queue(["Clear",this.signal]); for (var i = 0, m = ec.elements.length; i < m; i++) { if (ec.elements[i]) { - var scripts = []; // filled in by prepareScripts + var state = { + scripts: [], // filled in by prepareScripts + start: new Date().getTime(), // timer for processing messages + i: 0, // current script + jax: {} // scripts grouped by output jax + }; queue.Push( ["Post",this.signal,["Begin "+action,ec.elements[i]]], - ["Post",this.signal,["Begin Math",ec.elements[i]]], - ["prepareScripts",this,action,ec.elements[i],scripts], - ["Post",this.signal,["Begin Math Input",ec.elements[i]]], - ["processInput",this,scripts], - ["Post",this.signal,["End Math Input",ec.elements[i]]], - ["Post",this.signal,["Begin Math Output",ec.elements[i]]], - ["processOutput",this,scripts], - ["Post",this.signal,["End Math Output",ec.elements[i]]], - ["Post",this.signal,["End Math",ec.elements[i]]], + ["Post",this.signal,["Begin Math",ec.elements[i],action]], + ["prepareScripts",this,action,ec.elements[i],state], + ["Post",this.signal,["Begin Math Input",ec.elements[i],action]], + ["processInput",this,state], + ["Post",this.signal,["End Math Input",ec.elements[i],action]], + ["prepareOutput",this,state,"preTranslate"], + ["Post",this.signal,["Begin Math Output",ec.elements[i],action]], + ["processOutput",this,state], + ["Post",this.signal,["End Math Output",ec.elements[i],action]], + ["prepareOutput",this,state,"postTranslate"], + ["Post",this.signal,["End Math",ec.elements[i],action]], ["Post",this.signal,["End "+action,ec.elements[i]]] ); } @@ -1375,7 +1383,7 @@ MathJax.Hub = { } }, - prepareScripts: function (action,element,math) { + prepareScripts: function (action,element,state) { if (arguments.callee.disabled) return; var scripts = this.elementScripts(element); var STATE = MathJax.ElementJax.STATE; @@ -1385,19 +1393,17 @@ MathJax.Hub = { if (script.MathJax && script.MathJax.state !== STATE.PENDING) {this.scriptAction[action](script)} if (!script.MathJax) {script.MathJax = {state: STATE.PENDING}} - if (script.MathJax.state !== STATE.PROCESSED) {math.push(script)} + if (script.MathJax.state !== STATE.PROCESSED) {state.scripts.push(script)} } } }, checkScriptSiblings: function (script) { - if (script.MathJax && script.MathJax.checked) return; - var config = this.config; - var pre = script.previousSibling; - if (pre && pre.nodeName == "#text") { - var preJax,postJax; - var post = script.nextSibling; - if (post && post.nodeName != "#text") {post = null} + if (script.MathJax.checked) return; + var config = this.config, pre = script.previousSibling; + if (pre && pre.nodeName === "#text") { + var preJax,postJax, post = script.nextSibling; + if (post && post.nodeName !== "#text") {post = null} if (config.preJax) { if (typeof(config.preJax) === "string") {config.preJax = new RegExp(config.preJax+"$")} preJax = pre.nodeValue.match(config.preJax); @@ -1417,87 +1423,152 @@ MathJax.Hub = { } if (pre && !pre.nodeValue.match(/\S/)) {pre = pre.previousSibling} } - if (config.preRemoveClass && pre && pre.className == config.preRemoveClass) { - try {pre.innerHTML = ""} catch (err) {} - pre.style.display = "none"; - } - if (script.MathJax) {script.MathJax.checked = 1} + if (config.preRemoveClass && pre && pre.className === config.preRemoveClass) + {script.MathJax.preview = pre} + script.MathJax.checked = 1; }, - processInput: function (scripts,start,n) { - if (arguments.callee.disabled) {return null} - if (!start) {start = new Date().getTime()} - var result, STATE = MathJax.ElementJax.STATE; - var i = 0, script, prev; + processInput: function (state) { + var jax, STATE = MathJax.ElementJax.STATE; + var script, prev, m = state.scripts.length; try { - while (i < scripts.length) { - script = scripts[i]; if (!script) {i++; continue} + // + // Loop through the scripts + // + while (state.i < m) { + script = state.scripts[state.i]; if (!script) {state.i++; continue} + // + // Remove previous error marker, if any + // prev = script.previousSibling; if (prev && prev.className === "MathJax_Error") {prev.parentNode.removeChild(prev)} - var type = script.type.replace(/ *;(.|\s)*/,""); - if (!script.MathJax || script.MathJax.state === STATE.PROCESSED) {i++; continue}; + // + // Check if already processed or needs processing + // + if (!script.MathJax || script.MathJax.state === STATE.PROCESSED) {state.i++; continue}; if (!script.MathJax.elementJax || script.MathJax.state === STATE.UPDATE) { - this.checkScriptSiblings(script); - result = this.inputJax[type].Process(script); - if (typeof result === 'function') { - if (result.called) continue; // go back and call Process() again - this.RestartAfter(result); + this.checkScriptSiblings(script); // remove preJax/postJax etc. + var type = script.type.replace(/ *;(.|\s)*/,""); // the input jax type + jax = this.inputJax[type].Process(script); // run the input jax + if (typeof jax === 'function') { // if a callback was returned + if (jax.called) continue; // go back and call Process() again + this.RestartAfter(jax); // wait for the callback } - result.Attach(script,this.inputJax[type].id); - script.MathJax.state = STATE.OUTPUT; + jax.Attach(script,this.inputJax[type].id); // register the jax on the script + script.MathJax.state = STATE.OUTPUT; // mark it as needing output + // + if (!this.outputJax[jax.mimeType]) { // check for existing output jax + script.MathJax.state = STATE.UPDATE; + throw Error("No output jax registered for "+jax.mimeType); + } + // + // Record the output jax + // and put this script in the queue for that jax + // + jax.outputJax = this.outputJax[jax.mimeType][0].id; + if (!state.jax[jax.outputJax]) {state.jax[jax.outputJax] = []} + state.jax[jax.outputJax].push(script); + } + // + // Go on to the next script, and check if we need to update the processing message + // + state.i++; var now = new Date().getTime(); + if (now - state.start > this.processUpdateTime && state.i < state.scripts.length) { + state.start = now; + tihs.processMessage(state,"Input"); + this.RestartAfter(MathJax.Callback.Delay(1)); } - i++; - if (new Date().getTime() - start > this.processUpdateTime && i < scripts.length) - {start = 0; this.RestartAfter(MathJax.Callback.Delay(1))} } - } catch (err) {return this.processError(err,scripts,i,n,start,"Input")} - if ((n || scripts.length) && this.config.showProcessingMessages) + } catch (err) {return this.processError(err,state,"Input")} + // + // Put up final message, reset the state and return + // + if (state.scripts.length && this.config.showProcessingMessages) {MathJax.Message.Set("Processing math: 100%",0)} + state.start = new Date().getTime(); state.i = 0; return null; }, + + // + // Pre- and post-translate sscripts by jax + // (to get scaling factors, hide/show output, and so on) + // + prepareOutput: function (state,method) { + for (var id in state.jax) {if (state.jax.hasOwnProperty(id)) { + var JAX = MathJax.OutputJax[id]; + if (JAX[method]) {JAX[method](state.jax[id])} + }} + }, - processOutput: function (scripts,start,n) { - if (arguments.callee.disabled) {return null} - if (!start) {start = new Date().getTime()} - var result, STATE = MathJax.ElementJax.STATE; - var i = 0, script; + processOutput: function (state) { + var result, STATE = MathJax.ElementJax.STATE, script, m = state.scripts.length; try { - while (i < scripts.length) { - script = scripts[i]; if (!script || !script.MathJax) {i++; continue} - var jax = script.MathJax.elementJax; if (!jax) {i++; continue} - if (!this.outputJax[jax.mimeType]) { - script.MathJax.state = STATE.UPDATE; - throw Error("No output jax registered for "+jax.mimeType); - } - var outputJax = this.outputJax[jax.mimeType][0]; - jax.outputJax = outputJax.id; - result = outputJax.Process(script); + // + // Loop through the scripts + // + while (state.i < m) { + // + // Check that there is an element jax + // + script = state.scripts[state.i]; if (!script || !script.MathJax) {state.i++; continue} + var jax = script.MathJax.elementJax; if (!jax) {state.i++; continue} + // + // Call the output Jax's Process method (which will be its Translate() + // method once loaded) and if it returns a call back, restart the processing. + // + result = MathJax.OutputJax[jax.outputJax].Process(script); if (typeof result === 'function') { if (result.called) continue; // go back and call Process() again this.RestartAfter(result); } - script.MathJax.state = STATE.PROCESSED; i++; + // + // Mark it as complete and remove the preview + // + script.MathJax.state = STATE.PROCESSED; state.i++; + if (script.MathJax.preview) {script.MathJax.preview.style.display = "none"} + // + // Signal that new math is available + // this.signal.Post(["New Math",jax.inputID]); // FIXME: wait for this? (i.e., restart if returns uncalled callback) - if (new Date().getTime() - start > this.processUpdateTime && i < scripts.length) - {start = 0; this.RestartAfter(MathJax.Callback.Delay(1))} + // + // Update the processing message, if needed + // + var now = new Date().getTime(); + if (now - state.start > this.processUpdateTime && state.i < state.scripts.length) { + state.start = now; + this.processMessage(state,"Output"); + this.RestartAfter(MathJax.Callback.Delay(1)); + } } - } catch (err) {return this.processError(err,scripts,i,n,start,"Output")} - if ((n || scripts.length) && this.config.showProcessingMessages) { - MathJax.Message.Set("Typesetting math: 100%",0); - MathJax.Message.Clear(0); - } + } catch (err) {return this.processError(err,state,"Output")} + // + // Put up the typesetting-complete message + // + if (state.scripts.length && this.config.showProcessingMessages) + {MathJax.Message.Set("Typesetting math: 100%",0,600)} return null; }, + + postOutput: function (state) { + for (var id in state.jax) {if (state.jax.hasOwnProperty(id)) { + var JAX = MathJax.OutputJax[id]; + if (JAX.postTranslate) {JAX.preTranslate(state.jax[id])} + }} + }, - processError: function (err,scripts,i,n,start,type) { - if (!err.restart) { - if (!this.config.errorSettings.message) {throw err} - this.formatError(scripts[i],err); i++; - } - if (!n) {n = 0}; var m = Math.floor((n+i)/(n+scripts.length)*100); n += i; + processMessage: function (state,type) { + var m = Math.floor(state.i/(state.scripts.length)*100); var message = (type === "Output" ? "Typesetting" : "Processing"); if (this.config.showProcessingMessages) {MathJax.Message.Set(message+" math: "+m+"%",0)} - return MathJax.Callback.After(["process"+type,this,scripts.slice(i),start,n],err.restart); + }, + + processError: function (err,state,type) { + if (!err.restart) { + if (!this.config.errorSettings.message) {throw err} + this.formatError(state.scripts[state.i],err); state.i++; + } + this.processMessage(state,type); + return MathJax.Callback.After(["process"+type,this,state],err.restart); }, formatError: function (script,err) {