class PaperCard extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); } connectedCallback() { this.render(); } render() { const title = this.getAttribute('title') || ''; const authors = this.getAttribute('authors') || ''; const abstract = this.getAttribute('abstract') || ''; const year = this.getAttribute('year') || ''; const venue = this.getAttribute('venue') || ''; const citations = this.getAttribute('citations') || '0'; const references = this.getAttribute('references') || '0'; const categories = this.getAttribute('categories') || ''; const keywords = this.getAttribute('keywords') || ''; const pdfUrl = this.getAttribute('pdf-url') || ''; const url = this.getAttribute('url') || ''; const categoryTags = categories ? categories.split(',').filter(cat => cat).map(cat => this.getCategoryTag(cat)).join('') : ''; const keywordTags = keywords ? keywords.split(',').filter(kw => kw).map(kw => `${this.escapeHtml(kw)}`).join('') : ''; this.shadowRoot.innerHTML = `
${citations > 0 ? `
${citations}
` : ''}

${this.escapeHtml(title)}

${year}
${this.escapeHtml(venue)}
${references} refs
${this.escapeHtml(authors)}
${this.escapeHtml(abstract)}
${categoryTags}
${keywordTags}
${pdfUrl ? ` PDF ` : ` `} View
`; // Initialize feather icons in shadow DOM if (window.feather) { window.feather.replace({ 'stroke-width': 1.5, 'width': 16, 'height': 16 }); } } getCategoryTag(category) { const categoryMap = { 'machine-learning': { name: 'ML', class: 'tag-ml' }, 'computer-vision': { name: 'CV', class: 'tag-cv' }, 'nlp': { name: 'NLP', class: 'tag-nlp' }, 'robotics': { name: 'Robotics', class: 'tag-robotics' }, 'data-science': { name: 'Data Science', class: 'tag-ds' }, 'artificial-intelligence': { name: 'AI', class: 'tag-ml' } }; const categoryInfo = categoryMap[category.toLowerCase()] || { name: category.toUpperCase(), class: 'tag-ds' }; return `${categoryInfo.name}`; } escapeHtml(text) { const div = document.createElement('div'); div.textContent = text; return div.innerHTML; } } customElements.define('paper-card', PaperCard);