-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathstarting.html
79 lines (50 loc) · 1.83 KB
/
starting.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
<html>
<head>
<title>MathCell - Starting</title>
<link rel="stylesheet" type="text/css" href="style.css">
<style>
textarea {
position: absolute;
top: -100%;
}
</style>
</head>
<body>
<p>Here are two simple examples to get started:</p>
<table style="width: 4in; margin: auto"><tr><td>
<a href="examples/hello-world-svg.html">Hello World! SVG</a>
</td><td>
<a href="examples/hello-world-threejs.html">Hellow World! Three.js</a>
</td></tr></table><br>
<p>For more complicated applications, <button onclick="copyTemplate()">copy</button> this template into the body of the page:</p>
<script>
function copyTemplate() {
var textArea = document.createElement( 'textarea' );
textArea.textContent = document.getElementById( 'template' ).textContent + '\n';
document.body.append( textArea );
textArea.select();
document.execCommand( 'copy' );
}
</script>
<pre id="template">
<div class="mathcell" style="height: 4in">
<script>
var parent = document.currentScript.parentNode;
var id = generateId();
parent.id = id;
MathCell( id, [ { type: '' } ] );
parent.update = function( id ) {
var x = getVariable( id, 'x' );
var data = [];
// additional JavaScript here
var config = { type: '' };
evaluate( id, data, config );
}
parent.update( id );
</script>
</div>
</pre>
<p>The template automatically assigns an <code>id</code> to each cell, which is then available to the interactive input elements that are added to the cell. This relieves the end user of the need to manually add tags to cells.</p>
<p>Input elements are specified as an array of dictionaries inside the <code>MathCell()</code> command. Code for processing the input is added to the body of the <code>update()</code> function. The output element is specified in the <code>config</code> dictionary inside the <code>update</code> function.</p>
</body>
</html>