Ultronprime commited on
Commit
8039ec2
·
verified ·
1 Parent(s): faf8d87

I WANT AN OPTION IN THIS WHICH WILL MERGE ALL FILES INTO SINGLE FILE AND CHANGE THE EXTENSION TO TXT TO GET RAW TXT MERGED ALL FILE INTO SINGLE FILE AND DOWNLOAD IT - Follow Up Deployment

Browse files
Files changed (1) hide show
  1. index.html +52 -0
index.html CHANGED
@@ -92,6 +92,10 @@
92
  <div id="downloadSection" class="bg-emerald-50 p-6 text-center hidden">
93
  <h3 class="text-lg font-medium text-emerald-800 mb-3">Files processed successfully!</h3>
94
  <div class="flex flex-col sm:flex-row justify-center gap-4">
 
 
 
 
95
  <button id="downloadAllBtn" class="inline-flex items-center px-6 py-3 bg-emerald-600 hover:bg-emerald-700 text-white font-medium rounded-lg shadow-sm cursor-pointer transition">
96
  <i class="fas fa-download mr-3"></i>
97
  Download All Files
@@ -133,6 +137,7 @@
133
  const zipProgress = document.getElementById('zipProgress');
134
  const zipStatus = document.getElementById('zipStatus');
135
  const progressBar = zipProgress.querySelector('.progress-bar');
 
136
 
137
  let files = [];
138
  let processedFiles = [];
@@ -160,6 +165,7 @@
160
  renameBtn.addEventListener('click', renameExtensions);
161
  downloadAllBtn.addEventListener('click', downloadFiles);
162
  downloadZipBtn.addEventListener('click', createZip);
 
163
 
164
  function handleFiles(newFiles) {
165
  if (newFiles.length === 0) return;
@@ -344,6 +350,52 @@
344
  newExtension.addEventListener('input', () => {
345
  renameBtn.disabled = files.length === 0 || !newExtension.value.trim();
346
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
  });
348
  </script>
349
  <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Ultronprime/extension-changer" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
 
92
  <div id="downloadSection" class="bg-emerald-50 p-6 text-center hidden">
93
  <h3 class="text-lg font-medium text-emerald-800 mb-3">Files processed successfully!</h3>
94
  <div class="flex flex-col sm:flex-row justify-center gap-4">
95
+ <button id="mergeFilesBtn" class="inline-flex items-center px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg shadow-sm cursor-pointer transition">
96
+ <i class="fas fa-file-alt mr-3"></i>
97
+ Merge to TXT
98
+ </button>
99
  <button id="downloadAllBtn" class="inline-flex items-center px-6 py-3 bg-emerald-600 hover:bg-emerald-700 text-white font-medium rounded-lg shadow-sm cursor-pointer transition">
100
  <i class="fas fa-download mr-3"></i>
101
  Download All Files
 
137
  const zipProgress = document.getElementById('zipProgress');
138
  const zipStatus = document.getElementById('zipStatus');
139
  const progressBar = zipProgress.querySelector('.progress-bar');
140
+ const mergeFilesBtn = document.getElementById('mergeFilesBtn');
141
 
142
  let files = [];
143
  let processedFiles = [];
 
165
  renameBtn.addEventListener('click', renameExtensions);
166
  downloadAllBtn.addEventListener('click', downloadFiles);
167
  downloadZipBtn.addEventListener('click', createZip);
168
+ mergeFilesBtn.addEventListener('click', mergeToTxt);
169
 
170
  function handleFiles(newFiles) {
171
  if (newFiles.length === 0) return;
 
350
  newExtension.addEventListener('input', () => {
351
  renameBtn.disabled = files.length === 0 || !newExtension.value.trim();
352
  });
353
+
354
+ async function mergeToTxt() {
355
+ if (processedFiles.length === 0) return;
356
+
357
+ try {
358
+ // Read all files as text
359
+ const fileContents = await Promise.all(
360
+ processedFiles.map(file => {
361
+ return new Promise((resolve) => {
362
+ const reader = new FileReader();
363
+ reader.onload = function(e) {
364
+ resolve({
365
+ name: file.name,
366
+ content: e.target.result
367
+ });
368
+ };
369
+ reader.readAsText(file);
370
+ });
371
+ })
372
+ );
373
+
374
+ // Combine all contents with separators
375
+ let mergedContent = '';
376
+ fileContents.forEach((file, index) => {
377
+ mergedContent += `=== ${file.name} ===\n\n${file.content}\n\n`;
378
+ if (index < fileContents.length - 1) {
379
+ mergedContent += '\n\n';
380
+ }
381
+ });
382
+
383
+ // Create and download the merged file
384
+ const blob = new Blob([mergedContent], { type: 'text/plain' });
385
+ const url = URL.createObjectURL(blob);
386
+ const a = document.createElement('a');
387
+ a.href = url;
388
+ a.download = 'merged_files.txt';
389
+ document.body.appendChild(a);
390
+ a.click();
391
+ document.body.removeChild(a);
392
+ URL.revokeObjectURL(url);
393
+
394
+ } catch (error) {
395
+ console.error('Error merging files:', error);
396
+ alert('Error merging files. Please try again.');
397
+ }
398
+ }
399
  });
400
  </script>
401
  <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Ultronprime/extension-changer" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>