@@ -644,8 +640,6 @@
const processLoader = document.getElementById('process-loader');
const cropCanvas = document.getElementById('crop-canvas');
const cropCtx = cropCanvas.getContext('2d');
- const cropModeBtn = document.getElementById('crop-mode-btn');
- const cropHint = document.getElementById('crop-hint');
const videoPreview = document.getElementById('video-preview');
const currentTimeDisplay = document.getElementById('current-time-display');
const setStartBtn = document.getElementById('set-start-btn');
@@ -709,6 +703,10 @@
Resolution: ${videoInfo.width}x${videoInfo.height}
Duration: ${videoInfo.duration.toFixed(2)} seconds
Codec: ${videoInfo.codec}
+
+
+
Click and drag on the video to select crop area
+
`;
// Set default values
@@ -720,6 +718,9 @@
// Setup canvas for cropping
setupCropCanvas();
+ // Setup crop mode button (now that it exists)
+ setupCropButton();
+
// Show edit section
document.getElementById('upload-section').classList.add('hidden');
document.getElementById('edit-section').classList.remove('hidden');
@@ -750,23 +751,28 @@
cropCanvas.height = video.offsetHeight;
}
- // Crop mode toggle
- cropModeBtn.addEventListener('click', () => {
- cropMode = !cropMode;
- if (cropMode) {
- cropCanvas.classList.add('active');
- cropModeBtn.classList.add('active');
- cropModeBtn.textContent = '❌ Cancel Crop Selection';
- cropHint.style.display = 'block';
- document.getElementById('video-preview').pause();
- } else {
- cropCanvas.classList.remove('active');
- cropModeBtn.classList.remove('active');
- cropModeBtn.textContent = '🎯 Click to Draw Crop Area';
- cropHint.style.display = 'none';
- clearCropCanvas();
- }
- });
+ // Setup crop button event listener
+ function setupCropButton() {
+ const cropModeBtn = document.getElementById('crop-mode-btn');
+ const cropHint = document.getElementById('crop-hint');
+
+ cropModeBtn.addEventListener('click', () => {
+ cropMode = !cropMode;
+ if (cropMode) {
+ cropCanvas.classList.add('active');
+ cropModeBtn.classList.add('active');
+ cropModeBtn.textContent = '❌ Cancel Crop Selection';
+ cropHint.style.display = 'block';
+ document.getElementById('video-preview').pause();
+ } else {
+ cropCanvas.classList.remove('active');
+ cropModeBtn.classList.remove('active');
+ cropModeBtn.textContent = '🎯 Click to Draw Crop Area';
+ cropHint.style.display = 'none';
+ clearCropCanvas();
+ }
+ });
+ }
// Canvas drawing for crop selection
let isDrawing = false;
@@ -820,9 +826,15 @@
// Exit crop mode
cropMode = false;
- cropModeBtn.classList.remove('active');
- cropModeBtn.textContent = '🎯 Click to Draw Crop Area';
- cropHint.style.display = 'none';
+ const cropModeBtn = document.getElementById('crop-mode-btn');
+ const cropHint = document.getElementById('crop-hint');
+ if (cropModeBtn) {
+ cropModeBtn.classList.remove('active');
+ cropModeBtn.textContent = '🎯 Click to Draw Crop Area';
+ }
+ if (cropHint) {
+ cropHint.style.display = 'none';
+ }
// Keep the rectangle visible for a moment
setTimeout(() => {
@@ -1041,9 +1053,6 @@
videoInput.value = '';
clearCropCanvas();
cropCanvas.classList.remove('active');
- cropModeBtn.classList.remove('active');
- cropModeBtn.textContent = '🎯 Click to Draw Crop Area';
- cropHint.style.display = 'none';
// Reset all form inputs
document.getElementById('start-time').value = '0';