-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
67 lines (54 loc) · 2.36 KB
/
script.js
File metadata and controls
67 lines (54 loc) · 2.36 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
67
// -------------------- Mode Switch --------------------
function switchMode(mode) {
document.getElementById('patternMode').classList.toggle('hidden', mode !== 'pattern');
document.getElementById('multiplierMode').classList.toggle('hidden', mode !== 'multiplier');
document.getElementById('outputBox').innerText = '';
}
// -------------------- Pattern Mode --------------------
function generatePattern() {
const text = document.getElementById("patternText").value || "I love you";
const max = parseInt(document.getElementById("patternCount").value) || 30;
// Rainbow hearts in exact order (fixed, not editable)
const hearts = ["❤️","🩷","🧡","🧡","💛","💚","💙","🩵","💜","💜"];
let output = "";
const waveDepth = 7; // max spaces
let wave = 0;
let direction = 1;
for (let i = 0; i < max; i++) {
const heart = hearts[i % hearts.length]; // cycle in exact order
let spaces = " ".repeat(waveDepth - wave);
output += `${spaces}${heart} ${text} ${i + 1}%\n`;
wave += direction;
if (wave === waveDepth || wave === 0) direction *= -1;
}
document.getElementById("outputBox").innerText = output;
}
// -------------------- Text Multiplier --------------------
function generateMultiplier() {
const text = document.getElementById("multiText").value || "Hello";
const count = parseInt(document.getElementById("multiCount").value) || 5;
const numbered = document.getElementById("enableNumbering").checked;
let output = "";
for (let i = 1; i <= count; i++) {
output += numbered ? `${i}) ${text}\n` : `${text}\n`;
}
document.getElementById("outputBox").innerText = output;
}
// -------------------- Copy Output --------------------
function copyOutput() {
const output = document.getElementById("outputBox").innerText;
navigator.clipboard.writeText(output).then(() => {
alert("✨ Copied to clipboard! ✨");
});
}
// -------------------- Theme Handling --------------------
const themeSelect = document.getElementById('themeSelect');
themeSelect.addEventListener('change', () => {
const body = document.body;
body.className = ''; // reset classes
let theme = themeSelect.value;
if (theme === 'dark') body.classList.add('dark-mode');
if (theme === 'light') body.classList.add('light-mode');
if (theme === 'candy') body.classList.add('candy-mode');
if (theme === 'emoji') body.classList.add('emoji-mode');
});