Created
January 12, 2011 23:09
-
-
Save ryankshaw/777086 to your computer and use it in GitHub Desktop.
injects math into a canvas wiki page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(window){ | |
// inside of here window is the iframe | |
var document = window.document; | |
function loadScriptWithCallback(url, callback) { | |
var head = document.getElementsByTagName("head")[0] || document.documentElement; | |
var script = document.createElement("script"); | |
script.src = url; | |
script.onload = script.onreadystatechange = function() { | |
callback.call(window); | |
}; | |
head.insertBefore( script, head.firstChild ); | |
} | |
loadScriptWithCallback("http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js", function(){ | |
this.jQuery(function($){ | |
// in here $ is our new jquery, window is the iframe, and document is the iframe document | |
$("head").append('<link rel="stylesheet" type="text/css" href="http://laughinghan.github.com/mathquill/mathquill.css">'); | |
$.getScript('http://laughinghan.github.com/mathquill/mathquill.js', function(){ | |
var equation = "\\frac{d}{dx}\\sqrt{x}=\\frac{d}{dx}x^{\\frac{1}{2}}=\\frac{1}{2}x^{-\\frac{1}{2}}=\\frac{1}{2\\sqrt{x}}"; | |
$('<span>'+equation+'</span>').appendTo('body').mathquill('editable'); | |
console.log($el); | |
}); | |
}); | |
}); | |
})($("#wiki_page_body_ifr")[0].contentWindow); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment