-
Notifications
You must be signed in to change notification settings - Fork 0
/
wordcount.html
170 lines (133 loc) · 3.98 KB
/
wordcount.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
/* Created by Devi Prasad */
* {
margin-top: 0px;
margin-bottom: 0px;
}
body {
background-color: rgb(81, 255, 240);
animation: changebg 5s infinite alternate linear;
}
@keyframes changebg {
0% {
background: #55eee9;
}
25% {
background: #60d394;
}
50% {
background: #aaf683;
}
75% {
background: #d0ed40;
}
100% {
background: #ff9b85;
}
}
#outer {
display: flex;
flex-direction: row;
justify-content: center;
margin-top: 2.4cm;
margin-right: 20px;
margin-left: 11px;
box-shadow: 4px 4px 6px black;
}
#inbox {
height: 11cm;
width: 18cm;
background-color: rgb(218, 252, 235);
border-radius: 0px 100px 0px 100px;
}
#input {
position: relative;
margin-left: 20%;
margin-top: 9%;
height: 3.5cm;
width: 5cm;
border-radius: 5px 20px 5px 20px;
box-shadow: 4px 4px 6px black;
}
h2 {
margin-left: 25%;
}
h4 {
margin-top: 5px;
margin-left: 23%;
color: rgb(19, 21, 139);
animation-name: ul;
animation-duration: 2s;
animation-iteration-count: infinite;
}
@keyframes ul {
from {
text-decoration: none;
}
to {
text-decoration: underline;
}
}
a {
text-decoration: none;
color: white;
margin-left: 28%;
border-radius: 15px;
background-color: black;
padding: 10px;
border-radius: 10px 0px 10px 0px;
transition: all 0.5s ease-in;
}
a:hover {
background-color: green;
box-shadow: 4px 4px 6px black;
padding: 15px 15px 15px 15px;
}
</style>
</head>
<body>
<div id="outer">
<div id="inbox">
<h4>Created by Devi Prasad</h4>
<br>
<textarea id="input" rows="15"></textarea>
<br><br>
<h2>Words count <span id="count">0</span></h2>
<br>
<h2>Letters count <span id="letcount">0</span></h2>
<br><br>
<!-- <a href="https://youtube.com/c/DeviprasadVlogs">Click to subscribe</a> -->
</div>
</div>
<script>
let textArea = document.getElementById('input');
let wordCount = document.getElementById('count');
let letterCount = document.getElementById('letcount');
function letterCounter() {
let text = textArea.value.trim();
let count = 0;
for (let i = 1; i <= text.length; i++) {
count++;
}
letterCount.innerText = count;
}
setInterval(letterCounter);
function wordCounter() {
let count=0;
let str = textArea.value;
let arr = str.split(" ");
let arr1=arr.filter((element) =>{return element.length!==0;})
console.log(arr);
count = (str.split(" ").filter((a)=>{return a.length!==0;} )).length
wordCount.innerText=count;
}
setInterval(wordCounter,5000)
</script>
</body>
</html>