-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
406 lines (342 loc) · 14 KB
/
index.html
File metadata and controls
406 lines (342 loc) · 14 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
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Text Editor</title>
<link rel="icon" type="image/x-icon" href="https://i.postimg.cc/wjrmSP08/icons8-editor-32.png">
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #111;
color: #ffffff;
margin: 0;
transition: background-color 0.3s, color 0.3s;
}
.container {
text-align: center;
background: #ffffff;
color: #000000;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgb(0, 0, 0);
transition: background-color 0.3s, color 0.3s;
}
textarea, input {
width: 80%;
padding: 10px;
margin: 10px 0;
background-color: #333;
color: #ffffff;
border: 1px solid #555;
border-radius: 5px;
transition: background-color 0.3s, color 0.3s;
}
.button-group {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.button-group button {
flex: 1 1 calc(50% - 10px);
margin: 5px;
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #007BFF;
color: white;
cursor: pointer;
transition: background-color 0.3s;
box-sizing: border-box;
}
.button-group button:hover {
background-color: #0056b3;
}
#output {
margin-top: 20px;
padding: 10px;
background: #444;
color: #ffffff;
border-radius: 5px;
white-space: pre-wrap;
transition: background-color 0.3s, color 0.3s;
height: 200px;
width: 100%;
overflow-y: auto;
overflow-x: hidden;
box-sizing: border-box;
}
#output:empty::before {
content: attr(placeholder);
color: #888;
}
.extra-buttons {
display: flex;
flex-wrap: wrap;
justify-content: center;
margin-top: 10px;
}
.extra-buttons button {
margin: 5px;
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #007BFF;
color: white;
cursor: pointer;
transition: background-color 0.3s;
box-sizing: border-box;
}
.extra-buttons-separator button
{
width: 100%;
margin: 5px;
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #007BFF;
color: white;
cursor: pointer;
transition: background-color 0.3s;
box-sizing: border-box;
}
.extra-buttons-separator button:hover
{
background-color: #0056b3;
}
.extra-buttons button:hover {
background-color: #0056b3;
}
.dark-mode {
background-color: #111;
color: #ffffff;
}
.dark-mode .container {
background-color: #222;
color: #ffffff;
}
.dark-mode textarea, .dark-mode input {
background-color: #333;
color: #ffffff;
border: 1px solid #555;
}
.dark-mode .button-group button, .dark-mode .extra-buttons button {
background-color: #007BFF;
color: white;
}
.dark-mode .button-group button:hover, .dark-mode .extra-buttons button:hover {
background-color: #0056b3;
}
.dark-mode #output {
background-color: #444;
color: #ffffff;
}
.theme-toggle {
position: absolute;
top: 20px;
left: 20px;
cursor: pointer;
font-size: 24px;
}
.separator-toggle {
position: absolute;
top: 20px;
right: 20px;
cursor: pointer;
font-size: 24px;
}
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0, 0, 0, 0.4);
}
.modal-content {
color: white;
background-color: #1a1a1a;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 500px;
border-radius: 10px;
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
</style>
</head>
<body class="dark-mode">
<div class="theme-toggle" onclick="toggleTheme()">🌙</div>
<div class="separator-toggle" onclick="openSeparator()">📋</div>
<div class="container">
<h1>Text Editor</h1>
<textarea id="wordList" placeholder="Enter words, each on a new line..."></textarea>
<br>
<input type="text" id="customWord" placeholder="Enter custom word...">
<br>
<div class="button-group">
<button onclick="addWordToEnd()">Add Word to End</button>
<button onclick="addWordToStart()">Add Word to Start</button>
<button onclick="removeSpaces()">Remove Spaces</button>
<button onclick="countWordsAndLines()">Count Words and Lines</button>
<button onclick="removeItemsContainingWord()">Remove Items Containing Word</button>
<button onclick="removeDuplicates()">Remove Duplicates</button>
<button onclick="exportTextToFile()">Export Text to File</button>
</div>
<div id="output" placeholder="Output will be displayed here..."></div>
<div class="extra-buttons">
<button onclick="copyOutput()">Copy Output</button>
<button onclick="clearOutput()">Clear Output</button>
<button onclick="clearInput()">Clear Input</button>
<button onclick="toUpperCase()">All Caps</button>
<button onclick="toLowerCase()">All Small</button>
<button onclick="capitalizeFirst()">Capitalize First</button>
<button onclick="sortOutput()">Sort Output</button>
</div>
<h4>
Developed by TGWArad
</h4>
</div>
<div id="separatorModal" class="modal extra-buttons-separator" style="display: none;">
<div class="modal-content" style="display: flex; flex-direction: column; align-items: center; text-align: center;">
<span class="close" onclick="closeSeparator()" style="align-self: flex-end; cursor: pointer;">×</span>
<h2>List Separator</h2>
<textarea id="inputList" placeholder="Enter your long list, each item on a new line" style="margin: 10px 0;"></textarea>
<input type="number" id="linesPerFile" placeholder="Enter number of lines per file" style="margin: 10px 0;">
<button onclick="separateList()" style="margin: 10px 0;">Separate and Download Files</button>
<div id="outputLists"></div>
</div>
</div>
<script>
function removeDuplicates() {
let wordList = document.getElementById("wordList").value.split("\n");
let uniqueWords = [...new Set(wordList.map(word => word.trim()).filter(word => word !== ""))];
document.getElementById("output").innerText = uniqueWords.join("\n");
}
function addWordToEnd() {
let wordList = document.getElementById("wordList").value.split("\n");
let customWord = document.getElementById("customWord").value.trim();
let modifiedWords = wordList.map(word => word.trim() ? word.trim() + customWord : "").filter(word => word !== "");
document.getElementById("output").innerText = modifiedWords.join("\n");
}
function addWordToStart() {
let wordList = document.getElementById("wordList").value.split("\n");
let customWord = document.getElementById("customWord").value.trim();
let modifiedWords = wordList.map(word => word.trim() ? customWord + word.trim() : "").filter(word => word !== "");
document.getElementById("output").innerText = modifiedWords.join("\n");
}
function removeSpaces() {
let wordList = document.getElementById("wordList").value;
let modifiedWords = wordList.replace(/ /g, ''); // Replace only spaces
document.getElementById("output").innerText = modifiedWords;
}
function countWordsAndLines() {
let wordList = document.getElementById("wordList").value;
let lines = wordList.split("\n").filter(line => line.trim() !== "").length;
let words = wordList.split(/\s+/).filter(word => word.trim() !== "").length;
document.getElementById("output").innerText = `Words: ${words}, Lines: ${lines}`;
}
function removeItemsContainingWord() {
let wordList = document.getElementById("wordList").value.split("\n");
let customWord = document.getElementById("customWord").value.trim();
let modifiedWords = wordList.filter(word => !word.includes(customWord));
document.getElementById("output").innerText = modifiedWords.join("\n");
}
function exportTextToFile() {
let outputText = document.getElementById("output").innerText;
let blob = new Blob([outputText], { type: 'text/plain' });
let link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'output.txt';
link.click();
}
function copyOutput() {
let outputText = document.getElementById("output").innerText;
navigator.clipboard.writeText(outputText).then(function() {
alert('Output copied to clipboard!');
}, function(err) {
alert('Could not copy text: ', err);
});
}
function clearOutput() {
document.getElementById("output").innerText = '';
}
function clearInput() {
document.getElementById("wordList").value = '';
document.getElementById("customWord").value = '';
}
function toggleTheme() {
document.body.classList.toggle('dark-mode');
const themeToggle = document.querySelector('.theme-toggle');
if (document.body.classList.contains('dark-mode')) {
themeToggle.textContent = '🌙';
document.body.style.backgroundColor = "#111";
document.body.style.color = "#ffffff";
} else {
themeToggle.textContent = '☀️';
document.body.style.backgroundColor = "#f0f0f0";
document.body.style.color = "#000000";
}
}
function toUpperCase() {
let wordList = document.getElementById("wordList").value.toUpperCase();
document.getElementById("output").innerText = wordList;
}
function toLowerCase() {
let wordList = document.getElementById("wordList").value.toLowerCase();
document.getElementById("output").innerText = wordList;
}
function capitalizeFirst() {
let wordList = document.getElementById("wordList").value;
let modifiedWords = wordList.split("\n").map(line => {
let trimmedLine = line.trim();
return trimmedLine ? trimmedLine[0].toUpperCase() + trimmedLine.slice(1).toLowerCase() : "";
}).join("\n");
document.getElementById("output").innerText = modifiedWords;
}
function sortOutput() {
let outputText = document.getElementById("output").innerText;
let sortedText = outputText.split("\n").filter(line => line.trim() !== "").sort().join("\n");
document.getElementById("output").innerText = sortedText;
}
function openSeparator() {
document.getElementById("separatorModal").style.display = "block";
}
function closeSeparator() {
document.getElementById("separatorModal").style.display = "none";
}
function separateList() {
const inputList = document.getElementById('inputList').value.split("\n").map(item => item.trim()).filter(item => item);
const linesPerFile = parseInt(document.getElementById('linesPerFile').value);
const chunkSize = linesPerFile;
for (let i = 0; i < inputList.length; i += chunkSize) {
const chunk = inputList.slice(i, i + chunkSize);
const blob = new Blob([chunk.join('\n')], { type: 'text/plain' });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = `output_part_${Math.floor(i / chunkSize) + 1}.txt`;
link.click();
}
}
</script>
</body>
</html>