forked from TG1999/speedtyper
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
80 lines (74 loc) · 1.48 KB
/
Copy pathscript.js
File metadata and controls
80 lines (74 loc) · 1.48 KB
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
arr=['hello','bye','tushar'];
cnt=0;
n=3
p=5
str=arr[cnt];
word1=[];
var qwerty='';
for(var element in str)
{
qw=`<t id=${element}>`+str[element]+'</t>'
word1.push(qw);
}
document.getElementById('test').innerHTML=word1.join('');
document.getElementById('t1').onkeyup=function(){abc()};
if(p==0)
{
console.log('DONE')
}
var count=0; // Count in Array of Letters
merac=0
function changeGreen(count)
{
document.getElementById(count).style.color='green';
merac++
console.log(merac)
}
function changeRed(count)
{
document.getElementById(count).style.color='red';
}
l2=0;
function check(){
if(merac==word1.length)
{
cnt++;
str=arr[cnt];
count=0;
merac=0
l2=0
word1=[]
for(var element in str)
{
qw=`<t id=${element}>`+str[element]+'</t>'
word1.push(qw);
}
document.getElementById('test').innerHTML=word1.join('');
document.getElementById('t1').value=''
}
}
function abc(){
word=document.getElementById('t1').value;
l2++;
qwerty=word[word.length-1];
l1=word.length;
if(l1==count+1)
{
if(str[count]===qwerty)
{
count++;
changeGreen(count-1);
}
else
{
count++;
changeRed(count-1);
}
}
else
{
document.getElementById(count-1).style.color='black';
count--;
}
check();
}