Commit 04f221e3 by kimth

Another step towards Javascriptinput-style script loading

parent 37acade6
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
### version of textline.html which does dynamic math ### version of textline.html which does dynamic math
### ###
<section class="text-input-dynamath textinputdynamath capa_inputtype" id="inputtype_${id}"> <section class="text-input-dynamath textinputdynamath capa_inputtype" id="inputtype_${id}">
<div class="textinputdynamath_data" data-preprocessor="MathjaxPreprocessorFor6002x"/>
<div class="script_placeholder" data-src="/static/js/mathjax_preprocessor_for_6002x.js"/>
% if state == 'unsubmitted': % if state == 'unsubmitted':
<div class="unanswered" id="status_${id}"> <div class="unanswered" id="status_${id}">
% elif state == 'correct': % elif state == 'correct':
...@@ -20,7 +24,6 @@ ...@@ -20,7 +24,6 @@
style="display:none;" style="display:none;"
% endif % endif
/> />
<div class="script_placeholder" data-src="/static/js/mathjax_preprocessor_for_6002x.js"/>
<p class="status"> <p class="status">
% if state == 'unsubmitted': % if state == 'unsubmitted':
unanswered unanswered
......
...@@ -297,12 +297,17 @@ class @Problem ...@@ -297,12 +297,17 @@ class @Problem
refreshMath: (event, element) => refreshMath: (event, element) =>
element = event.target unless element element = event.target unless element
target = "display_#{element.id.replace(/^input_/, '')}" elid = element.id.replace(/^input_/,'')
target = "display_" + elid
preprocessor_tag = "inputtype_" + elid
mathjax_preprocessor = @inputtypeDisplays[preprocessor_tag]
if jax = MathJax.Hub.getAllJax(target)[0] if jax = MathJax.Hub.getAllJax(target)[0]
eqn = $(element).val() eqn = $(element).val()
if @mathjax_preprocessor if mathjax_preprocessor
eqn = @mathjax_preprocessor(eqn) eqn = mathjax_preprocessor(eqn)
MathJax.Hub.Queue ['Text', jax, eqn], MathJax.Hub.Queue ['Text', jax, eqn],
[@updateMathML, jax, element] [@updateMathML, jax, element]
...@@ -324,9 +329,13 @@ class @Problem ...@@ -324,9 +329,13 @@ class @Problem
inputtypeSetupMethods: inputtypeSetupMethods:
textinputdynamath: (element) => textinputdynamath: (element) =>
preprocessorClass = window['MathjaxPreprocessorFor6002x'] data = $(element).find('.textinputdynamath_data')
preprocessorClassName = data.data('preprocessor')
preprocessorClass = window[preprocessorClassName]
preprocessor = new preprocessorClass() preprocessor = new preprocessorClass()
alert preprocessor.fn return preprocessor.fn
javascriptinput: (element) => javascriptinput: (element) =>
......
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