fix on copy link
This commit is contained in:
@@ -1472,25 +1472,31 @@ const RoomsApp = (function() {
|
||||
|
||||
copyInviteBtn.onclick = async () => {
|
||||
try {
|
||||
console.log('Copying to clipboard:', inviteUrl);
|
||||
await navigator.clipboard.writeText(inviteUrl);
|
||||
console.log('Attempting to copy:', inviteUrl);
|
||||
|
||||
const originalHTML = copyInviteBtn.innerHTML;
|
||||
copyInviteBtn.innerHTML = `
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<polyline points="20 6 9 17 4 12"></polyline>
|
||||
</svg>
|
||||
`;
|
||||
copyInviteBtn.style.color = '#4ade80';
|
||||
const success = await copyToClipboard(inviteUrl);
|
||||
|
||||
setTimeout(() => {
|
||||
copyInviteBtn.innerHTML = originalHTML;
|
||||
copyInviteBtn.style.color = '';
|
||||
}, 2000);
|
||||
if (success) {
|
||||
const originalHTML = copyInviteBtn.innerHTML;
|
||||
copyInviteBtn.innerHTML = `
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<polyline points="20 6 9 17 4 12"></polyline>
|
||||
</svg>
|
||||
`;
|
||||
copyInviteBtn.style.color = '#4ade80';
|
||||
|
||||
showCopyToast(window.__roomExposed ? 'Public link copied!' : 'Local link copied!');
|
||||
setTimeout(() => {
|
||||
copyInviteBtn.innerHTML = originalHTML;
|
||||
copyInviteBtn.style.color = '';
|
||||
}, 2000);
|
||||
|
||||
showCopyToast(window.__roomExposed ? 'Public link copied!' : 'Local link copied!');
|
||||
} else {
|
||||
showManualCopyModal(inviteUrl);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to copy:', err);
|
||||
showManualCopyModal(inviteUrl);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1504,6 +1510,61 @@ const RoomsApp = (function() {
|
||||
if (room.currentVideo) loadVideo(room.currentVideo);
|
||||
}
|
||||
|
||||
function showManualCopyModal(text) {
|
||||
const modal = document.createElement('div');
|
||||
modal.className = 'modal-overlay show';
|
||||
modal.innerHTML = `
|
||||
<div class="modal-content" style="max-width: 500px;">
|
||||
<h2 class="modal-title">Copy Invite Link</h2>
|
||||
<p style="color: #aaa; margin-bottom: 16px;">Select and copy this link:</p>
|
||||
<input type="text" readonly value="${text}"
|
||||
style="width: 100%; padding: 12px; font-family: monospace; font-size: 0.9rem;"
|
||||
onclick="this.select()">
|
||||
<div class="form-actions" style="margin-top: 20px;">
|
||||
<button class="btn-confirm" onclick="this.closest('.modal-overlay').remove()">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
document.body.appendChild(modal);
|
||||
|
||||
// Auto-seleccionar el texto
|
||||
setTimeout(() => {
|
||||
const input = modal.querySelector('input');
|
||||
if (input) input.select();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
async function copyToClipboard(text) {
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
return true;
|
||||
} catch (err) {
|
||||
console.warn('Clipboard API failed, trying fallback:', err);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const textArea = document.createElement("textarea");
|
||||
textArea.value = text;
|
||||
textArea.style.position = "fixed";
|
||||
textArea.style.left = "-999999px";
|
||||
textArea.style.top = "-999999px";
|
||||
document.body.appendChild(textArea);
|
||||
textArea.focus();
|
||||
textArea.select();
|
||||
|
||||
const successful = document.execCommand('copy');
|
||||
document.body.removeChild(textArea);
|
||||
|
||||
if (successful) return true;
|
||||
throw new Error('execCommand failed');
|
||||
} catch (err) {
|
||||
console.error('All clipboard methods failed:', err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async function initGlobalControls() {
|
||||
const hasAccess = isHost || (window.__userPermissions?.canManageQueue || false);
|
||||
if (!hasAccess || !extensionsReady) return;
|
||||
|
||||
Reference in New Issue
Block a user