forked from JoshuaGrams/steno-jig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
numbers.html
90 lines (80 loc) · 2.81 KB
/
numbers.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Steno Jig - Number Sentences</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script src="type-jig.js"></script>
<script src="steno-display.js"></script>
<script src="word-sets.js"></script>
<script src="plover-translations.js"></script>
<link rel="stylesheet" type="text/css" href="font-roboto.css">
</head>
<body>
<div id="lesson">
<div class="scroll-margin"><div id="strokes"></div></div>
<div class="scroll-bounds"><div id="exercise" style="white-space: nowrap"></div></div>
<div id="answer" class="answer scroll-margin" contenteditable="true"><span class="prompt">Type here...</span></div>
<p id="clock" class="clock"></p>
</div>
<script>
var exercise = new TypeJig.Exercise([], 15*60);
exercise.nouns = [].concat(TypeJig.WordSets.Nouns);
exercise.actions = [].concat(
TypeJig.WordSets.TransitiveVerbs.map(function(v) { return [v, 'v']; }),
TypeJig.WordSets.Adjectives.map(function(a) { return [a, 'a']; }));
exercise.sentence = [];
randomize(exercise.nouns);
randomize(exercise.actions);
exercise.nextWord = function() {
if(this.sentence.length == 0) this.sentence = this.nextSentence();
return this.sentence.shift();
}
exercise.nextClause = function(num, noun, action, tense) {
if(action[1] === 'v') {
var verb = action[0][tense].split(' ');
var num2 = 1 + randomIntLessThan(99);
var noun2 = rotateAndShuffle(this.nouns);
if(num2 > 1) noun2 = pluralize(noun2);
return [].concat(num+'', noun, verb, num2+'', noun2);
} else {
verb = ["are", "were"];
var adjective = action[0].split(' ');
return [].concat(num+'', noun, verb[tense], adjective);
}
}
exercise.nextSentence = function() {
var type = ['.', '!', '?', ','][randomIntLessThan(4)];
var num = 2 + randomIntLessThan(98);
var noun = pluralize(rotateAndShuffle(this.nouns));
var action = rotateAndShuffle(this.actions);
var tense;
if(type === '?') tense = 0;
else tense = randomIntLessThan(2);
var s = this.nextClause(num, noun, action, tense);
s[s.length-1] += type;
if(type === '?') {
if(action[1] === 'v') {
s.unshift(['Do', 'Did'][randomIntLessThan(2)]);
} else if(action[1] === 'a') {
var verb = ['Are', 'Were'][randomIntLessThan(2)];
s.splice(2, 1);
s.unshift(verb);
}
} else if(type === ',') {
var conj = ['but', 'while', 'so', 'and', 'or'];
s.push(conj[randomIntLessThan(conj.length)]);
var num = 2 + randomIntLessThan(98);
var noun = pluralize(rotateAndShuffle(this.nouns));
var action = rotateAndShuffle(this.actions);
s = s.concat(this.nextClause(num, noun, action, tense));
s[s.length-1] += '.';
}
return s;
}
var translations = TypeJig.shortestTranslations(TypeJig.Translations.Plover);
var hint = new StenoDisplay('strokes', translations, true);
var jig = new TypeJig(exercise, 'exercise', 'answer', 'clock', hint);
</script>
</body>
</html>