fix on copy link
This commit is contained in:
@@ -1472,9 +1472,11 @@ const RoomsApp = (function() {
|
|||||||
|
|
||||||
copyInviteBtn.onclick = async () => {
|
copyInviteBtn.onclick = async () => {
|
||||||
try {
|
try {
|
||||||
console.log('Copying to clipboard:', inviteUrl);
|
console.log('Attempting to copy:', inviteUrl);
|
||||||
await navigator.clipboard.writeText(inviteUrl);
|
|
||||||
|
|
||||||
|
const success = await copyToClipboard(inviteUrl);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
const originalHTML = copyInviteBtn.innerHTML;
|
const originalHTML = copyInviteBtn.innerHTML;
|
||||||
copyInviteBtn.innerHTML = `
|
copyInviteBtn.innerHTML = `
|
||||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||||
@@ -1489,8 +1491,12 @@ const RoomsApp = (function() {
|
|||||||
}, 2000);
|
}, 2000);
|
||||||
|
|
||||||
showCopyToast(window.__roomExposed ? 'Public link copied!' : 'Local link copied!');
|
showCopyToast(window.__roomExposed ? 'Public link copied!' : 'Local link copied!');
|
||||||
|
} else {
|
||||||
|
showManualCopyModal(inviteUrl);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to copy:', err);
|
console.error('Failed to copy:', err);
|
||||||
|
showManualCopyModal(inviteUrl);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1504,6 +1510,61 @@ const RoomsApp = (function() {
|
|||||||
if (room.currentVideo) loadVideo(room.currentVideo);
|
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() {
|
async function initGlobalControls() {
|
||||||
const hasAccess = isHost || (window.__userPermissions?.canManageQueue || false);
|
const hasAccess = isHost || (window.__userPermissions?.canManageQueue || false);
|
||||||
if (!hasAccess || !extensionsReady) return;
|
if (!hasAccess || !extensionsReady) return;
|
||||||
|
|||||||
@@ -1472,9 +1472,11 @@ const RoomsApp = (function() {
|
|||||||
|
|
||||||
copyInviteBtn.onclick = async () => {
|
copyInviteBtn.onclick = async () => {
|
||||||
try {
|
try {
|
||||||
console.log('Copying to clipboard:', inviteUrl);
|
console.log('Attempting to copy:', inviteUrl);
|
||||||
await navigator.clipboard.writeText(inviteUrl);
|
|
||||||
|
|
||||||
|
const success = await copyToClipboard(inviteUrl);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
const originalHTML = copyInviteBtn.innerHTML;
|
const originalHTML = copyInviteBtn.innerHTML;
|
||||||
copyInviteBtn.innerHTML = `
|
copyInviteBtn.innerHTML = `
|
||||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||||
@@ -1489,8 +1491,12 @@ const RoomsApp = (function() {
|
|||||||
}, 2000);
|
}, 2000);
|
||||||
|
|
||||||
showCopyToast(window.__roomExposed ? 'Public link copied!' : 'Local link copied!');
|
showCopyToast(window.__roomExposed ? 'Public link copied!' : 'Local link copied!');
|
||||||
|
} else {
|
||||||
|
showManualCopyModal(inviteUrl);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to copy:', err);
|
console.error('Failed to copy:', err);
|
||||||
|
showManualCopyModal(inviteUrl);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1504,6 +1510,61 @@ const RoomsApp = (function() {
|
|||||||
if (room.currentVideo) loadVideo(room.currentVideo);
|
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() {
|
async function initGlobalControls() {
|
||||||
const hasAccess = isHost || (window.__userPermissions?.canManageQueue || false);
|
const hasAccess = isHost || (window.__userPermissions?.canManageQueue || false);
|
||||||
if (!hasAccess || !extensionsReady) return;
|
if (!hasAccess || !extensionsReady) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user