`;
let adIndex = 0;
let paraCount = 0;
// Ad after every 3 paragraphs, max 5 ads
const adEvery = Math.max(3, Math.floor(paragraphs.length / 5));
paragraphs.forEach((para, i) => {
html += `
${escHtml(para)}
`;
paraCount++;
if (paraCount % adEvery === 0 && adIndex < 5 && i < paragraphs.length - 1) {
html += adBox(adIndex + 1, adCodes[adIndex]);
adIndex++;
}
});
// Fill remaining ads if fewer than 5 placed
while (adIndex < 5) {
html += adBox(adIndex + 1, adCodes[adIndex]);
adIndex++;
}
html += `
`; // close article-body
// Footer
html += `
`;
document.getElementById('article-card').innerHTML = html;
closeAdmin();
window.scrollTo({ top: 0, behavior: 'smooth' });
}
function adBox(num, code) {
return `
বিজ্ঞাপন
${code}
`;
}
function escHtml(str) {
return str
.replace(/&/g, '&')
.replace(//g, '>')
.replace(/"/g, '"');
}
function readingTime(text) {
const words = text.split(/\s+/).length;
return Math.max(1, Math.ceil(words / 200));
}
function getBanglaDate() {
const bn = new Intl.DateTimeFormat('bn-BD', { day: 'numeric', month: 'long', year: 'numeric' });
return bn.format(new Date());
}
0 Comments