Skip to content

Commit 51e13fc

Browse files
committed
1 parent 2946a4b commit 51e13fc

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed

text-indentation.html

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8">
4+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
5+
<title>Text Indentation Tool</title>
6+
<style>
7+
* {
8+
box-sizing: border-box;
9+
}
10+
11+
body {
12+
font-family: Helvetica, Arial, sans-serif;
13+
padding: 20px;
14+
max-width: 800px;
15+
margin: 0 auto;
16+
background: #f5f5f5;
17+
}
18+
19+
h1 {
20+
margin-top: 0;
21+
color: #333;
22+
}
23+
24+
.container {
25+
background: white;
26+
padding: 20px;
27+
border-radius: 8px;
28+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
29+
}
30+
31+
textarea {
32+
width: 100%;
33+
min-height: 300px;
34+
padding: 12px;
35+
font-size: 16px;
36+
font-family: 'Courier New', monospace;
37+
border: 1px solid #ddd;
38+
border-radius: 4px;
39+
resize: vertical;
40+
margin-bottom: 15px;
41+
}
42+
43+
.buttons {
44+
display: flex;
45+
gap: 10px;
46+
flex-wrap: wrap;
47+
}
48+
49+
button {
50+
padding: 10px 20px;
51+
font-size: 16px;
52+
font-family: Helvetica, Arial, sans-serif;
53+
background: #007aff;
54+
color: white;
55+
border: none;
56+
border-radius: 4px;
57+
cursor: pointer;
58+
transition: background 0.2s;
59+
}
60+
61+
button:hover {
62+
background: #0051d5;
63+
}
64+
65+
button:active {
66+
transform: translateY(1px);
67+
}
68+
69+
button.remove {
70+
background: #ff3b30;
71+
}
72+
73+
button.remove:hover {
74+
background: #d62d20;
75+
}
76+
</style>
77+
</head>
78+
<body>
79+
<div class="container">
80+
<h1>Text indentation tool</h1>
81+
<textarea id="textInput" placeholder="Paste your text here..."></textarea>
82+
<div class="buttons">
83+
<button id="indent2">Indent 2</button>
84+
<button id="indent4">Indent 4</button>
85+
<button id="remove2" class="remove">Remove 2 spaces</button>
86+
<button id="remove4" class="remove">Remove 4 spaces</button>
87+
<button id="removeIndent" class="remove">Remove all indentation</button>
88+
</div>
89+
</div>
90+
91+
<script type="module">
92+
const textInput = document.getElementById('textInput');
93+
const removeIndentBtn = document.getElementById('removeIndent');
94+
const indent2Btn = document.getElementById('indent2');
95+
const indent4Btn = document.getElementById('indent4');
96+
const remove2Btn = document.getElementById('remove2');
97+
const remove4Btn = document.getElementById('remove4');
98+
99+
removeIndentBtn.addEventListener('click', () => {
100+
const text = textInput.value;
101+
const lines = text.split('\n');
102+
const processed = lines.map(line => line.replace(/^\s+/, '')).join('\n');
103+
textInput.value = processed;
104+
});
105+
106+
indent2Btn.addEventListener('click', () => {
107+
const text = textInput.value;
108+
const lines = text.split('\n');
109+
const processed = lines.map(line => ' ' + line).join('\n');
110+
textInput.value = processed;
111+
});
112+
113+
indent4Btn.addEventListener('click', () => {
114+
const text = textInput.value;
115+
const lines = text.split('\n');
116+
const processed = lines.map(line => ' ' + line).join('\n');
117+
textInput.value = processed;
118+
});
119+
120+
remove2Btn.addEventListener('click', () => {
121+
const text = textInput.value;
122+
const lines = text.split('\n');
123+
const processed = lines.map(line => {
124+
if (line.startsWith(' ')) {
125+
return line.slice(2);
126+
}
127+
return line;
128+
}).join('\n');
129+
textInput.value = processed;
130+
});
131+
132+
remove4Btn.addEventListener('click', () => {
133+
const text = textInput.value;
134+
const lines = text.split('\n');
135+
const processed = lines.map(line => {
136+
if (line.startsWith(' ')) {
137+
return line.slice(4);
138+
}
139+
return line;
140+
}).join('\n');
141+
textInput.value = processed;
142+
});
143+
</script>
144+
</body>
145+
</html>

0 commit comments

Comments
 (0)