-
Notifications
You must be signed in to change notification settings - Fork 11
/
ADocument.html
147 lines (145 loc) · 5.41 KB
/
ADocument.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
<div class = "ampleforthDocumentClass" name = "ADocument" classBody = "() (
notAFragment = (^33)
testButton1 = (^button: #TestButton1 action: ['testing' out])
testButton2 = (^button: #TestButton2 action: ['testing' out])
testButton3 = (^button: #TestButton3 action: ['testing' out])
testButton4 = (^button: #TestButton4 action: ['testing' out])
toggle = (^expanded: (testButton4) collapsed: (label: 'open'))
) : (
)
" </div><div class = "ampleforthDocumentBody">
<div contenteditable="true"
style="border: 2px solid blue; resize: horizontal; overflow: auto"
onkeyup="updateRawHTML()" >
<h1> A Sample Document</h1> This is a <div class="ampleforth"
name="testButton1" contenteditable="false"></div>
embedded in a document!
And here is another one: <span class="ampleforth" name="testButton2"
contenteditable="false"></span> and another
<div class="ampleforth" name="testButton3" contenteditable="false"></div>
<h3> Maintaining State</h3>
Here is a toggle that maintains its state while we edit:
<div class="ampleforth" name="toggle" contenteditable="false"></div>
Let us add another widget <span class="ampleforth"
name="testButton4" contenteditable="false"></span>
<h3>Dealing with Errors</h3>
What if the expression given in the document does not evaluate to a
Fragment?
<br>
If it evaluates without error, we place an
error message that links to an inspector on the result in the
document.
<br>
<div class="ampleforth" name="notAFragment" contenteditable="false"></div>
<br>
Consider a bad selector in the <i>name</i> attribute of an <i>ampleforth</i> node.
<br>
<div class="ampleforth" name="foo" contenteditable="false"></div>
<br>
If the expression does not compile at all, what do we do?
<br>No longer an
issue in the new design.
<br>
Likewise if the <i>initializer</i> attribute is missing.
<br>
Another interesting situation is recursion, as attempted below, which yields an informative error message:
<br>
<div class="ampleforth" name="AmpleforthTargetDocument" contenteditable="false"></div>
</div>
<br>
</div>
</div><script type="text/javascript">
function scheduleTurn(timeout) {
if (timeout >= 0) {
setTimeout(function() {
var timeout = Module._handle_message();
scheduleTurn(timeout);
}, timeout);
}
}
var Module = {
noInitialRun: true,
noExitRuntime: true,
onRuntimeInitialized: function() {
var url = new URLSearchParams(window.location.search);
var request = new XMLHttpRequest();
request.open("GET", url.get("snapshot"), true);
request.responseType = "arraybuffer";
request.onload = function (event) {
var jsBuffer = new Uint8Array(request.response);
var cBuffer = _malloc(jsBuffer.length);
writeArrayToMemory(jsBuffer, cBuffer);
Module._load_snapshot(cBuffer, jsBuffer.length);
_free(cBuffer);
scheduleTurn(0);
};
request.send();
},
print: function(text) {
if (arguments.length > 1) {
text = Array.prototype.slice.call(arguments).join(" ");
}
console.log(text);
},
printErr: function(text) {
if (arguments.length > 1) {
text = Array.prototype.slice.call(arguments).join(" ");
}
console.error(text);
},
setStatus: function(text) {
console.log(text);
},
};
</script>
<script async="" type="text/javascript" src="primordialsoup.js"></script>
<script src="CodeMirror/lib/codemirror.js"></script>
<link rel="stylesheet" href="CodeMirror/lib/codemirror.css">
<script src="CodeMirror/addon/display/autorefresh.js"></script></div> <script type="text/javascript">
function scheduleTurn(timeout) {
if (timeout >= 0) {
setTimeout(function() {
var timeout = Module._handle_message();
scheduleTurn(timeout);
}, timeout);
}
}
var Module = {
noInitialRun: true,
noExitRuntime: true,
onRuntimeInitialized: function() {
var url = new URLSearchParams(window.location.search);
var request = new XMLHttpRequest();
request.open("GET", url.get("snapshot"), true);
request.responseType = "arraybuffer";
request.onload = function (event) {
var jsBuffer = new Uint8Array(request.response);
var cBuffer = _malloc(jsBuffer.length);
writeArrayToMemory(jsBuffer, cBuffer);
Module._load_snapshot(cBuffer, jsBuffer.length);
_free(cBuffer);
scheduleTurn(0);
};
request.send();
},
print: function(text) {
if (arguments.length > 1) {
text = Array.prototype.slice.call(arguments).join(" ");
}
console.log(text);
},
printErr: function(text) {
if (arguments.length > 1) {
text = Array.prototype.slice.call(arguments).join(" ");
}
console.error(text);
},
setStatus: function(text) {
console.log(text);
},
};
</script>
<script async type="text/javascript" src="primordialsoup.js"></script>
<script src="CodeMirror/lib/codemirror.js"></script>
<link rel="stylesheet" href="CodeMirror/lib/codemirror.css"></link>
<script src="CodeMirror/addon/display/autorefresh.js"></script>