-
Notifications
You must be signed in to change notification settings - Fork 0
/
my.js
50 lines (42 loc) · 1020 Bytes
/
my.js
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
$(function() {
var buffer = '';
$('#a').on('input', function () {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
});
function flush() {
if (buffer == $("#a").val()) {
console.log('!');
return;
}
buffer = $("#a").val();
$.ajax({
type: "POST",
url: "parser.php",
data: {"text": buffer},
success: function(data) {
$("#b").html(data);
// refresh mathjax in '#b'
MathJax.Hub.Queue(["Typeset", MathJax.Hub, "b"]);
}
});
}
// init '#a'
$.ajax({
type: "GET",
url: "demo.md",
success: function(data) {
$("#a").html(data);
flush();
}
});
$('#a').focusout(function() {
flush();
});
shortcut.add("F8",function() {
flush();
});
shortcut.add("Ctrl+Enter",function() {
flush();
});
});