-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext-repeater.js
More file actions
33 lines (31 loc) · 1.41 KB
/
text-repeater.js
File metadata and controls
33 lines (31 loc) · 1.41 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
const toolSection = document.getElementById('toolSection');
toolSection.innerHTML = `
<div class="input-area">
<label for="inputText">Text to Repeat:</label>
<textarea id="inputText" rows="4" placeholder="Enter text here..."></textarea>
<label style="margin-top:12px;">Repeat Count:</label>
<input type="number" id="repeatCount" value="3" min="1" max="1000" style="width:100px;padding:8px;">
</div>
<div class="buttons-grid">
<button onclick="convert()" class="btn btn-primary">Repeat Text</button>
</div>
<div class="output-area">
<label for="outputText">Result:</label>
<textarea id="outputText" rows="8" readonly></textarea>
<button onclick="copyOutput()" class="btn btn-copy" id="copyBtn">📋 Copy</button>
</div>
`;
function convert() {
const text = document.getElementById('inputText').value;
const count = parseInt(document.getElementById('repeatCount').value) || 1;
const result = Array(count).fill(text).join('\n');
document.getElementById('outputText').value = result;
}
function copyOutput() {
const output = document.getElementById('outputText');
if (!output.value) return;
navigator.clipboard.writeText(output.value).then(() => {
document.getElementById('copyBtn').textContent = '✅ Copied!';
setTimeout(() => { document.getElementById('copyBtn').textContent = '📋 Copy'; }, 2000);
});
}