User:Ledrug/vector.js

(function {

function load_mathjax { var x = document.createElement("script"); x.src = "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"; x.type= "text/javascript"; x.id = "_mathjax_script"; document.head.appendChild(x); }

var ll = []; function tex_jax(e) { var l = document.getElementsByTagName('img'); for (var i = 0; i < l.length; i++) { if (l[i].className.match(/\btex\b/)) ll.push(l[i]); }

if (!ll.length) return; if (! document.getElementById('_mathjax_script')) load_mathjax;

use_jax; }

function use_jax { if (!window.MathJax) { setTimeout(use_jax, 250); return; }

function repl(x) { if (!x._mathjax_repl) { var e, t, tl, tr; t = x.getAttribute('alt'); e = x._mathjax_repl = document.createElement("span"); if (x.parentNode.tagName == "dd") tl = tr = "$$"; else { tl = "\\("; tr = "\\)"; }			e.textContent = tl + t + tr; MathJax.Hub.Queue(["Typeset",MathJax.Hub,x._mathjax_repl]); e.title = t;			e._mathjax_repl = x;			e.addEventListener('click', function {repl(e)}, false); }		x.parentNode.replaceChild(x._mathjax_repl, x); }

ll.map(function(x) {		x.addEventListener('click', function(e) { repl(x) }, false);		repl(x);	}); }

document.addEventListener("DOMContentLoaded", tex_jax, false);

});