From 3a97f3c52aafb10e0a46bf3dfa39b4a6dbdec018 Mon Sep 17 00:00:00 2001 From: igennova Date: Thu, 20 Mar 2025 03:02:27 +0530 Subject: [PATCH] done --- website/templates/report.html | 125 ++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/website/templates/report.html b/website/templates/report.html index 7f5baf5435..57b4ed1da1 100644 --- a/website/templates/report.html +++ b/website/templates/report.html @@ -260,6 +260,10 @@

{% trans "Bug Descripti

PNG, JPG, GIF up to 5 images

+
+ + Pro tip: You can also paste images directly (Ctrl+V) +
@@ -476,6 +480,127 @@

{% trans "Team Members" %}

let email_container = document.getElementById("email-container"); email_container.appendChild(email_container_child_html) } + // Enhanced paste functionality for screenshot uploads +document.addEventListener('DOMContentLoaded', function() { + // Make the entire page listen for paste events + document.addEventListener('paste', function(e) { + // Only process paste if we're focused on relevant elements or the document body + const activeElement = document.activeElement; + const notInTextInput = activeElement.tagName !== 'INPUT' && + activeElement.tagName !== 'TEXTAREA' && + !activeElement.isContentEditable; + + if (notInTextInput || activeElement === document.body) { + var items = (e.clipboardData || e.originalEvent.clipboardData).items; + let foundImage = false; + + for (var index in items) { + var item = items[index]; + if (item.kind === 'file' && item.type.indexOf('image/') !== -1) { + foundImage = true; + var blob = item.getAsFile(); + var reader = new FileReader(); + + reader.onload = function(event) { + // Create a unique filename with timestamp + const timestamp = new Date().getTime(); + const filename = `pasted-image-${timestamp}.png`; + + // Create a File object from the blob with our custom filename + var file = new File([blob], filename, {type: blob.type}); + + // Add file to the file input + var dt = new DataTransfer(); + var fileInput = document.getElementById('screenshots'); + + // Add existing files + if (fileInput && fileInput.files) { + for (var i = 0; i < fileInput.files.length; i++) { + dt.items.add(fileInput.files[i]); + } + } + + // Add the new file + dt.items.add(file); + + // Replace the file input's FileList + if (fileInput) { + fileInput.files = dt.files; + + // Trigger the change event to update the UI + fileInput.dispatchEvent(new Event('change', { bubbles: true })); + + // Show toast notification + showToast('Image pasted successfully!'); + } + }; + reader.readAsDataURL(blob); + break; + } + } + + if (foundImage) { + e.preventDefault(); + } + } + }); + + // Add a toast notification system + if (!document.getElementById('toast-container')) { + const toastContainer = document.createElement('div'); + toastContainer.id = 'toast-container'; + toastContainer.style.cssText = 'position: fixed; bottom: 20px; right: 20px; z-index: 10000;'; + document.body.appendChild(toastContainer); + } +}); + +// Function to show toast notifications +function showToast(message, type = 'success') { + const toastContainer = document.getElementById('toast-container'); + const toast = document.createElement('div'); + + // Set toast styling based on type + const backgroundColor = type === 'success' ? '#10b981' : '#ef4444'; + + toast.style.cssText = ` + background-color: ${backgroundColor}; + color: white; + padding: 12px 20px; + border-radius: 8px; + margin-top: 10px; + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); + display: flex; + align-items: center; + opacity: 0; + transform: translateY(20px); + transition: all 0.3s ease; + `; + + // Add icon based on type + const icon = type === 'success' ? 'fa-check-circle' : 'fa-exclamation-circle'; + toast.innerHTML = ` + + ${message} + `; + + toastContainer.appendChild(toast); + + // Trigger animation + setTimeout(() => { + toast.style.opacity = '1'; + toast.style.transform = 'translateY(0)'; + }, 10); + + // Auto-remove toast after 3 seconds + setTimeout(() => { + toast.style.opacity = '0'; + toast.style.transform = 'translateY(-20px)'; + + setTimeout(() => { + toastContainer.removeChild(toast); + }, 300); + }, 3000); +} document.addEventListener("DOMContentLoaded", function() { // Get the value from the URL parameter