-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
30 lines (24 loc) · 1.2 KB
/
script.js
File metadata and controls
30 lines (24 loc) · 1.2 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
document
.getElementById("inputText")
.addEventListener("input", updateCharacterCount);
document.getElementById("fontSize").addEventListener("change", formatText);
document.getElementById("lineHeight").addEventListener("change", formatText);
document.getElementById("fontChoice").addEventListener("change", formatText);
function formatText() {
const inputText = document.getElementById("inputText").value;
const outputText = document.getElementById("outputText");
const fontSize = document.getElementById("fontSize").value;
const lineHeight = document.getElementById("lineHeight").value;
const fontChoice = document.getElementById("fontChoice").value;
outputText.style.fontSize = fontSize + "px";
outputText.style.lineHeight = lineHeight;
outputText.style.fontFamily = fontChoice;
outputText.value = inputText;
}
function updateCharacterCount() {
formatText(); // Aby se text aktualizoval při jakémkoli vstupu
const inputText = document.getElementById("inputText").value;
const count = (inputText.match(/[^ ]/g) || []).length; // Počet všech znaků kromě mezer
const counterDisplay = document.getElementById("charCount");
counterDisplay.innerText = `Počet znaků (bez mezer): ${count}`;
}