Created
November 18, 2013 20:46
-
-
Save yingted/7534995 to your computer and use it in GitHub Desktop.
UW MapleTA inline equation preview
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
// ==UserScript== | |
// @name Inline equation preview | |
// @namespace localhost | |
// @description Inline equation preview for MapleTA equation editor | |
// @include https://maple-ta.uwaterloo.ca/mapleta/modules/* | |
// @version 0.1 | |
// @grant none | |
// @require http://userscripts.org/scripts/source/68059.user.js | |
// ==/UserScript== | |
$("input+a>img").parent().prev().each(function(i,e){ | |
var $img=$([]),$this=$(e).bind("change keyup keydown",function(e){ | |
$.get("/mapleta/modules/preview.Preview?eq="+encodeURIComponent($(this).val())+"&actionID=maple",function(html){ | |
var m=html.match(/img src="([^"]*(?:\\"[^"]*)*)"/i); | |
if(!m) | |
return; | |
$img.remove(); | |
$img=$("<img>") | |
.attr("src",m[1]) | |
.insertAfter($this) | |
//.delay(3000) | |
// .hide(100); | |
}) | |
}).change(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment