diff --git a/README.md b/README.md index 6fce471..664ffb5 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ kportal simplifies managing multiple Kubernetes port-forwards with an elegant, i ### Homebrew (macOS/Linux) ```bash -brew install lukaszraczylo/tap/kportal +brew install lukaszraczylo/brew-taps/kportal ``` ### Quick Install Script diff --git a/docs/index.html b/docs/index.html index 648e16b..bc204aa 100644 --- a/docs/index.html +++ b/docs/index.html @@ -162,9 +162,9 @@

macOS & Linux

-
- brew install lukaszraczylo/tap/kportal + brew install lukaszraczylo/brew-taps/kportal
@@ -357,17 +357,65 @@ } }); - // Copy to clipboard function + // Copy to clipboard function with fallback function copyToClipboard(text, button) { - navigator.clipboard.writeText(text).then(() => { - const originalHTML = button.innerHTML; - button.innerHTML = ''; - setTimeout(() => { - button.innerHTML = originalHTML; - }, 2000); - }).catch(err => { - console.error('Failed to copy:', err); - }); + // Modern clipboard API (preferred) + if (navigator.clipboard && navigator.clipboard.writeText) { + navigator.clipboard.writeText(text).then(() => { + showCopySuccess(button); + }).catch(err => { + console.error('Clipboard API failed:', err); + fallbackCopy(text, button); + }); + } else { + // Fallback for older browsers or insecure contexts + fallbackCopy(text, button); + } + } + + // Fallback copy method using execCommand + function fallbackCopy(text, button) { + const textarea = document.createElement('textarea'); + textarea.value = text; + textarea.style.position = 'fixed'; + textarea.style.top = '0'; + textarea.style.left = '0'; + textarea.style.opacity = '0'; + document.body.appendChild(textarea); + textarea.focus(); + textarea.select(); + + try { + const successful = document.execCommand('copy'); + if (successful) { + showCopySuccess(button); + } else { + showCopyError(button); + } + } catch (err) { + console.error('Fallback copy failed:', err); + showCopyError(button); + } + + document.body.removeChild(textarea); + } + + // Show success feedback + function showCopySuccess(button) { + const originalHTML = button.innerHTML; + button.innerHTML = ''; + setTimeout(() => { + button.innerHTML = originalHTML; + }, 2000); + } + + // Show error feedback + function showCopyError(button) { + const originalHTML = button.innerHTML; + button.innerHTML = ''; + setTimeout(() => { + button.innerHTML = originalHTML; + }, 2000); } // Smooth scrolling