-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
91 lines (88 loc) · 1.73 KB
/
script.js
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
var randomworld = [
'prisoner',
'bronze',
'union',
'determine',
'gossip',
'infrastructure',
'shaft',
'beef',
'compartment',
'biology',
'extent',
'routine',
'glance',
'operation',
'survey',
'injection',
'build',
'party',
'manufacturer',
'connection',
'skip',
'stall',
'dairy',
'place',
'architect',
'initial',
'nonsense',
'tournament',
'pit',
'cabin',
'straighten',
'banish',
'meeting',
'cane',
'diplomatic',
'camp',
'observer',
'overall',
'direction',
'recording',
'particle',
'paralyzed',
'mind',
'absorption',
'snuggle',
'insurance',
'unlawful',
'dramatic',
'project',
'pity'
];
let word = 0;
const sayHi = () => {
let SymbolInMin = document.getElementById('SymbolMinute');
SymbolInMin.textContent = 'символов в минуту: ' + word;
word = 0;
setTimeout(sayHi, 60000);
}
sayHi();
var myHeading = document.getElementById('entersymbol');
var allWords = randomworld.join(',');
myHeading.textContent = randomworld;
let text = myHeading.textContent;
let splitext = text.split('');
document.addEventListener('keydown', function(event) {
let keypress = event.key.toLowerCase();
let keycolor = document.getElementById(keypress);
console.log(keypress)
if (keypress === splitext[0]) {
let spliced = splitext.splice(0, 1);
myHeading.textContent = splitext.join('');
if (keycolor) {
word++;
keycolor.style.backgroundColor = 'green';
setTimeout(function() {
keycolor.style.backgroundColor = '#fff';
}, 500);
}
} else {
if (keycolor) {
keycolor.style.backgroundColor = 'red';
setTimeout(function() {
keycolor.style.backgroundColor = '#fff';
}, 500);
}
}
});