forked from tpbarron/mathjax_mathspeak
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmathml.html
More file actions
90 lines (90 loc) · 2.88 KB
/
Copy pathmathml.html
File metadata and controls
90 lines (90 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<html>
<head>
<title>MathML MathJax Test Page</title>
<script type="text/javascript" src="unpackedlanguagebuffer/MathJax.js?config=MML_HTMLorMML,lang_enus"></script>
<script src="speakClient.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
function display() {
var str = document.getElementById("equation_editor").value;
var svg_node = document.getElementById("svg_node");
svg_node.innerHTML = '`' + str + '`';
MathJax.Hub.Typeset(svg_node);
}
<!-- https://groups.google.com/d/topic/mathjax-users/unL8IjcrTto/discussion -->
function toMathML(jax, callback) {
var mml;
try {
mml = jax.root.toMathML("");
} catch(err) {
if (!err.restart) { throw err; }
return MathJax.Callback.After([toMathML, jax, callback], err, restart);
}
MathJax.Callback(callback)(mml);
}
function clearDescription() {
var description_node = document.getElementById("description");
description_node.value = '';
}
function appendToDescription() {
var svg_node = document.getElementById("svg_node");
MathJax.Hub.Queue(function() {
var jaxen = MathJax.Hub.getAllJax(svg_node);
toMathML(jaxen[0], function(mml) {
var str = document.getElementById("equation_editor").value;
var description_node = document.getElementById("description");
$.ajax({
url: "service?equation=" + str,
success: function(mde_description) {
description_node.value += mde_description;
description_node.value += "\n";
description_node.value += mml;
},
error: function() {
description_node.value += mml;
}
});
})});
}
function copyMML() {
document.getElementById("mathmlinput").innerHTML = document.getElementById("description").value;
document.getElementById("mathspeak").innerHTML = '';
MathJax.Hub.Typeset(document.getElementById("mathmlinput"));
}
</script>
</head>
<body>
<div id="audio"></div>
<b>Description:</b><br>
<textarea id="description" rows="10" cols="80"></textarea>
<button onclick=copyMML();>Update Math</button>
<br><br>
<table border="1"><tr><td valign="center">
<div id="mathmlinput">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mstyle displaystyle="true">
<mrow>
<mi>f</mi>
<mo>(</mo>
<mi>x</mi>
<mo>)</mo>
</mrow>
<mo>≈</mo>
<msup>
<mi>x</mi>
<mn>3</mn>
</msup>
<mo>+</mo>
<mfrac>
<mn>8</mn>
<mn>10</mn>
</mfrac>
</mstyle>
</math>
</div>
</td><td valign="top">
<div id="mathspeak"></div>
</td></tr></table>
</body>
</html>