3v324v23 commited on
Commit
3ea030c
·
2 Parent(s): f880f1b 5031d04

Merge branch 'main' of https://huggingface.co/spaces/tokyotechlab/fe into develop

Browse files
Files changed (2) hide show
  1. assets/image-default.jpg +0 -0
  2. main.js +24 -4
assets/image-default.jpg ADDED
main.js CHANGED
@@ -1,5 +1,7 @@
1
  import { closeIcon, eyeIcon, fileIcon, trashIcon } from './constants.js';
2
 
 
 
3
  const inputElement = document.getElementById('file-input');
4
  const metadataElement = document.getElementById('metadata-input');
5
  const textInputElement = document.getElementById('text-input');
@@ -683,6 +685,17 @@ function createDefaultMetadataFile() {
683
  return new File([defaultContent], fileName, { type: 'application/json' });
684
  }
685
 
 
 
 
 
 
 
 
 
 
 
 
686
  async function handleSubmit() {
687
  if (isLoading.value) return;
688
 
@@ -690,9 +703,16 @@ async function handleSubmit() {
690
  outputElement.innerHTML =
691
  '<p class="opacity-50">Verification result comes here...</p>';
692
 
693
- if (files.value.length === 0) {
694
- createTemplateModal('Please upload media files');
695
- return;
 
 
 
 
 
 
 
696
  }
697
 
698
  isLoading.value = true;
@@ -709,7 +729,7 @@ async function handleSubmit() {
709
  MediaInfo.mediaInfoFactory({ format: 'JSON' }, resolve);
710
  });
711
  let isGetTimed = false;
712
- for (const [index, file] of files.value.entries()) {
713
  const readChunk = async (chunkSize, offset) =>
714
  new Uint8Array(
715
  await file.slice(offset, offset + chunkSize).arrayBuffer()
 
1
  import { closeIcon, eyeIcon, fileIcon, trashIcon } from './constants.js';
2
 
3
+ const IMAGE_DEFAULT_URL = './assets/image-default.jpg';
4
+
5
  const inputElement = document.getElementById('file-input');
6
  const metadataElement = document.getElementById('metadata-input');
7
  const textInputElement = document.getElementById('text-input');
 
685
  return new File([defaultContent], fileName, { type: 'application/json' });
686
  }
687
 
688
+ async function createDefaultImageFile() {
689
+ const response = await fetch(IMAGE_DEFAULT_URL);
690
+ if (!response.ok) {
691
+ throw new Error('Unable to load default image');
692
+ }
693
+ const blob = await response.blob();
694
+ return new File([blob], 'default-image.jpg', {
695
+ type: blob.type || 'image/jpeg',
696
+ });
697
+ }
698
+
699
  async function handleSubmit() {
700
  if (isLoading.value) return;
701
 
 
703
  outputElement.innerHTML =
704
  '<p class="opacity-50">Verification result comes here...</p>';
705
 
706
+ let mediaFiles = files.value;
707
+ if (mediaFiles.length === 0) {
708
+ try {
709
+ const defaultImageFile = await createDefaultImageFile();
710
+ mediaFiles = [defaultImageFile]; // Use fallback for submission only; do not show in UI
711
+ } catch (error) {
712
+ console.error('Error loading default image:', error);
713
+ createTemplateModal('Please upload media files');
714
+ return;
715
+ }
716
  }
717
 
718
  isLoading.value = true;
 
729
  MediaInfo.mediaInfoFactory({ format: 'JSON' }, resolve);
730
  });
731
  let isGetTimed = false;
732
+ for (const [index, file] of mediaFiles.entries()) {
733
  const readChunk = async (chunkSize, offset) =>
734
  new Uint8Array(
735
  await file.slice(offset, offset + chunkSize).arrayBuffer()