Skip to content

Instantly share code, notes, and snippets.

@yingted
Created November 18, 2013 20:46
Show Gist options
  • Save yingted/7534995 to your computer and use it in GitHub Desktop.
Save yingted/7534995 to your computer and use it in GitHub Desktop.
UW MapleTA inline equation preview
// ==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