V2EX = way to explore V2EX 是一个关于分享和探索的地方
script> document.addEventListener('DOMContentLoaded', function() { // Function to escape HTML entities function escapeHtml(text) { if (!text) return ''; var div = document.createElement('div'); div.textCOntent= text; return div.innerHTML; } // Function to render campaign based on display format function renderCampaign(campaign) { let html = ''; let displayFormat = campaign.display_format || 'text-only'; let title = escapeHtml(campaign.title); let description = escapeHtml(campaign.description); let callToAction = escapeHtml(campaign.call_to_action); let link = escapeHtml(campaign.link); // Check if required image URL is available for the display format, fallback to text-only if not if (displayFormat === 'small-with-description' && !campaign.img_small_url) { displayFormat = 'text-only'; } else if (displayFormat === 'banner-only' && !campaign.img_banner_url) { displayFormat = 'text-only'; } else if ((displayFormat === 'big-only' || displayFormat === 'big-with-description' || displayFormat === 'big-with-title-description-button') && !campaign.img_big_url) { displayFormat = 'text-only'; } html = `
${title}
`; switch(displayFormat) { case 'text-only': html += `
`; break; case 'small-with-description': html += `
${campaign.img_small_cid ? `
` : ''}
${description}
`; break; case 'banner-only': html += `
`; break; case 'big-only': html += `
`; break; case 'big-with-description': html += `
`; html += `
`; break; case 'big-with-title-description-button': html += `
`; html += `
`; html += `
`; break; default: html += `
`; } html += `
` return html; } // Load campaign from emitter var xhr = new XMLHttpRequest(); xhr.open('GET', '/pro/emitter', true); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.Onreadystatechange= function() { if (xhr.readyState === 4) { if (xhr.status === 200) { try { var campaign = JSON.parse(xhr.responseText); if (campaign && campaign.id) { var html = renderCampaign(campaign); document.getElementById('pro-campaign-container').innerHTML = html; } else { // No campaign to display, hide the container document.getElementById('pro-campaign-container').style.display = 'none'; } } catch (e) { // Parse error, hide the container document.getElementById('pro-campaign-container').style.display = 'none'; console.log('Error parsing campaign data: ' + e.message); } } else { // HTTP error, hide the container document.getElementById('pro-campaign-container').style.display = 'none'; console.log('Error loading campaign: HTTP ' + xhr.status); } } }; xhr.send(); });
这是一个创建于 5122 天前的主题,其中的信息可能已经有所发展或是发生改变。
9 条回复 1970-01-01 08:00:00 +08:00  | | 2 udonmai 2011-11-21 07:48:00 +08:00 via Android cool~ |
 | | 5 lwjef 2011-11-21 19:06:10 +08:00 还有神马nanoc啦 toto啦 =。= |
 | | 6 Anylei 2011-11-21 19:36:37 +08:00 @ lwjef基于 Jekyll 的没太多尝试。 Toto 感觉扩展性差点。 Nanoc 是很棒,我现在就用这个。 |
 | | 7 ywjno 2011-11-21 19:53:12 +08:00 底层使用sinatra的scanty也还可以用,不过这东西作者太久没更新需要自己稍微改一下 支持markdown格式发布(不过说句题外话,markdown的兼容性个人感觉比不上textile来得好 |
 | | 8 chloerei 2011-11-21 20:08:55 +08:00 试用过一下,还是喜欢在网页里面写日志。 |
 | | 9 loading 2011-11-21 20:12:23 +08:00 像黑客一样收邮件 mutt。 不过现在已经是浏览器的天下了,不如在博客里加入MarkDown支持呢! @ ywjno Textile+1,不过感觉太小众了。如果我不是用了Textpattern估计不会遇到. |