-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
66 lines (55 loc) · 2.02 KB
/
Copy pathscript.js
File metadata and controls
66 lines (55 loc) · 2.02 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
let inputText = document.querySelector('.js-input-text');
const maxWords = document.querySelector('.text-max-words');
const btnReset = document.querySelector('.js-reset');
// animation
const mouth = document.querySelector('.mouth');
const split = document.querySelector('.split');
const split1 = document.querySelector('.split1');
const eyeslidsRight = document.querySelector('.eyeslids-right');
const eyeslidsLeft = document.querySelector('.eyeslids-left');
const eyesbrown = document.querySelector('.eyesbrown');
const burp = 'burrrp';
function burpifyText(str) {
return str.replaceAll('e', burp).replaceAll('a', burp);
}
function reset() {
console.log('hi');
inputText.value = '';
document.querySelector('.js-text-translate').innerHTML = '';
maxWords.innerHTML = '';
removeAnimation();
}
// function translateText(str, word = burp) {
// return str.replaceAll('e', word).replaceAll('a', word);
// }
function translateAndRenderText(str) {
const textTranslate = document.querySelector('.js-text-translate');
textTranslate.innerHTML = burpifyText(str);
}
function addAnimation() {
mouth.classList.add('mouth-animation');
split.classList.add('split-animation');
split1.classList.add('split1-animation');
eyeslidsRight.classList.add('eyeslids-animation');
eyeslidsLeft.classList.add('eyeslids-animation');
eyesbrown.classList.add('eyesbrown-animation');
}
function removeAnimation() {
mouth.classList.remove('mouth-animation');
split.classList.remove('split-animation');
split1.classList.remove('split1-animation');
eyeslidsRight.classList.remove('eyeslids-animation');
eyeslidsLeft.classList.remove('eyeslids-animation');
eyesbrown.classList.remove('eyesbrown-animation');
}
const writeText = (e) => {
let textValue = e.target.value;
translateAndRenderText(textValue);
addAnimation();
if (textValue.length >= 19) {
maxWords.innerHTML = 'No more words, nothing you write matters!';
removeAnimation();
}
};
inputText.addEventListener('input', writeText);
btnReset.addEventListener('click', reset);