-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathintro.html
149 lines (133 loc) · 4.05 KB
/
intro.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Introductory 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="intro.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>Introductory Lessons</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>Randomly</label> for <input name="timeLimit" type="text" size="2", value="1"> minutes.</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 = Object.keys(TypeJig.WordSets.Intro)
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 {
let L = document.getElementById('lesson')
L.style['max-width'] = '22em'
var fields = parseQueryString(document.location.search)
TypeJig.WordSets = TypeJig.WordSets.Intro
let drills = Array.isArray(fields.drill) ? fields.drill : [fields.drill]
let alternate = null
for(let drill of drills) {
let d = TypeJig.WordSets[drill]
if(d.alternate) { alternate = d.alternate; break }
}
fields.type = "randomly"
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['will'] = 'WEUL'
var hints = new StenoDisplay(strokes, translations, true)
}
var options = {
wpm: fields.wpm,
cpm: fields.cpm,
alternate: fields.alternate,
live_wpm: fields.live_wpm,
}
displayOnly('lesson')
var jig = setExercise(exercise.name, exercise, hints, options)
}
}
}
function saveFormState(form) {
save({
drill: form.drill.value,
hints: form.hints.checked,
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.timeLimit) {
form.timeLimit.value = loaded.timeLimit
}
}
var LOCAL_STORAGE_KEY = "intro-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>