Skip to content

Commit 2ee9ae1

Browse files
committed
Add example selector
1 parent aab9968 commit 2ee9ae1

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ outdated and/or uncomfortable user interfaces.
2222
## Try it
2323

2424
This is a browser-based application. A fully functional build is available
25-
[here](https://fbbdev.it/turing/).
25+
[here](https://fbbdev.it/turing/?view=3).
2626
For a guide to the [description language](#description-language) and some
2727
[examples](#examples), see below.
2828

dist/css/app.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ body > nav > .uk-tab::before {
145145
content: counter(trace-step-number);
146146
}
147147

148+
#examples-view {
149+
padding: 30px;
150+
}
151+
152+
#examples-view .uk-accordion-title {
153+
font-size: 14px;
154+
text-transform: uppercase;
155+
}
156+
148157
#editor {
149158
position: relative;
150159

dist/index.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<li class="uk-active"><a href="#">Diagram</a></li>
1919
<li><a href="#">Table</a></li>
2020
<li><a href="#">Trace</a></li>
21+
<li><a href="#">Examples</a></li>
2122
</ul>
2223
<div class="grow"></div>
2324
<div class="uk-button-group">
@@ -46,6 +47,35 @@
4647
<tbody></tbody>
4748
</table>
4849
</li>
50+
<li id="examples-view">
51+
<ul uk-accordion>
52+
<li>
53+
<a class="uk-accordion-title" href>Unary multiplication by 2</a>
54+
<div class="uk-accordion-content">
55+
<p>A machine that reads from the tape an integer in unary notation (n is represented by a list of n occurrences of the symbol 1) and writes it back doubled.</p>
56+
<p><a href="?fetch=https%3A%2F%2Fraw.githubusercontent.com%2Ffbbdev%2Fturing%2Fmain%2Fexamples%2FunaryDup.txt">Load in the simulator</a></p>
57+
<p><i>Instructions:</i> click the link above; when the machine has been loaded, click the tape head (the cell with a large black border), type <code>1</code> as many times as you like, press the <code>Enter</code> key and hit the play button.</p>
58+
</div>
59+
</li>
60+
<li>
61+
<a class="uk-accordion-title" href>Binary increment by one</a>
62+
<div class="uk-accordion-content">
63+
<p>A machine that reads from the tape an integer in binary notation and writes it back incremented by one.</p>
64+
<p><a href="?fetch=https%3A%2F%2Fraw.githubusercontent.com%2Ffbbdev%2Fturing%2Fmain%2Fexamples%2FbinaryIncr.txt">Load in the simulator</a></p>
65+
<p><i>Instructions:</i> click the link above; when the machine has been loaded, click the tape head (the cell with a large black border), type a sequence of <code>1</code>s and <code>0</code>s, press the <code>Enter</code> key and hit the play button.</p>
66+
<p>After the machine halts, if you hit the stop button, then the play button again it will keep incrementing the number more and more.</p>
67+
</div>
68+
</li>
69+
<li>
70+
<a class="uk-accordion-title" href>Binary addition</a>
71+
<div class="uk-accordion-content">
72+
<p>A machine that reads from the tape two integers in binary notation, separated by a blank, and writes back their sum.</p>
73+
<p><a href="?fetch=https%3A%2F%2Fraw.githubusercontent.com%2Ffbbdev%2Fturing%2Fmain%2Fexamples%2FbinaryAdd.txt">Load in the simulator</a></p>
74+
<p><i>Instructions:</i> click the link above; when the machine has been loaded, click the tape head (the cell with a large black border), type a sequence of <code>1</code>s and <code>0</code>s, press <code>Space</code>, then type again a sequence of <code>1</code>s and <code>0</code>s, press the <code>Enter</code> key and hit the play button.</p>
75+
</div>
76+
</li>
77+
</ul>
78+
</li>
4979
</ul>
5080
</div>
5181
<div id="editor">

src/index.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,14 @@ class App {
12551255
this.tapeResizeObserver.observe(this.tape);
12561256

12571257
const params = new URLSearchParams(window.location.search);
1258+
if (params.has('view')) {
1259+
try {
1260+
UIkit.tab(document.querySelector('body > nav > *[uk-tab]')).show(parseInt(params.get('view')));
1261+
} catch (_) {
1262+
// Discard parseInt exception
1263+
}
1264+
}
1265+
12581266
if (!params.has('fetch'))
12591267
return;
12601268

0 commit comments

Comments
 (0)