-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
54 lines (48 loc) · 1.79 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
<script src="https://www.desmos.com/api/v1.3/calculator.js?apiKey=dcb31709b452b1cf9dc26972add0fda6"></script>
<html lang='en'>
<head>
<title>Desmos | Graphing Calculator</title>
<link rel='icon' href='https://www.desmos.com/favicon.ico'>
</head>
<div id="calculator" style="width: 100%; height: 100%;"></div>
<script>
var elt = document.getElementById('calculator');
var calculator = Desmos.GraphingCalculator(elt);
function changeGraph(key, latex, frame) {
while (key > 0) {
calculator.removeExpression({ id: 'expr-' + key });
key--;
}
for (var expr of latex) {
// console.log(expr);
key++;
calculator.setExpression({ id: 'expr-' + key, latex: expr, color: '#2464b4' });
}
return key;
}
function init() {
var key = 0;
var frame = 0;
var top = 0;
var bottom = 0;
var latex;
const interval = setInterval(function() {
if (frame < top) {
key = changeGraph(key, latex.result[frame - bottom], frame);
frame++;
} else {
xhr = new XMLHttpRequest();
xhr.open("GET", `http://127.0.0.1:5000/?frame=${frame}`);
xhr.send();
xhr.onload = function(e) {
latex = JSON.parse(xhr.response);
if (latex.result === null)
clearInterval(interval);
bottom = frame;
top += latex.number_of_frames;
}
}
}, 1000);
}
</script>
</html>