-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
349 lines (312 loc) · 13.4 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LaTeX Type</title>
<style>
#input-origin {
font-size: 25px;
outline: none;
}
.operate-area {
display: flex;
justify-content: space-around;
align-items: center;
margin-top: 20px;
}
textarea {
padding: 0;
margin: 0;
}
.operate-area .show-area {
border: #000 1px solid;
padding: 0;
}
.btn-field {
overflow: hidden;
width: 740px;
margin-top: 50px;
margin-left: 50px;
}
.btn-field div {
display: flex;
/* justify-content: space-between; */
flex-wrap: wrap;
}
.btn-field div span {
cursor: pointer;
font-size: 20px;
line-height: 40px;
padding: 5px 10px;
border: 1px #000 solid;
}
.btn-field input {
display: none;
}
.btn-field label {
float: left;
width: 140px;
height: 40px;
line-height: 40px;
text-align: center;
font-size: 14px;
font-weight: 700;
transition: all .3s;
}
.btn-field ul {
clear: both;
width: 3500px;
min-height: 600px;
transition: all .5s;
}
.btn-field ul li {
float: left;
list-style: none;
width: 700px;
min-height: 600px;
margin-right: 40px;
}
#tab1:checked~ul {
margin-left: 0;
}
#tab2:checked~ul {
margin-left: -740px;
}
#tab3:checked~ul {
margin-left: -1480px;
}
#tab4:checked~ul {
margin-left: -2220px;
}
#tab1:checked~label[for="tab1"] {
border: 1px solid #000;
}
#tab2:checked~label[for="tab2"] {
border: 1px solid #000;
}
#tab3:checked~label[for="tab3"] {
border: 1px solid #000;
}
#tab4:checked~label[for="tab4"] {
border: 1px solid #000;
}
</style>
</head>
<script>
window.MathJax = {
tex: {
inlineMath: [["\$", "\$"], ["\\(", "\\)"]],
displayMath: [["$$", "$$"], ["\\[", "\\]"]]
},
options: {
skipHtmlTags: ["script", "noscript", "style", "textarea", "pre", "code", "a"],
ignoreHtmlClass: 'tex2jax_ignore',
processHtmlClass: 'tex2jax_process'
}
};
</script>
<script src="./MathJax-3.2.0/es5/tex-svg.js" id="MathJax-script"></script>
<script src="./jquery.min.js"></script>
<body>
<div class="operate-area">
<div class="input-area">
<textarea name="" id="input-origin" cols="30" rows="10"></textarea>
</div>
<div class="show-area">
<p class="latex-formula">$$ $$</p>
</div>
</div>
<div class="btn-field">
<input type="radio" id="tab1" checked name="basic">
<input type="radio" id="tab2" name="basic">
<input type="radio" id="tab3" name="basic">
<input type="radio" id="tab4" name="basic">
<label for="tab1">基本</label>
<label for="tab2">基本运算</label>
<label for="tab3">微积分</label>
<label for="tab4">常用字母</label>
<ul>
<li>
<h2>基本</h2>
<div>
<span id="init">重置</span>
<span class="init-operation" id="inline-formula" do="$ $">行内公式</span>
<span class="init-operation" id="block-formula" do="$$ $$">行间公式</span>
<span class="save-operation" id="save-svg">下载 SVG 文件</span>
</div>
</li>
<li>
<h2>基本运算</h2>
<div>
<span class="operation" id="frac" do="\frac{}{}">$ \frac{a}{b} $</span>
<span class="operation" id="superscript" do="^{}">$x^{a}$</span>
<span class="operation" id="function-x" do="f(x)={}">$f(x)$</span>
<span class="operation" id="cdot" do="\cdot{}">$\cdot{}$</span>
<span class="operation" id="approx" do="\approx{}">$\approx{}$</span>
<span class="operation" id="neq" do="\neq{}">$\neq{}$</span>
<span class="operation" id="sqrt" do="\sqrt{}">$\sqrt{a}$</span>
<span class="operation" id="right_arrow" do="\rightarrow ">$\rightarrow$</span>
<span class="operation" do="\pi">$\pi$</span>
<span class="operation" do="e">$e$</span>
<span class="operation" do="e^x">$e^x$</span>
<span class="operation" id="x_0" do="x_{0}">$x_{0}$</span>
<span class="operation" id="log_ax" do="\log_{a}{x}">$\log_{a}{x}$</span>
<span class="operation" id="ln_x" do="\ln{x}">$\ln{x}$</span>
</div>
<h3>三角学</h3>
<div>
<span class="operation" id="sin" do="\sin{}">$\sin{a}$</span>
<span class="operation" id="cos" do="\cos{}">$\cos{a}$</span>
<span class="operation" id="tan" do="\tan{}">$\tan{a}$</span>
<span class="operation" id="sin_2" do="\sin({})">$\sin({a})$</span>
<span class="operation" id="cos_2" do="\cos({})">$\cos({a})$</span>
<span class="operation" id="tan_2" do="\tan({})">$\tan({a})$</span>
<span class="operation" id="tan_-1" do="\tan^-1({})">$\tan^-1({a})$</span>
</div>
</li>
<li>
<h2>微积分</h2>
<div>
<span class="operation" do="\infty">$\infty$</span>
<span class="operation" id="delta-x" do="\Delta x">$\Delta x$</span>
<span class="operation" id="derivative-1-1" do="\frac{dx}{dy}">$\frac{dy}{dx}$</span>
<span class="operation" id="derivative-1-2" do="\frac{d}{dy}">$\frac{d}{dx}$</span>
<span class="operation" id="derivative-2" do="f'(x)={}">$f'(x)$</span>
<span class="operation" id="y-prime" do="y'">$y'$</span>
<span class="operation" id="second-derivative-2" do="f''(x)">$f''(x)$</span>
<span class="operation" id="integral" do="\int_{}^{}">$\int_{a}^{b}$</span>
<span class="operation" id="lim_x_to_infinity" do="\lim_{x \to \infty}">$\lim_{x \to \infty}$</span>
<span class="operation" id="x_to_0" do="\Delta x \rightarrow 0">$\Delta x \rightarrow 0$</span>
</div>
<h3>常见公式</h3>
<div>
<span class="operation" id="f_difination"
do="f'(x_0)=\lim_{x \to \infty}\frac{f(x_0+\Delta x)-f(x_0)}{\Delta x}">$f'(x_0)=\lim_{x \to
\infty}\frac{f(x_0+\Delta x)-f(x_0)}{\Delta x}$</span>
<span class="operation" id="f_x_n_power"
do="\frac{d}{dx}x^n=nx^{n-1}">$\frac{d}{dx}x^n=nx^{n-1}$</span>
<span class="operation" id="f_1_x"
do="\frac{d}{dx}(\frac{1}{x})=-\frac{1}{x^2}">$\frac{d}{dx}(\frac{1}{x})=-\frac{1}{x^2}$</span>
<span class="operation" do="f(x)\approx f(x_0)+f'(x_0)(x-x_0) (x\approx x_0)">$f(x)\approx
f(x_0)+f'(x_0)(x-x_0) (x\approx x_0)$</span>
<span class="operation"
do="f(x)\approx f(x_0)+f'(x_0)(x-x_0)+\frac{f''(x_0)}{2}(x-x_0)^2 (x\approx x_0)">$f(x)\approx
f(x_0)+f'(x_0)(x-x_0)+\frac{f''(x_0)}{2}(x-x_0)^2 (x\approx x_0)$</span>
</div>
</li>
<li>
<h2>常用字母</h2>
<div>
<span class="operation" do="a ">$a$</span>
<span class="operation" do="b ">$b$</span>
<span class="operation" do="c ">$c$</span>
<span class="operation" do="y ">$y$</span>
<span class="operation" do="x ">$x$</span>
<span class="operation" do="n ">$n$</span>
<span class="operation" do="\Delta ">$\Delta$</span>
<span class="operation" do="\delta ">$\delta$</span>
<span class="operation" do="\theta ">$\theta$</span>
</div>
</li>
</ul>
</div>
<script>
</script>
<script>
(function ($) {
$.fn.extend({
insertContent: function (myValue, t) {
var $t = $(this)[0];
if (document.selection) { // ie
this.focus();
var sel = document.selection.createRange();
sel.text = myValue;
this.focus();
sel.moveStart('character', -l);
var wee = sel.text.length;
if (arguments.length == 2) {
var l = $t.value.length;
sel.moveEnd("character", wee + t);
t <= 0 ? sel.moveStart("character", wee - 2 * t - myValue.length) : sel.moveStart("character", wee - t - myValue.length);
sel.select();
}
} else if ($t.selectionStart
|| $t.selectionStart == '0') {
var startPos = $t.selectionStart;
var endPos = $t.selectionEnd;
var scrollTop = $t.scrollTop;
$t.value = $t.value.substring(0, startPos)
+ myValue
+ $t.value.substring(endPos, $t.value.length);
this.focus();
$t.selectionStart = startPos + myValue.length;
$t.selectionEnd = startPos + myValue.length;
$t.scrollTop = scrollTop;
if (arguments.length == 2) {
$t.setSelectionRange(startPos - t,
$t.selectionEnd + t);
this.focus();
}
} else {
this.value += myValue;
this.focus();
}
}
})
})(jQuery);
$("#input-origin").val("$$ $$")
$("#input-origin").on("keyup change", function () {
$(".latex-formula").html($(this).val());
MathJax.typesetPromise();
// window.MathJax.Hub.Queue(["Typeset", MathJax.Hub, document.getElementsByClassName("ck-content")]);
})
$("#init").click(function () {
$("#input-origin").val("$$ $$")
$(".latex-formula").html($("#input-origin").val());
MathJax.typesetPromise();
})
$(".operation").click(function () {
$("#input-origin").insertContent($(this).attr("do"));
$(".latex-formula").html($("#input-origin").val());
MathJax.typesetPromise();
})
$("#inline-formula").click(function () {
$("#input-origin").val($("#input-origin").val().trim().replace(/\$/g, ""))
$("#input-origin").val("$ " + $("#input-origin").val().trim() + " $")
$(".latex-formula").html($("#input-origin").val());
MathJax.typesetPromise();
})
$("#block-formula").click(function () {
$("#input-origin").val($("#input-origin").val().trim().replace(/\$/g, ""))
$("#input-origin").val("$$ " + $("#input-origin").val().trim() + " $$")
$(".latex-formula").html($("#input-origin").val());
MathJax.typesetPromise();
})
function downloadString(text, fileType, fileName) {
var blob = new Blob([text], { type: fileType });
var a = document.createElement('a');
a.download = fileName;
a.href = URL.createObjectURL(blob);
a.dataset.downloadurl = [fileType, a.download, a.href].join(':');
a.style.display = "none";
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
setTimeout(function () { URL.revokeObjectURL(a.href); }, 1500);
}
$("#save-svg").click(function () {
downloadString(document.getElementsByTagName("svg")[0].outerHTML, "image/svg", "save.svg")
})
</script>
</body>
<script>
$(".operate-area .show-area").css("width", $(".operate-area .input-area").width() + "px");
$(".operate-area .show-area").css("height", $(".operate-area .input-area").height() + "px");
$(".operate-area .input-area").mousemove(function () {
$(".operate-area .show-area").css("width", $(".operate-area .input-area").width() + "px");
$(".operate-area .show-area").css("height", $(".operate-area .input-area").height() + "px");
});
</script>
</html>