-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathlearn-keyboard.html
175 lines (159 loc) · 5.24 KB
/
learn-keyboard.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Learn the Steno Keyboard</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script src="type-jig.js"></script>
<script src="util.js"></script>
<script src="word-drill.js"></script>
<script src="steno-display.js"></script>
<script src="learn-keyboard.js"></script>
<script src="chart.js"></script>
<link rel="stylesheet" type="text/css" href="font-roboto.css">
</head>
<body>
<div class="wrapper">
<div id="form">
<h1>Learn the Steno Keyboard</h1>
<p style="text-align: center"><a href="raw-steno-instructions.html">How to get raw steno output</a></p>
<div class="form-section">
<form id="selectDrill">
<ul style="list-style-type: none">
<li><select name="drill"></select></li>
<li><label><input name="count" type="number" value="100"> Length (number of chords).</label></li>
<li><label><input name="hints" type="checkbox" value="yes" checked> Show hints?</label></li>
<li><label><input name="wpm" type="number" value="" step="5"> Speed (strokes per minute).</label></li>
<li><input type="submit" value="Go"></li>
</ul>
</form>
</div>
</div>
</div>
<div id="lesson" class="wrapper" style="display: none">
<div id="leftside">
<h3 id="lesson-name" class="center"></h3>
<p style="text-align: center; padding-bottom: 3em"><a href="raw-steno-instructions.html">How to get raw steno output</a></p>
<div id="drill-content">
<div id="answer"></div>
<div id="exercise"></div>
<div id="results"></div>
</div>
</div>
<textarea id="input"></textarea>
<div id="nav">
<p id="strokes"></p>
<p id="clock" class="clock"></p>
<p id="live-wpm-display" class="wpm"></p>
<p class="center"><a id="again" title="Enter">↺ Restart <span class="shortcutkey">(Enter 3x)</span></a></p>
<p class="center"><a id="back" title="LeftArrow">← Back to Menu <span class="shortcutkey">(LeftArrow)</span></a></p>
</div>
</div>
<script>
window.onload = function() {
var leftFromPseudo = {
'C': 'KR',
'D': 'TK', 'B': 'PW', 'L': 'HR',
'F': 'TP', 'M': 'PH', 'N': 'TPH',
'Q': 'KW', 'Y': 'KWR', 'J': 'SKWR', 'V': 'SR',
'G': 'TKPW', 'X': 'KP', 'Z': 'STKPW'
};
var vowelFromPseudo = {
'AY': 'AEU', 'OH': 'OE', 'EE': 'AOE', 'UU': 'AOU',
'I': 'EU', 'IE': 'AOEU',
'AW': 'AU', 'OW': 'OU', 'OI': 'OEU',
'EA': 'AE', 'OA': 'AO', 'OO': 'AO'
};
var rightFromPseudo = {
'TH': '*T', 'CH': 'FP', 'SH': 'RB', 'RCH': 'FRPB',
'N': 'PB', 'NG': 'PBG', 'NK': 'PBG',
'M': 'PL', 'K': 'BG', 'SHN': 'GS', 'KSHN': 'BGS',
'J': 'PBLG', 'RBGS': 'RBGS'
};
var left_re = /C|L|G|Z|N|J|X|B|V|F|Y|Q|D|M|0|1|2|3|4|5|6|7|8|9|S|T|K|P|W|H|R/g;
var vowel_re = /AY|OA|OO|AW|EA|EE|OH|UU|OI|IE|OW|I|0|1|2|3|4|5|6|7|8|9|A|O|E|U/g;
var right_re = /RBGS|KSHN|SHN|RCH|CH|SH|NG|NK|TH|K|J|N|M|0|1|2|3|4|5|6|7|8|9|\*|F|R|P|B|L|G|T|S|D|Z/g;
var separation_re = /([^AOEUI*-]*)([AO*EUI-][AO*EUIHYW-]*|)(.*)/;
function fromPseudo(stroke) {
match = separation_re.exec(stroke);
var b = match[1], v = match[2], e = match[3];
var left = b.replace(left_re, function(m) { return leftFromPseudo[m] || m; });
var vowel = v.replace(vowel_re, function(m) { return vowelFromPseudo[m] || m; });
var right = e.replace(right_re, function(m) { return rightFromPseudo[m] || m; });
return (left+vowel+right).replace(/-$/,'')
}
if(document.location.search === '') {
var form = document.getElementById('selectDrill');
var drill = form.elements.drill;
var order = Object.keys(TypeJig.WordSets.LearnKeyboard);
for(var i=0; i<order.length; ++i) {
var option = document.createElement('option');
option.appendChild(document.createTextNode(order[i]));
drill.appendChild(option);
}
drill.focus();
loadFormState(form);
form.addEventListener("submit", function(){
saveFormState(form);
});
} else {
var fields = parseQueryString(document.location.search);
TypeJig.WordSets = TypeJig.WordSets.LearnKeyboard;
var exercise = wordDrill(fields);
if(exercise) {
if(fields.hints) {
var strokes = document.getElementById('strokes');
if(fields.floating_hints) {
strokes.style.position = 'fixed';
}
var translations = TypeJig.shortestTranslations(TypeJig.Translations.Plover);
var hints = new StenoDisplay(strokes, translations, true);
hints.lookupEntry = fromPseudo
}
fields.menu = 'learn-keyboard'
fields.actualWords = {unit: 'strokes per minute', u: 'SPM'}
displayOnly('lesson');
var jig = setExercise(exercise.name, exercise, hints, fields);
jig.match = function(a, b) {
return a == fromPseudo(b)
}
}
}
}
function saveFormState(form) {
save({
drill: form.drill.value,
count: form.count.value,
hints: form.hints.checked,
});
}
function loadFormState(form) {
var loaded = load();
if (loaded.drill) {
form.drill.value = loaded.drill;
}
if(loaded.count) {
form.count.value = loaded.count
}
form.hints.checked = loaded.hints;
}
var LOCAL_STORAGE_KEY = "learn-plover-form";
function save(obj) {
try {
localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(obj));
} catch (e) {
console.error(e);
}
}
function load() {
try {
return JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY)) || {};
} catch (e) {
console.error(e);
return {};
}
}
setTheme()
</script>
</body>
</html>