Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
65 lines (56 sloc) 1.38 KB
module mathJAX
import mobl
function renderMaths() : void
{
sleep(0);
render();
}
function renderMathsIn(event:Object) : void
{
sleep(0);
renderIn(event);
}
external sync function loadMaths() : void
external sync function render() : void
external sync function renderIn(event:Object) : void
external sync function isLoaded():Bool
<javascript>
//
// Load MathJax and have it process the page
//
__ns.loaded = false;
__ns.isLoaded = function()
{
if(this.loaded)
return true;
else
return null;
};
__ns.loadMaths = function() {
var script = document.createElement("script");
script.src = "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML-full";
var config = 'MathJax.Hub.Startup.onload()';
script.text = config;
document.getElementsByTagName("head")[0].appendChild(script);
this.loaded = true;
};
__ns.render = function() {
if(this.loaded)
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
else
this.loadMaths();
};
__ns.renderIn = function(event) {
if(this.loaded) {
var math = MathJax.Hub.getAllJax(event.currentTarget)[0];
if(math) {
math.Remove();
}
else {
MathJax.Hub.Queue(["Typeset",MathJax.Hub, event.currentTarget]);
}
}
else
this.loadMaths();
};
</javascript>