diff --git a/containers/backupchecks/src/templates/main/job_detail.html b/containers/backupchecks/src/templates/main/job_detail.html index 99cba0c..17f0505 100644 --- a/containers/backupchecks/src/templates/main/job_detail.html +++ b/containers/backupchecks/src/templates/main/job_detail.html @@ -284,6 +284,60 @@ .replace(/'/g, "'"); } + // Cross-browser copy to clipboard function + function copyToClipboard(text, button) { + // Method 1: Modern Clipboard API (works in most browsers with HTTPS) + if (navigator.clipboard && navigator.clipboard.writeText) { + navigator.clipboard.writeText(text) + .then(function () { + showCopyFeedback(button); + }) + .catch(function () { + // Fallback to method 2 if clipboard API fails + fallbackCopy(text, button); + }); + } else { + // Method 2: Legacy execCommand method + fallbackCopy(text, button); + } + } + + function fallbackCopy(text, button) { + var textarea = document.createElement('textarea'); + textarea.value = text; + textarea.style.position = 'fixed'; + textarea.style.opacity = '0'; + textarea.style.top = '0'; + textarea.style.left = '0'; + document.body.appendChild(textarea); + textarea.focus(); + textarea.select(); + + try { + var successful = document.execCommand('copy'); + if (successful) { + showCopyFeedback(button); + } else { + // If execCommand fails, use prompt as last resort + window.prompt('Copy ticket number:', text); + } + } catch (err) { + // If all else fails, show prompt + window.prompt('Copy ticket number:', text); + } + + document.body.removeChild(textarea); + } + + function showCopyFeedback(button) { + if (!button) return; + var original = button.textContent; + button.textContent = '✓'; + setTimeout(function () { + button.textContent = original; + }, 800); + } + (function () { var currentRunId = null; @@ -319,12 +373,14 @@ html += '