<!DOCTYPE html>
<html>
<head>
<!-- released under the GNU GPLv3 - copyleft Yoochan -->
<title>MathJax Test Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
body {
background-color:#99c;
}
#page {
margin: 0.5em;
padding: 0.5em;
min-width: 23em;
width:50%;
margin: auto;
background-color:#668;
}
#block, #inline, #input {
margin: 0.5em;
padding: 0.5em;
text-align:justify;
background-color:#fff;
}
textarea {
width: 100%;
height: auto;
border : 0px white solid;
}
</style>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX","output/SVG"],
tex2jax: {
inlineMath: [["\\(","\\)"]],
displayMath: [["\\[","\\]"]]
}
});
</script>
<script type="text/javascript">
(function () {
var mathinline = null;
var mathblock = null;
var previous_formula = null;
MathJax.Hub.queue.Push(function () {
mathinline = MathJax.Hub.getAllJax("MathInline")[0];
mathblock = MathJax.Hub.getAllJax("MathBlock")[0];
});
window.UpdateMath = function (value) {
if ((previous_formula === null) || (value != previous_formula)) {
console.log("window.UpdateMath("+value+")");
MathJax.Hub.queue.Push(["Text", mathinline, value]);
MathJax.Hub.queue.Push(["Text", mathblock, value]);
previous_formula = value;
}
};
window.do_keydown = function (event, value) {
var code = (event.keyCode ? event.keyCode : event.which);
if (code == 13 || event.shiftKey === true || code == 32) {
window.UpdateMath(value);
}
};
})();
</script>
</head>
<body>
<div id="page">
<div id="input">
<textarea id="MathInput" rows="5" cols="30" onblur="UpdateMath(this.value)" onkeydown="do_keydown(event, this.value)" >\sum _{ n = 1 } ^{+\infty} \frac {1} {n^2} = \frac {\pi^2} {6}</textarea>
</div>
<div id="inline">
<p id="MathInline">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex \(__formula__\) ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div id="block">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p>
<p id="MathBlock">\[__formula__\]</p>
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
<script type="text/javascript">
var formula = window.document.getElementById("MathInput").value;
var mathblock_div = document.getElementById("MathBlock");
mathblock_div.innerHTML = mathblock_div.innerHTML.replace("__formula__", formula);
var mathinline_div = document.getElementById("MathInline");
mathinline_div.innerHTML = mathinline_div.innerHTML.replace("__formula__", formula);
window.setInterval(function(){
window.UpdateMath(window.document.getElementById("MathInput").value);
}, 2500);
</script>
</body>
</html>
Diff to Previous Revision
--- revision 6 2015-02-12 10:47:11
+++ revision 7 2015-02-12 13:10:17
@@ -35,7 +35,7 @@
jax: ["input/TeX","output/SVG"],
tex2jax: {
inlineMath: [["\\(","\\)"]],
- displayMath: [["\\[","\\]"]],
+ displayMath: [["\\[","\\]"]]
}
});
</script>
@@ -43,7 +43,7 @@
(function () {
var mathinline = null;
var mathblock = null;
- var previous_formula = null
+ var previous_formula = null;
MathJax.Hub.queue.Push(function () {
mathinline = MathJax.Hub.getAllJax("MathInline")[0];
@@ -57,21 +57,20 @@
MathJax.Hub.queue.Push(["Text", mathblock, value]);
previous_formula = value;
}
- }
+ };
window.do_keydown = function (event, value) {
var code = (event.keyCode ? event.keyCode : event.which);
if (code == 13 || event.shiftKey === true || code == 32) {
window.UpdateMath(value);
}
- }
+ };
})();
</script>
</head>
<body>
<div id="page">
<div id="input">
- <!-- \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} = \frac{4\pi}{c}\vec{\mathbf{\jmath}} -->
<textarea id="MathInput" rows="5" cols="30" onblur="UpdateMath(this.value)" onkeydown="do_keydown(event, this.value)" >\sum _{ n = 1 } ^{+\infty} \frac {1} {n^2} = \frac {\pi^2} {6}</textarea>
</div>
<div id="inline">