-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathlearn-plover.html
161 lines (146 loc) · 4.63 KB
/
learn-plover.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Learn Plover Lessons</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-plover.js"></script>
<script src="plover-translations.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 Plover Exercises</h1>
<div class="form-section">
<form id="selectDrill">
<ul style="list-style-type: none">
<li><select name="drill" multiple></select></li>
<li><label><input name="hints" type="checkbox" value="yes" checked> Show hints?</label></li>
<li><label><input id="randomly" name="type" type="radio" value="randomly"> Randomly</label> for <input name="timeLimit" type="text" size="2", value="10" onfocus="selectRandomly()"> minutes.</li>
<li><label><input id="ordered" name="type" type="radio" value="once" checked> Once in order.</label></li>
<li><label><input id="shuffled" name="type" type="radio" value="shuffled"> Once in random order.</label></li>
<li><label><input name="wpm" type="number" value="" step="5"> Speed (WPM).</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>
<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() {
if(document.location.search === '') {
var form = document.getElementById('selectDrill');
var drill = form.elements.drill;
var order = TypeJig.WordSets.LearnPloverOrder;
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.LearnPlover;
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);
translations['says'] = "SEZ";
var hints = new StenoDisplay(strokes, translations, true);
}
fields.menu = 'learn-plover'
displayOnly('lesson');
var jig = setExercise(exercise.name, exercise, hints, fields);
}
}
}
function selectRandomly() {
var form = document.getElementById('selectDrill');
form.elements.type[0].checked = true;
}
function saveFormState(form) {
let radioButtons = document.getElementById('selectDrill').elements['type']
let drillType
for(let i=0; i<radioButtons.length; ++i) {
if(radioButtons[i].checked) {
drillType = radioButtons[i].value
break
}
}
save({
drill: form.drill.value,
hints: form.hints.checked,
type: drillType,
timeLimit: form.timeLimit.value,
});
}
function loadFormState(form) {
var loaded = load();
if(loaded.drill != null) {
form.drill.value = loaded.drill;
}
if(loaded.hints != null) form.hints.checked = !!loaded.hints;
if(loaded.type != null) {
let radioButtons = document.getElementById('selectDrill').elements['type']
for(let i=0; i<radioButtons.length; ++i) {
let b = radioButtons[i]
b.checked = (b.value === loaded.type)
}
}
form.type.value = loaded.type;
if (loaded.timeLimit) {
form.timeLimit.value = loaded.timeLimit;
}
}
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>