jebin2 commited on
Commit
4a9f7f7
·
1 Parent(s): 93f5826
Files changed (1) hide show
  1. image/javascript/image.js +17 -2
image/javascript/image.js CHANGED
@@ -187,13 +187,18 @@ function renderFileCards() {
187
  const completedFile = completedFiles.find(cf => cf.id === file.id);
188
  // Check if metadata info exists and has content
189
  const hasMetadata = file.other_info && Object.keys(file.other_info).length > 0;
 
 
 
 
190
 
191
  return `
192
  <div class="file-card" id="file-${file.id}">
193
  <button class="remove-button" onclick="removeFile('${file.id}')">×</button>
194
- ${window.location.pathname == '/image/remove_metadata' && file.status === 'completed' ? `<button class="remove-button" style="top: 40px; background: #17a2b8;" onclick="showMetadata('${file.id}')" title="View removed metadata">i</button>` : ``}
195
  ${file.status === 'error' && file.errorMessage ? `<button class="remove-button" style="top: 40px; background: #dc3545;" onclick="showError('${file.id}')" title="View error">!</button>` : ``}
196
- ${file.status === 'completed' && completedFile ? `<button class="remove-button" style="top: ${window.location.pathname == '/image/remove_metadata' ? '70px' : '40px'}; background: #28a745;" onclick="downloadFile('${file.id}')" title="Download">⬇</button>` : ``}
 
197
 
198
  <div class="file-preview">
199
  ${file.preview ? `<img src="${file.preview}" alt="${file.name}">` : '<span class="file-icon">🖼️</span>'}
@@ -470,3 +475,13 @@ function downloadFile(fileId) {
470
  document.body.removeChild(link);
471
  }
472
  }
 
 
 
 
 
 
 
 
 
 
 
187
  const completedFile = completedFiles.find(cf => cf.id === file.id);
188
  // Check if metadata info exists and has content
189
  const hasMetadata = file.other_info && Object.keys(file.other_info).length > 0;
190
+ // Calculate button positions based on page type
191
+ const isMetadataPage = window.location.pathname == '/image/remove_metadata';
192
+ const downloadTop = isMetadataPage ? '70px' : '40px';
193
+ const viewTop = isMetadataPage ? '100px' : '70px';
194
 
195
  return `
196
  <div class="file-card" id="file-${file.id}">
197
  <button class="remove-button" onclick="removeFile('${file.id}')">×</button>
198
+ ${isMetadataPage && file.status === 'completed' ? `<button class="remove-button" style="top: 40px; background: #17a2b8;" onclick="showMetadata('${file.id}')" title="View removed metadata">i</button>` : ``}
199
  ${file.status === 'error' && file.errorMessage ? `<button class="remove-button" style="top: 40px; background: #dc3545;" onclick="showError('${file.id}')" title="View error">!</button>` : ``}
200
+ ${file.status === 'completed' && completedFile ? `<button class="remove-button" style="top: ${downloadTop}; background: #28a745;" onclick="downloadFile('${file.id}')" title="Download">⬇</button>` : ``}
201
+ ${file.status === 'completed' && completedFile ? `<button class="remove-button" style="top: ${viewTop}; background: #6f42c1;" onclick="viewImage('${file.id}')" title="View image">👁</button>` : ``}
202
 
203
  <div class="file-preview">
204
  ${file.preview ? `<img src="${file.preview}" alt="${file.name}">` : '<span class="file-icon">🖼️</span>'}
 
475
  document.body.removeChild(link);
476
  }
477
  }
478
+
479
+ /**
480
+ * View the processed image in a new tab
481
+ */
482
+ function viewImage(fileId) {
483
+ const completedFile = completedFiles.find(f => f.id === fileId);
484
+ if (completedFile) {
485
+ window.open(completedFile.url, '_blank');
486
+ }
487
+ }