-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrefixSuffix tool by OmarTools.html
248 lines (232 loc) · 8.64 KB
/
PrefixSuffix tool by OmarTools.html
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Text Manipulation Tool</title>
<style>
body {
font-family: 'Arial', sans-serif;
margin: 0;
padding: 20px;
display: flex;
background-color: #f0f0f0;
color: #333;
transition: background-color 0.3s ease;
}
#left-panel {
flex: 2;
margin-right: 20px;
}
#right-panel {
flex: 1;
}
textarea {
width: 100%;
height: 300px;
margin-bottom: 10px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
resize: vertical;
transition: border-color 0.3s ease;
}
textarea:focus {
border-color: #333;
outline: none;
}
button {
margin: 5px;
padding: 8px 12px;
background-color: #333;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease, transform 0.1s ease;
}
button:hover {
background-color: #555;
}
button:active {
transform: scale(0.98);
}
input[type="text"], input[type="number"] {
width: calc(100% - 10px);
margin-bottom: 5px;
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
transition: border-color 0.3s ease;
}
input[type="text"]:focus, input[type="number"]:focus {
border-color: #333;
outline: none;
}
h2, h3 {
margin-top: 0;
color: #333;
}
.panel {
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
transition: box-shadow 0.3s ease;
}
.panel:hover {
box-shadow: 0 6px 8px rgba(0,0,0,0.15);
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.fade-in {
animation: fadeIn 0.5s ease-out;
}
</style>
</head>
<body>
<div id="left-panel" class="panel fade-in">
<textarea id="textArea" placeholder="Enter your text here"></textarea>
<div>
<button onclick="pasteText()">Paste text</button>
<button onclick="importFile()">Import txt file/s</button>
<button onclick="copyText()">Copy Text</button>
<button onclick="exportToTxt()">Export to txt</button>
<button onclick="clearText()">Clear Text</button>
</div>
</div>
<div id="right-panel" class="panel fade-in">
<h2>By OmarTools</h2>
<div>
<h3>Prefix</h3>
<input type="text" id="prefix" placeholder="Enter prefix">
<button onclick="applyPrefix()">Apply Prefix</button>
<button onclick="removePrefix()">Remove Prefix</button>
<button onclick="deleteLinesWithPrefix()">Delete Lines with Prefix</button>
<input type="number" id="deleteNPrefix" style="width: 50px;" placeholder="N">
<button onclick="deleteNPrefix()">Delete N Prefix</button>
<button onclick="numberPrefix()">Number Prefix</button>
</div>
<div>
<h3>Suffix</h3>
<input type="text" id="suffix" placeholder="Enter suffix">
<button onclick="applySuffix()">Apply Suffix</button>
<button onclick="removeSuffix()">Remove Suffix</button>
<button onclick="deleteLinesWithSuffix()">Delete Lines with Suffix</button>
<input type="number" id="deleteNSuffix" style="width: 50px;" placeholder="N">
<button onclick="deleteNSuffix()">Delete N Suffix</button>
<button onclick="numberSuffix()">Number Suffix</button>
</div>
</div>
<script>
function pasteText() {
navigator.clipboard.readText().then(text => {
document.getElementById('textArea').value += text;
animateAction('textArea');
});
}
function importFile() {
const input = document.createElement('input');
input.type = 'file';
input.accept = '.txt';
input.onchange = e => {
const file = e.target.files[0];
const reader = new FileReader();
reader.onload = function(event) {
document.getElementById('textArea').value += event.target.result;
animateAction('textArea');
};
reader.readAsText(file);
};
input.click();
}
function copyText() {
const textArea = document.getElementById('textArea');
textArea.select();
document.execCommand('copy');
animateAction('textArea');
}
function exportToTxt() {
const text = document.getElementById('textArea').value;
const blob = new Blob([text], { type: 'text/plain' });
const a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.download = 'export.txt';
a.click();
animateAction('textArea');
}
function clearText() {
document.getElementById('textArea').value = '';
animateAction('textArea');
}
function applyPrefix() {
const prefix = document.getElementById('prefix').value;
const textArea = document.getElementById('textArea');
textArea.value = textArea.value.split('\n').map(line => prefix + line).join('\n');
animateAction('textArea');
}
function removePrefix() {
const prefix = document.getElementById('prefix').value;
const textArea = document.getElementById('textArea');
textArea.value = textArea.value.split('\n').map(line => line.startsWith(prefix) ? line.slice(prefix.length) : line).join('\n');
animateAction('textArea');
}
function deleteLinesWithPrefix() {
const prefix = document.getElementById('prefix').value;
const textArea = document.getElementById('textArea');
textArea.value = textArea.value.split('\n').filter(line => !line.startsWith(prefix)).join('\n');
animateAction('textArea');
}
function deleteNPrefix() {
const n = parseInt(document.getElementById('deleteNPrefix').value);
const textArea = document.getElementById('textArea');
textArea.value = textArea.value.split('\n').map(line => line.slice(n)).join('\n');
animateAction('textArea');
}
function numberPrefix() {
const textArea = document.getElementById('textArea');
textArea.value = textArea.value.split('\n').map((line, index) => `${index + 1}. ${line}`).join('\n');
animateAction('textArea');
}
function applySuffix() {
const suffix = document.getElementById('suffix').value;
const textArea = document.getElementById('textArea');
textArea.value = textArea.value.split('\n').map(line => line + suffix).join('\n');
animateAction('textArea');
}
function removeSuffix() {
const suffix = document.getElementById('suffix').value;
const textArea = document.getElementById('textArea');
textArea.value = textArea.value.split('\n').map(line => line.endsWith(suffix) ? line.slice(0, -suffix.length) : line).join('\n');
animateAction('textArea');
}
function deleteLinesWithSuffix() {
const suffix = document.getElementById('suffix').value;
const textArea = document.getElementById('textArea');
textArea.value = textArea.value.split('\n').filter(line => !line.endsWith(suffix)).join('\n');
animateAction('textArea');
}
function deleteNSuffix() {
const n = parseInt(document.getElementById('deleteNSuffix').value);
const textArea = document.getElementById('textArea');
textArea.value = textArea.value.split('\n').map(line => line.slice(0, -n)).join('\n');
animateAction('textArea');
}
function numberSuffix() {
const textArea = document.getElementById('textArea');
textArea.value = textArea.value.split('\n').map((line, index) => `${line} ${index + 1}`).join('\n');
animateAction('textArea');
}
function animateAction(elementId) {
const element = document.getElementById(elementId);
element.style.transition = 'transform 0.1s ease';
element.style.transform = 'scale(1.02)';
setTimeout(() => {
element.style.transform = 'scale(1)';
}, 100);
}
</script>
</body>
</html>