// Showcase platform JavaScript
const MEDIA_LABELS = {
music: 'π΅ ι³δΉ', mtv: 'π¬ MTV', short_video: 'π± ηθ§ι’',
long_video: 'ποΈ ιΏθ§ι’', ktv: 'π€ KTV'
};
const MEDIA_ICONS = {
music: 'π΅', mtv: 'π¬', short_video: 'π±', long_video: 'ποΈ', ktv: 'π€'
};
let currentFilter = '';
async function loadFeed(mediaType) {
currentFilter = mediaType || '';
const container = document.getElementById('showcase_feed_grid');
if (!container) return;
const url = `${MODULE_PREFIX}/api/showcase_feed.dspy?media_type=${currentFilter}&page=1&page_size=30`;
try {
const resp = await fetch(url);
const result = await resp.json();
if (result.status !== 'ok' || !result.data) {
container.innerHTML = '
ζζ δ½ε
';
return;
}
renderFeedCards(container, result.data);
} catch (e) {
container.innerHTML = 'ε θ½½ε€±θ΄₯
';
}
}
function renderFeedCards(container, posts) {
if (!posts.length) {
container.innerHTML = 'ζζ δ½ε
';
return;
}
container.innerHTML = posts.map(p => `
${p.thumbnail_url ? `

` : MEDIA_ICONS[p.media_type] || 'π'}
${MEDIA_LABELS[p.media_type] || p.media_type}
${escHtml(p.title)}
β€ ${p.like_count || 0}
π¬ ${p.comment_count || 0}
π ${p.view_count || 0}
${parseFloat(p.price) > 0 ? `π° Β₯${p.price}` : ''}
`).join('');
}
function openDetail(postId) {
window.location.href = `${MODULE_PREFIX}/detail.ui?post_id=${postId}`;
}
function escHtml(s) {
if (!s) return '';
return s.replace(/&/g,'&').replace(//g,'>');
}
// Register filterByType function
if (typeof registerFunction !== 'undefined') {
registerFunction('filterByType', function(opts) {
loadFeed(opts.type);
});
}
// Auto-load on page ready
document.addEventListener('DOMContentLoaded', function() {
if (document.getElementById('showcase_feed_grid')) {
loadFeed('');
}
});