suppressor14 commited on
Commit
4c7d7af
·
verified ·
1 Parent(s): 1353a91

This isnt working, the drag and drop video here function doesnt work, please rectify this - Follow Up Deployment

Browse files
Files changed (1) hide show
  1. index.html +43 -15
index.html CHANGED
@@ -24,10 +24,15 @@
24
  .dropzone {
25
  border: 2px dashed #ccc;
26
  transition: all 0.3s ease;
 
 
 
 
27
  }
28
  .dropzone.active {
29
  border-color: #4f46e5;
30
  background-color: #eef2ff;
 
31
  }
32
  .story-card {
33
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
@@ -226,7 +231,8 @@
226
  dropzone.addEventListener(eventName, unhighlight, false);
227
  });
228
 
229
- function highlight() {
 
230
  dropzone.classList.add('active');
231
  }
232
 
@@ -240,7 +246,12 @@
240
  function handleDrop(e) {
241
  const dt = e.dataTransfer;
242
  const files = dt.files;
243
- if (files.length) {
 
 
 
 
 
244
  handleFiles(files);
245
  }
246
  }
@@ -253,13 +264,17 @@
253
 
254
  function handleFiles(files) {
255
  const file = files[0];
256
- if (!file.type.match('video.*')) {
 
 
 
 
257
  alert('Please upload a video file (MP4, MOV, AVI)');
258
  return;
259
  }
260
 
261
- // Check file size (simulated)
262
- if (file.size > 100 * 1024 * 1024) { // 100MB
263
  alert('File is too large. Maximum size is 100MB.');
264
  return;
265
  }
@@ -267,25 +282,24 @@
267
  // Display video preview
268
  const videoURL = URL.createObjectURL(file);
269
  videoPreview.src = videoURL;
 
270
  videoName.textContent = file.name;
271
  videoPreviewContainer.classList.remove('hidden');
272
  uploadContent.classList.add('hidden');
273
  generateBtn.disabled = false;
274
 
275
- // Load metadata to get duration
276
  videoPreview.onloadedmetadata = function() {
277
- console.log(`Video duration: ${videoPreview.duration} seconds`);
 
 
 
 
 
278
  };
279
  }
280
 
281
- removeVideoBtn.addEventListener('click', function() {
282
- videoPreview.src = '';
283
- videoPreviewContainer.classList.add('hidden');
284
- uploadContent.classList.remove('hidden');
285
- generateBtn.disabled = true;
286
- videoUpload.value = '';
287
- resetStoryOutput();
288
- });
289
 
290
  generateBtn.addEventListener('click', function() {
291
  if (!videoPreview.src) return;
@@ -428,6 +442,18 @@
428
  return names[Math.floor(Math.random() * names.length)];
429
  }
430
 
 
 
 
 
 
 
 
 
 
 
 
 
431
  function resetStoryOutput() {
432
  storyPlaceholder.classList.remove('hidden');
433
  loadingIndicator.classList.add('hidden');
@@ -435,6 +461,8 @@
435
  storyActions.classList.add('hidden');
436
  storyTitle.textContent = '';
437
  storyContent.textContent = '';
 
 
438
  }
439
 
440
  // Copy story to clipboard
 
24
  .dropzone {
25
  border: 2px dashed #ccc;
26
  transition: all 0.3s ease;
27
+ min-height: 200px;
28
+ display: flex;
29
+ align-items: center;
30
+ justify-content: center;
31
  }
32
  .dropzone.active {
33
  border-color: #4f46e5;
34
  background-color: #eef2ff;
35
+ transform: scale(0.98);
36
  }
37
  .story-card {
38
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
 
231
  dropzone.addEventListener(eventName, unhighlight, false);
232
  });
233
 
234
+ function highlight(e) {
235
+ e.preventDefault();
236
  dropzone.classList.add('active');
237
  }
238
 
 
246
  function handleDrop(e) {
247
  const dt = e.dataTransfer;
248
  const files = dt.files;
249
+
250
+ // Reset dropzone appearance
251
+ dropzone.classList.remove('active');
252
+
253
+ // Process files if any
254
+ if (files.length > 0) {
255
  handleFiles(files);
256
  }
257
  }
 
264
 
265
  function handleFiles(files) {
266
  const file = files[0];
267
+ if (!file) return;
268
+
269
+ // Check if file is a video
270
+ const validTypes = ['video/mp4', 'video/quicktime', 'video/x-msvideo'];
271
+ if (!validTypes.includes(file.type)) {
272
  alert('Please upload a video file (MP4, MOV, AVI)');
273
  return;
274
  }
275
 
276
+ // Check file size (100MB max)
277
+ if (file.size > 100 * 1024 * 1024) {
278
  alert('File is too large. Maximum size is 100MB.');
279
  return;
280
  }
 
282
  // Display video preview
283
  const videoURL = URL.createObjectURL(file);
284
  videoPreview.src = videoURL;
285
+ videoPreview.load();
286
  videoName.textContent = file.name;
287
  videoPreviewContainer.classList.remove('hidden');
288
  uploadContent.classList.add('hidden');
289
  generateBtn.disabled = false;
290
 
291
+ // Load metadata
292
  videoPreview.onloadedmetadata = function() {
293
+ console.log(`Video loaded: ${file.name} (${Math.round(file.size/(1024*1024))}MB)`);
294
+ };
295
+
296
+ videoPreview.onerror = function() {
297
+ alert('Error loading video file');
298
+ resetVideoUpload();
299
  };
300
  }
301
 
302
+ removeVideoBtn.addEventListener('click', resetVideoUpload);
 
 
 
 
 
 
 
303
 
304
  generateBtn.addEventListener('click', function() {
305
  if (!videoPreview.src) return;
 
442
  return names[Math.floor(Math.random() * names.length)];
443
  }
444
 
445
+ function resetVideoUpload() {
446
+ if (videoPreview.src) {
447
+ URL.revokeObjectURL(videoPreview.src);
448
+ }
449
+ videoPreview.src = '';
450
+ videoPreviewContainer.classList.add('hidden');
451
+ uploadContent.classList.remove('hidden');
452
+ generateBtn.disabled = true;
453
+ videoUpload.value = '';
454
+ resetStoryOutput();
455
+ }
456
+
457
  function resetStoryOutput() {
458
  storyPlaceholder.classList.remove('hidden');
459
  loadingIndicator.classList.add('hidden');
 
461
  storyActions.classList.add('hidden');
462
  storyTitle.textContent = '';
463
  storyContent.textContent = '';
464
+ generateBtn.disabled = !videoPreview.src;
465
+ generateBtn.innerHTML = '<i class="fas fa-magic mr-2"></i> Generate Story';
466
  }
467
 
468
  // Copy story to clipboard