This repository has been archived by the owner on Jul 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.html
217 lines (196 loc) · 6.01 KB
/
test.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<html>
<head>
<meta charset="utf-8">
<style>
body {
font-family: monospace;
line-height: 1.4;
}
program {
display: inline-block;
float: left;
margin-right: 20px;
}
program > line {
display: block;
}
program > line > text {
white-space: pre;
}
program > line > number {
text-align: right;
padding-right: 4px;
color: cornflowerblue;
}
microViz {
display: inline-block;
padding-left: 10px;
border-left: 1px dashed cornflowerblue;
}
microViz event,
microViz send,
microViz localEventGroup,
microViz remoteEventGroup,
microViz spacerGroup,
microViz spacer {
display: inline-block;
float: left;
}
microViz localEventGroup,
microViz remoteEventGroup {
margin-right: 10px;
}
microViz spacerGroup {
border-color: green;
}
microViz remoteEventGroup {
opacity: 0.65;
}
microViz .newline,
microViz spacer {
clear: left;
}
microViz send.empty > spacerGroup > spacer:first-child::before {
color: hsl(0, 0%, 50%);
content: '·';
}
microViz localEventGroup,
microViz remoteEventGroup {
border: 1px solid cornflowerblue;
border-radius: 4px;
padding: 0 2px;
}
microViz send {
border: 1px solid red;
border-radius: 4px;
padding: 0 2px;
}
microViz spacerGroup {
border: 1px solid green;
border-radius: 4px;
padding: 0 2px;
}
microViz spacer::before {
_content: '(spacer)';
color: hsl(0, 0%, 70%);
}
</style>
</head>
<body>
<program>
<line startLine="1" endLine="1">
<number>1</number>
<text>var sum = 0;</text>
</line>
<line startLine="2" endLine="2">
<number>2</number>
<text></text>
</line>
<line startLine="3" endLine="3">
<number>3</number>
<text>for 1 to: 3 do: {x |</text>
</line>
<line startLine="4" endLine="4">
<number>4</number>
<text> sum = sum + x;</text>
</line>
<line startLine="5" endLine="5">
<number>5</number>
<text> if x == 2 then: {</text>
</line>
<line startLine="6" endLine="6">
<number>6</number>
<text> f();</text>
</line>
<line startLine="7" endLine="7">
<number>7</number>
<text> };</text>
</line>
<line startLine="8" endLine="8">
<number>8</number>
<text>};</text>
</line>
</program>
<microviz>
<localEventGroup>
<event class="newline" startLine="1" endLine="1">sum = 0</event>
<spacer startLine="2" endLine="2"></spacer>
<send class="newline" startLine="3" endLine="8">
<spacerGroup>
<spacer startLine="3" endLine="3"></spacer>
<spacer startLine="4" endLine="4"></spacer>
<spacer startLine="5" endLine="5"></spacer>
<spacer startLine="6" endLine="6"></spacer>
<spacer startLine="7" endLine="7"></spacer>
<spacer startLine="8" endLine="8"></spacer>
</spacerGroup>
<localEventGroup>
<event class="newline" startLine="3" endLine="3">x = 1</event>
<event class="newline" startLine="4" endLine="4">sum = 1</event>
<send class="newline empty" startLine="5" endLine="7">
<spacerGroup>
<spacer startLine="5" endLine="5"></spacer>
<spacer startLine="6" endLine="6"></spacer>
<spacer startLine="7" endLine="7"></spacer>
</spacerGroup>
</send>
</localEventGroup>
<localEventGroup>
<event class="newline" startLine="3" endLine="3">x = 2</event>
<event class="newline" startLine="4" endLine="4">sum = 3</event>
<send class="newline" startLine="5" endLine="7">
<spacerGroup>
<spacer startLine="5" endLine="5"></spacer>
<spacer startLine="6" endLine="6"></spacer>
<spacer startLine="7" endLine="7"></spacer>
</spacerGroup>
<localEventGroup>
<spacer startLine="5" endLine="5"></spacer>
<send class="newline" startLine="6" endLine="6">
<remoteEventGroup>
<event class="newline" startLine="6" endLine="6">a = 1</event>
<event class="newline" startLine="6" endLine="6">b = 2</event>
<event class="newline" startLine="6" endLine="6">c = 3</event>
</remoteEventGroup>
</send>
</localEventGroup>
</send>
</localEventGroup>
<localEventGroup>
<event class="newline" startLine="3" endLine="3">x = 3</event>
<event class="newline" startLine="4" endLine="4">sum = 6</event>
<send class="newline empty" startLine="5" endLine="7">
<spacerGroup>
<spacer startLine="5" endLine="5"></spacer>
<spacer startLine="6" endLine="6"></spacer>
<spacer startLine="7" endLine="7"></spacer>
</spaceGroup>
</send>
</localEventGroup>
</send>
</localEventGroup>
</microviz>
<script>
const elements = [].slice.call(document.querySelectorAll('*[startLine][endLine]'));
for (let lineNumber = 1; lineNumber <= 8; lineNumber++) {
const top = elements.
filter(element => element.getAttribute('startLine') == lineNumber).
map(element => element.getBoundingClientRect().top).
reduce((x, y) => Math.min(x, y));
const bottom = elements.
filter(element => element.getAttribute('endLine') == lineNumber).
map(element => element.getBoundingClientRect().bottom).
reduce((x, y) => Math.max(x, y));
const height = bottom - top;
const line = document.querySelector('line[startLine="' + lineNumber + '"]');
const marginBottom = height - line.clientHeight;
line.style.marginBottom = marginBottom;
const spacers = [].slice.call(document.querySelectorAll(
'spacer[startLine="' + lineNumber + '"][endLine="' + lineNumber + '"]'));
spacers.forEach(spacer => {
spacer.style.marginBottom = height - spacer.clientHeight;
});
}
</script>
</body>
</html>