forked from misho104-obsolete/spritz-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
120 lines (116 loc) · 3.04 KB
/
index.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
<html>
<head>
<title>Speed Reading.</title>
<link rel="stylesheet" href="jquery-ui.min.css">
<link rel="stylesheet" href="jquery.highlighttextarea.css">
<script type="text/javascript" src="jquery-2.1.0.min.js"></script>
<script src="jquery-ui.min.js"></script>
<script src="jquery.highlighttextarea.js"></script>
<script type="text/javascript" src="open-spritz.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
var wpm = 1;
$('#go').on('click', function() {
if($('#go').html() == "Start") {
wpm = parseInt($('#wpm').val(), 10);
$("#go").html('Pause');
ospritz.init($('#text'), wpm, $('#word'));
} else if ($('#go').html() == "Pause") {
$("#go").html('Resume');
ospritz.pause();
} else if ($('#go').html() == "Resume") {
$("#go").html('Pause');
ospritz.resume();
}
});
$('#restart').on('click', function() {
ospritz.pause();
ospritz.abort();
wpm = parseInt($('#wpm').val(), 10);
$("#go").html('Pause');
ospritz.init($('#text'), wpm, $('#word'));
});
$(document).keydown(function(e) {
if (e.which == 32){//space bar
var a = e.target;
var b = $('#text')[0];
if (a != b) {
e.preventDefault();
if ($('#go').html() == "Pause") {
$("#go").html('Resume');
ospritz.pause();
} else if ($('#go').html() == "Resume") {
$("#go").html('Pause');
ospritz.resume();
}
}
} else if (e.which == 37){//left arrow
var a = e.target;
var b = $('#text')[0];
if (a != b) {
e.preventDefault();
ospritz.left();
}
} else if (e.which == 39){//right arrow
var a = e.target;
var b = $('#text')[0];
if (a != b) {
e.preventDefault();
ospritz.right();
}
} else if (e.which == 38){//up arrow
var a = e.target;
var b = $('#text')[0];
if (a != b) {
e.preventDefault();
ospritz.up();
}
} else if (e.which == 40){//down arrow
var a = e.target;
var b = $('#text')[0];
if (a != b) {
e.preventDefault();
ospritz.down();
}
}
});
$('#text').focus();
});
</script>
<style>
#word {
height: 40px;
font-size: 26px;
}
#word > .container {
vertical-align: middle;
}
.left {
width: 100px;
display: inline-block;
}
.left > .text {
float: right;
}
.pivot {
color: red;
}
#text {
width: 100%;
}
</style>
</head>
<body style="background-color:black;color:white;">
<input id="wpm" type="text" value="500" size="10" style="width:50px;"/> wpm: <button id="go" type="button">Start</button><button id="restart" type="button">Restart</button>
<hr>
Paste your text below.
<textarea id="text" rows="15"></textarea>
<br/><br/>
<center>
<div id="word" style="background-color:white;color:black;">
<span class="left container"><span class="text"></span></span><span class="pivot container"></span><span class="right container"></span>
</div>
</center>
</body>
</html>