Commit 68a2e7c0 by ichuang

dynamic math display - fix sequence of mathjax timing (mathml now

generated when Check is clicked)
parent 1e0475c1
...@@ -450,8 +450,9 @@ var AMsymbols = [ ...@@ -450,8 +450,9 @@ var AMsymbols = [
{input:"QQ", tag:"mo", output:"\u211A", tex:null, ttype:CONST}, {input:"QQ", tag:"mo", output:"\u211A", tex:null, ttype:CONST},
{input:"RR", tag:"mo", output:"\u211D", tex:null, ttype:CONST}, {input:"RR", tag:"mo", output:"\u211D", tex:null, ttype:CONST},
{input:"ZZ", tag:"mo", output:"\u2124", tex:null, ttype:CONST}, {input:"ZZ", tag:"mo", output:"\u2124", tex:null, ttype:CONST},
{input:"f", tag:"mi", output:"f", tex:null, ttype:UNARY, func:true}, // not for edX (ichuang jun12)
{input:"g", tag:"mi", output:"g", tex:null, ttype:UNARY, func:true}, //{input:"f", tag:"mi", output:"f", tex:null, ttype:UNARY, func:true},
//{input:"g", tag:"mi", output:"g", tex:null, ttype:UNARY, func:true},
//standard functions //standard functions
{input:"lim", tag:"mo", output:"lim", tex:null, ttype:UNDEROVER}, {input:"lim", tag:"mo", output:"lim", tex:null, ttype:UNDEROVER},
......
...@@ -79,7 +79,6 @@ function DoUpdateMath(inputId) { ...@@ -79,7 +79,6 @@ function DoUpdateMath(inputId) {
} }
</script> </script>
<%block name="headextra"/>
<!-- This must appear after all mathjax-config blocks, so it is after the imports from the other templates --> <!-- This must appear after all mathjax-config blocks, so it is after the imports from the other templates -->
<!-- TODO: move to settings --> <!-- TODO: move to settings -->
...@@ -87,4 +86,3 @@ function DoUpdateMath(inputId) { ...@@ -87,4 +86,3 @@ function DoUpdateMath(inputId) {
## <script type="text/javascript" src="/static/js/mathjax-MathJax-c9db6ac/MathJax.js?config=TeX-AMS_HTML-full"></script> ## <script type="text/javascript" src="/static/js/mathjax-MathJax-c9db6ac/MathJax.js?config=TeX-AMS_HTML-full"></script>
<script type="text/javascript" src="/static/js/mathjax-MathJax-c9db6ac/MathJax.js?config=TeX-MML-AM_HTMLorMML-full"></script> <script type="text/javascript" src="/static/js/mathjax-MathJax-c9db6ac/MathJax.js?config=TeX-MML-AM_HTMLorMML-full"></script>
</script> </script>
\ No newline at end of file
...@@ -2,31 +2,27 @@ function ${ id }_content_updated() { ...@@ -2,31 +2,27 @@ function ${ id }_content_updated() {
MathJax.Hub.Queue(["Typeset",MathJax.Hub]); MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
update_schematics(); update_schematics();
// dynamic math display: add to jaxset for automatic rendering // for (var key in codemirror_set) {
// codemirror_set[key].refresh();
// }
$('#check_${ id }').unbind('click').click(function() {
$("input.schematic").each(function(index,element){ element.schematic.update_value(); });
$(".CodeMirror").each(function(index,element){ if (element.CodeMirror.save) element.CodeMirror.save(); });
// dynamic math display: generate MathML on click
$.each($("[id^=input_${ id }_]"), function(index,value){ $.each($("[id^=input_${ id }_]"), function(index,value){
theid = value.id.replace("input_",""); // ID of the response theid = value.id.replace("input_",""); // ID of the response
if (document.getElementById("display_" + theid)){ if (document.getElementById("display_" + theid)){
MathJax.Hub.queue.Push(function () { MathJax.Hub.queue.Push(function () {
math = MathJax.Hub.getAllJax("display_" + theid)[0]; math = MathJax.Hub.getAllJax("display_" + theid)[0];
if (math){ if (math){
jaxset[theid] = math;
math.Text(document.getElementById(value.id).defaultValue);
x = document.getElementById("input_" + theid + "_dynamath");
UpdateMathML(math,theid); UpdateMathML(math,theid);
} }
}); });
}; };
}); });
$('#check_${ id }').unbind('click').click(function() {
$("input.schematic").each(function(index,element){ element.schematic.update_value(); });
$(".CodeMirror").each(function(index,element){ if (element.CodeMirror.save) element.CodeMirror.save(); });
// for (var key in codemirror_set) {
// codemirror_set[key].refresh();
// }
var submit_data={}; var submit_data={};
$.each($("[id^=input_${ id }_]"), function(index,value){ $.each($("[id^=input_${ id }_]"), function(index,value){
if (value.type==="checkbox"){ if (value.type==="checkbox"){
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
### version of textline.html which does dynammic math ### version of textline.html which does dynammic math
### ###
<section class="text-input-dynamath"> <section class="text-input-dynamath">
<table><tr><td> <table style="display:inline; vertical-align:middle;"><tr><td>
<input type="text" name="input_${id}" id="input_${id}" value="${value}" <input type="text" name="input_${id}" id="input_${id}" value="${value}"
% if size: % if size:
size="${size}" size="${size}"
...@@ -26,24 +26,23 @@ ...@@ -26,24 +26,23 @@
</td></tr><tr><td> </td></tr><tr><td>
<span id="display_${id}">`{::}`</span> <span id="display_${id}">`{::}`</span>
</td><td> </td><td>
<textarea style="display:none" id="input_${id}_dynamath" name="input_${id}_dynamath">none</textarea> <textarea style="display:none" id="input_${id}_dynamath" name="input_${id}_dynamath"> </textarea>
</td></tr> </td></tr>
</table> </table>
## ##
## javascript for dynamic math: add this math element to the MathJax rendering queue ## javascript for dynamic math: add this math element to the MathJax rendering queue
## also adds to global jaxset js array ## also adds to global jaxset js array
## ##
<script> <script type="text/javascript">
MathJax.Hub.queue.Push(function () { MathJax.Hub.queue.Push(function () {
math = MathJax.Hub.getAllJax("display_${id}")[0]; math = MathJax.Hub.getAllJax("display_${id}")[0];
if (math){ if (math){
jaxset["${id}"] = math; jaxset["${id}"] = math;
math.Text(document.getElementById("input_${id}_dynamath").defaultValue); // initial render math.Text(document.getElementById("input_${id}").value);
UpdateMathML(math,"${id}"); // initial MathML // UpdateMathML(math,"${id}");
} }
}); });
</script> </script>
% if msg: % if msg:
<br/> <br/>
<span class="debug">${msg|n}</span> <span class="debug">${msg|n}</span>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment