diff --git a/public/index.html b/public/index.html index b21ec8504de565c01e5ffc61073dd199a8ac2fa7..feecad763bbff1313ce8776feeb0fb524f8c07da 100644 --- a/public/index.html +++ b/public/index.html @@ -122,57 +122,9 @@ </section> </section> - <script> - let inputObj = {}; - - function handleTextRadioClick() { - let textChoice = document.querySelector('input[name="drone"]:checked').value; - console.log(textChoice); - toggleElement('character-calculation-wrapper'); - toggleElement('manual-character-input'); - } - - function toggleElement(id) { - let x = document.getElementById(id); - if (x.style.display === "none") { - x.style.display = "block"; - } else { - x.style.display = "none"; - } - } - - function handleTextAreaChange() { - let value = document.getElementById("manual-text-entry").value; - value = value.trim(); - let characters = value.split(' ').join('').length; - setCharacterLength(characters); - document.getElementById("calculatedTextCharacters").setAttribute('value', characters) - } - - function handleCharacterInputChange() { - let value = document.getElementById("inputTextCharacters").value; - setCharacterLength(value); - } - - function setCharacterLength(characters) { - inputObj.characters = characters; - console.log('Character length: ' + inputObj.characters); - } - - function calculateReadingTime() { - let x = document.getElementById('calculate-time-element'); - x.style.display = "block"; - } - - function showFeedbackForm() { - let x = document.getElementById('feedback-form'); - x.style.display = "block"; - } - - </script> - <!-- KEINE ÄNDERUNGEN NACH DIESER ZEILE --> <script src="settings.js"> </script> + <script src="index.js"> </script> </body> </html> \ No newline at end of file diff --git a/public/index.js b/public/index.js new file mode 100644 index 0000000000000000000000000000000000000000..31a0f5a0a97f1c1995f203b7a4e66680a9aaee8f --- /dev/null +++ b/public/index.js @@ -0,0 +1,45 @@ +let inputObj = {}; + +function handleTextRadioClick() { + let textChoice = document.querySelector('input[name="drone"]:checked').value; + console.log(textChoice); + toggleElement('character-calculation-wrapper'); + toggleElement('manual-character-input'); +} + +function toggleElement(id) { + let x = document.getElementById(id); + if (x.style.display === "none") { + x.style.display = "block"; + } else { + x.style.display = "none"; + } +} + +function handleTextAreaChange() { + let value = document.getElementById("manual-text-entry").value; + value = value.trim(); + let characters = value.split(' ').join('').length; + setCharacterLength(characters); + document.getElementById("calculatedTextCharacters").setAttribute('value', characters) +} + +function handleCharacterInputChange() { + let value = document.getElementById("inputTextCharacters").value; + setCharacterLength(value); +} + +function setCharacterLength(characters) { + inputObj.characters = characters; + console.log('Character length: ' + inputObj.characters); +} + +function calculateReadingTime() { + let x = document.getElementById('calculate-time-element'); + x.style.display = "block"; +} + +function showFeedbackForm() { + let x = document.getElementById('feedback-form'); + x.style.display = "block"; +}