Skip to content

Commit c042325

Browse files
committed
🐛 Fix file upload and improve UX
- Remove preview mode checkbox (confusing for users) - Fix file input click handler - ensure it works properly - Improve Clear button functionality with toast notification - Add better error handling for missing elements - Update cache-busting to v=3
1 parent 994cf86 commit c042325

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

docs/assets/app.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,26 @@ class App {
174174
this.fileList = document.getElementById('fileList');
175175
this.resultsSection = document.getElementById('resultsSection');
176176
this.resultsContainer = document.getElementById('resultsContainer');
177-
this.dryRunCheck = document.getElementById('dryRunCheck');
178177
this.clearBtn = document.getElementById('clearBtn');
178+
179+
// Check if elements exist
180+
if (!this.uploadArea || !this.fileInput) {
181+
console.error('Required elements not found');
182+
return;
183+
}
179184
}
180185

181186
setupEventListeners() {
182-
// Click to upload
183-
this.uploadArea.addEventListener('click', () => {
184-
this.fileInput.click();
187+
// Click to upload - ensure it works even if upload-content is clicked
188+
this.uploadArea.addEventListener('click', (e) => {
189+
// Don't trigger if clicking on remove button or other interactive elements
190+
if (e.target.closest('.remove-file') || e.target.closest('.btn')) {
191+
return;
192+
}
193+
// Trigger file input click
194+
if (this.fileInput) {
195+
this.fileInput.click();
196+
}
185197
});
186198

187199
// Drag and drop
@@ -338,7 +350,6 @@ class App {
338350
return;
339351
}
340352

341-
const isDryRun = this.dryRunCheck.checked;
342353
const displayText = result.cleanedText;
343354

344355
html += `
@@ -421,11 +432,18 @@ class App {
421432
}
422433

423434
clearAll() {
435+
if (this.files.length === 0) {
436+
return;
437+
}
438+
424439
this.files = [];
425440
this.results = [];
426-
this.fileInput.value = '';
441+
if (this.fileInput) {
442+
this.fileInput.value = '';
443+
}
427444
this.updateFileList();
428445
this.resultsSection.style.display = 'none';
446+
this.showToast('All files cleared');
429447
}
430448

431449
formatFileSize(bytes) {

docs/assets/style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ body {
171171

172172
.upload-content {
173173
pointer-events: none;
174+
user-select: none;
174175
}
175176

176177
.upload-icon {

docs/index.html

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>DocStripper - Batch Document Cleaner</title>
77
<meta name="description" content="DocStripper - Remove noise from text documents automatically. Clean page numbers, headers, footers, duplicates, and empty lines.">
8-
<link rel="stylesheet" href="assets/style.css?v=2">
8+
<link rel="stylesheet" href="assets/style.css?v=3">
99
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🧹</text></svg>">
1010
</head>
1111
<body>
@@ -47,10 +47,6 @@ <h2>Upload Your Documents</h2>
4747
</div>
4848

4949
<div class="upload-options">
50-
<label class="checkbox-label">
51-
<input type="checkbox" id="dryRunCheck" checked>
52-
<span>Preview mode (dry-run)</span>
53-
</label>
5450
<button class="btn btn-secondary" id="clearBtn" style="display: none;">Clear All</button>
5551
</div>
5652

@@ -184,6 +180,6 @@ <h2>Prefer Command Line?</h2>
184180
</div>
185181
</footer>
186182

187-
<script src="assets/app.js?v=2"></script>
183+
<script src="assets/app.js?v=3"></script>
188184
</body>
189185
</html>

0 commit comments

Comments
 (0)