-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
107 lines (94 loc) · 3.1 KB
/
index.html
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html>
<html>
<head>
<title>MathJax Dynamic Math Test Page</title>
<!-- Copyright (c) 2010-2019 The MathJax Consortium -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script type="text/javascript" src="./MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<style>
input {
margin-top: 0.7em;
}
.output {
border: 1px solid black;
padding: 1em;
width: auto;
position: absolute;
top: 0;
left: 2em;
min-width: 20em;
}
.box {
position: relative;
}
</style>
</head>
<body>
<script>
//
// Use a closure to hide the local variables from the
// global namespace
//
;
(function() {
var QUEUE = MathJax.Hub.queue // shorthand for the queue
var math = null,
box = null // the element jax for the math output, and the box it's in
//
// Hide and show the box (so it doesn't flicker as much)
//
var HIDEBOX = function() {
box.style.visibility = 'hidden'
}
var SHOWBOX = function() {
box.style.visibility = 'visible'
}
//
// Get the element jax when MathJax has produced it.
//
QUEUE.Push(function() {
math = MathJax.Hub.getAllJax('MathOutput')[0]
box = document.getElementById('box')
SHOWBOX() // box is initially hidden so the braces don't show
})
//
// The onchange event handler that typesets the math entered
// by the user. Hide the box, then typeset, then show it again
// so we don't see a flash as the math is cleared and replaced.
//
window.UpdateMath = function(TeX) {
QUEUE.Push(
HIDEBOX, ['resetEquationNumbers', MathJax.InputJax.TeX], ['Text', math, '\\displaystyle{' + TeX + '}'],
SHOWBOX
)
}
})()
</script>
<p>
Type some \(\rm\TeX\) code and press RETURN:
<br />
<input id="MathInput" size="80" onchange="UpdateMath(this.value)" />
</p>
<p>You typed:</p>
<div class="box" id="box" style="visibility: hidden">
<div id="MathOutput" class="output">$${}$$</div>
</div>
<script>
//
// IE doesn't fire onchange events for RETURN, so
// use onkeypress to do a blur (and refocus) to
// force the onchange to occur
//
if (MathJax.Hub.Browser.isMSIE) {
MathInput.onkeypress = function() {
if (window.event && window.event.keyCode === 13) {
this.blur()
this.focus()
}
}
}
</script>
</body>
</html>