-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.html
71 lines (49 loc) · 1.82 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
<html>
<head>
<title>MathCell</title>
<link rel="stylesheet" type="text/css" href="docs/style.css">
<meta name="google-site-verification" content="CF-4-ituiQgPq9WZpTcf5EYUTQhRrkZN0w9R6u6SmsE" />
</head>
<body>
<p style="text-align: center; line-height: 2"><span style="font-size: 20pt">MathCell</span></p>
<p style="text-align: center">
<a href="docs/index.html">documentation</a> ·
<a id="example" href="">this example</a>
</p>
<!-- use iframe to execute dynamically added script -->
<iframe id="view" style="width: 100%; height: 4.5in; border: 0" scrolling="no"
onload="this.style.height=this.contentWindow.document.body.scrollHeight+50"></iframe>
<script>
var xhr = new XMLHttpRequest();
xhr.open( 'GET', 'https://api.github.com/repos/paulmasson/mathcell/contents/docs/examples', true );
xhr.onload = function() {
var files = JSON.parse( xhr.response );
var fileList = [];
for ( var i = 0 ; i < files.length ; i++ ) fileList.push( files[i].name );
var index = Math.floor( fileList.length * Math.random() );
example.href = 'docs/examples/' + fileList[index];
xhr.open( 'GET', example.href, true );
xhr.onload = function() {
var parser = new DOMParser();
var dom = parser.parseFromString( this.response, 'text/html' );
var cell = dom.getElementsByClassName( 'mathcell' )[0];
var math = this.response.includes( 'math.js' ) ? `
<script src="../math/build/math.js"><\/script>` : '';
var mathjax = this.response.includes( 'mathjax' ) ? `
<script src="https://cdn.jsdelivr.net/gh/mathjax/MathJax@2.7.5/MathJax.js?config=TeX-AMS_HTML"><\/script>` : '';
var view = document.getElementById( 'view' );
view.srcdoc = `
<html>
<body>
<script src="build/mathcell.js"><\/script> ${math} ${mathjax}
${cell.outerHTML}
</body>
</html>
`;
}
xhr.send();
}
xhr.send();
</script>
</body>
</html>