-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextAnalyzer.js
More file actions
47 lines (38 loc) · 1.62 KB
/
textAnalyzer.js
File metadata and controls
47 lines (38 loc) · 1.62 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
//console.log("Machine Starting");
uppercase.addEventListener("click", () => {
console.log("Changing characters into Uppercase");
inputText.value = inputText.value.toUpperCase()
})
lowercase.addEventListener("click", () => {
console.log("Changing characters into Lowercase");
inputText.value = inputText.value.toLowerCase()
})
extraSpace.addEventListener("click", () => {
console.log("Removing Extra Spaces");
inputText.value = inputText.value.replace(/\s+/g, ' ').trim();
})
//https://stackoverflow.com/questions/38698670/removing-blank-lines-from-textarea-with-jquery
extraLine.addEventListener("click", () => {
console.log("Removing Extra Lines");
inputText.value = inputText.value.replace(/^\s*$(?:\r\n?|\n)/gm, "");
})
charWordCount.addEventListener("click", () => {
console.log("New character and word count");
const characters = inputText.value.length;
const words = inputText.value.trim().replace(/\s+/gi, ' ').split(" ").length;
document.getElementById("characterCount").value = characters;
document.getElementById("wordCount").value = words
})
clearAll.addEventListener("click", () => {
console.log("Clearing Full Page");
inputText.value = "";
document.getElementById("characterCount").value = "";
document.getElementById("wordCount").value = "";
})
inputText.addEventListener("input", () => {
console.log("changed");
const characters = inputText.value.length;
const words = inputText.value.trim().replace(/\s+/gi, ' ').split(" ").length;
document.getElementById("characterCount").value = characters;
document.getElementById("wordCount").value = words
})