AKY Mundo

Conectando con AKY...

Usuario
Sin QR

Escanea para ver el perfil

'; }, render: function() { var self = this; var data = this.allMedia.filter(function(m) { if (self.currentFilter === 'mundo') return m.type === 'video'; if (self.currentFilter === 'recuerdos') return m.type === 'image'; return true; }); if (data.length === 0) { this.videoGrid.innerHTML = '
video_library

Sin contenido

'; return; } this.videoGrid.innerHTML = ''; data.forEach(function(m, i) { var card = document.createElement('div'); card.className = 'aky-mr-video-card'; var thumb = document.createElement('div'); thumb.className = 'aky-mr-video-thumbnail'; if (m.type === 'video') { var vid = document.createElement('video'); vid.src = m.url; vid.preload = 'metadata'; vid.muted = true; thumb.appendChild(vid); } else { var img = document.createElement('img'); img.src = m.url; thumb.appendChild(img); } var overlay = document.createElement('div'); overlay.className = 'aky-mr-play-overlay'; overlay.innerHTML = '' + (m.type === 'video' ? 'play_arrow' : 'fullscreen') + ''; thumb.appendChild(overlay); var duration = document.createElement('span'); duration.className = 'aky-mr-video-duration'; duration.textContent = m.type === 'video' ? 'VIDEO' : 'IMG'; thumb.appendChild(duration); card.appendChild(thumb); var info = document.createElement('div'); info.className = 'aky-mr-video-info'; var avatar = document.createElement('div'); avatar.className = 'aky-mr-channel-avatar clickable'; if (m.userAvatar) { avatar.innerHTML = ''; } else { avatar.textContent = m.userInitial; } avatar.onclick = function(e) { e.stopPropagation(); self.showQrModal(m); }; info.appendChild(avatar); var details = document.createElement('div'); details.className = 'aky-mr-video-details'; details.innerHTML = '
' + (m.title || 'Sin titulo') + '
' + '
' + m.userName + ' • ' + self.getTimeAgo(m.timestamp) + '
'; info.appendChild(details); card.appendChild(info); card.onclick = function() { self.openModal(i); }; self.videoGrid.appendChild(card); }); }, openModal: function(index) { var self = this; var data = this.allMedia.filter(function(m) { if (self.currentFilter === 'mundo') return m.type === 'video'; if (self.currentFilter === 'recuerdos') return m.type === 'image'; return true; }); var m = data[index]; if (!m) return; var player = document.getElementById('aky-mr-video-player'); if (m.type === 'video') { player.innerHTML = ''; } else { player.innerHTML = ''; } var infoEl = document.getElementById('aky-mr-video-player-info'); infoEl.innerHTML = '
' + (m.title || 'Sin titulo') + '
' + '
' + this.getTimeAgo(m.timestamp) + ' • ' + m.likes + ' likes
' + '
' + '
' + (m.userAvatar ? '' : m.userInitial) + '
' + '
' + m.userName + '
' + '
'; this.currentModalItem = m; document.getElementById('aky-mr-video-modal').classList.add('active'); document.body.style.overflow = 'hidden'; }, closeModal: function() { document.getElementById('aky-mr-video-modal').classList.remove('active'); document.body.style.overflow = ''; var v = document.querySelector('#aky-mr-video-player video'); if (v) v.pause(); document.getElementById('aky-mr-video-player').innerHTML = ''; }, loadUserData: function(userId) { if (!userId) return Promise.resolve(null); return this.db.collection('users').doc(userId).get() .then(function(doc) { if (doc.exists) { var data = doc.data(); return { id: userId, nickname: data.nickname || data.displayName || '', followersCount: data.followersCount || 0, likesCount: data.likesCount || 0 }; } return null; }) .catch(function() { return null; }); }, generateUserQr: function(userId) { var self = this; if (!userId) return Promise.resolve(null); return this.loadUserData(userId).then(function(userData) { if (!userData) return null; var qrData = 'aky://user/' + userId; var qrUrl = 'https://api.qrserver.com/v1/create-qr-code/?size=200x200&margin=10&data=' + encodeURIComponent(qrData); return { qrUrl: qrUrl, userData: userData }; }); }, showQrModal: function(mediaItem) { var self = this; var qrAvatar = document.getElementById('aky-mr-qr-avatar'); var qrName = document.getElementById('aky-mr-qr-name'); var qrInfo = document.getElementById('aky-mr-qr-info'); var qrImage = document.getElementById('aky-mr-qr-image'); qrAvatar.innerHTML = '
'; qrName.textContent = mediaItem.userName; qrInfo.textContent = 'Cargando...'; qrImage.innerHTML = '
'; document.getElementById('aky-mr-qr-modal').classList.add('active'); if (!mediaItem.userId) { qrAvatar.textContent = mediaItem.userInitial; qrInfo.textContent = ''; qrImage.innerHTML = 'Usuario no identificado'; return; } this.generateUserQr(mediaItem.userId).then(function(result) { if (!result) { qrAvatar.textContent = mediaItem.userInitial; qrInfo.textContent = ''; qrImage.innerHTML = 'Usuario no encontrado'; return; } var userData = result.userData; if (userData.nickname) { qrName.textContent = '@' + userData.nickname; } qrInfo.textContent = userData.followersCount + ' seguidores • ' + userData.likesCount + ' likes'; if (mediaItem.userAvatar) { qrAvatar.innerHTML = ''; } else { qrAvatar.textContent = mediaItem.userInitial; } qrImage.innerHTML = 'QR'; }); }, closeQrModal: function() { document.getElementById('aky-mr-qr-modal').classList.remove('active'); } }; window.AKY_MR = AKY_MR; window.akyMRCloseModal = function() { AKY_MR.closeModal(); }; window.akyMRCloseQrModal = function() { AKY_MR.closeQrModal(); }; if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', function() { AKY_MR.init(); }); } else { AKY_MR.init(); } })();