à¦à¦¿à¦¡à¦¿à¦“ দেখতে à¦à¦•াউনà§à¦Ÿ লাগবে!
আমাদের পà§à¦²à§à¦¯à¦¾à¦Ÿà¦«à¦°à§à¦®à§‡ অà§à¦¯à¦¾à¦•াউনà§à¦Ÿ ছাড়া à¦à¦¿à¦¡à¦¿à¦“ দেখা যাবে না।
দয়া করে নিচের উপায়ে যেকোনো à¦à¦•টি অপশন বেছে নিন:
`;
} else {
elements.userName.textContent = 'Guest User';
elements.profilePic.innerHTML = `
`;
}
}
function updateAdButtonUI() {
const videoProgress = document.getElementById('video-progress');
const webProgress = document.getElementById('web-progress');
const videoCountText = document.getElementById('video-count-text');
const webCountText = document.getElementById('web-count-text');
if (videoProgress) videoProgress.style.width = `${(appData.videoAdCount / MAX_VIDEO_ADS) * 100}%`;
if (webProgress) webProgress.style.width = `${(appData.webVisitCount / MAX_WEB_VISITS) * 100}%`;
if (videoCountText) videoCountText.textContent = `(${appData.videoAdCount}/${MAX_VIDEO_ADS})`;
if (webCountText) webCountText.textContent = `(${appData.webVisitCount}/${MAX_WEB_VISITS})`;
elements.showAdsBtn.disabled = appData.videoAdCount >= MAX_VIDEO_ADS;
elements.webVisitBtn.disabled = appData.webVisitCount >= MAX_WEB_VISITS;
}
function updateStatsUI() {
const now = new Date();
const todayStr = now.toISOString().split('T')[0];
const todayClicks = appData.clickHistory.find(d => d.date === todayStr)?.clicks || 0;
const getClicksSince = (days) => appData.clickHistory.filter(d => (now - new Date(d.date)) / (1000 * 60 * 60 * 24) < days).reduce((s, d) => s + d.clicks, 0);
const totalClicks = appData.clickHistory.reduce((s, d) => s + d.clicks, 0);
gsap.to(elements.todayClicks, { duration: 0.5, innerText: todayClicks, snap: { innerText: 1 } });
gsap.to(elements.weekClicks, { duration: 0.5, innerText: getClicksSince(7), snap: { innerText: 1 } });
gsap.to(elements.monthClicks, { duration: 0.5, innerText: getClicksSince(30), snap: { innerText: 1 } });
gsap.to(elements.totalClicks, { duration: 0.5, innerText: totalClicks, snap: { innerText: 1 } });
}
function updateIpHistoryUI() {
elements.ipHistoryList.innerHTML = '';
appData.ipHistory.forEach(ip => {
const li = document.createElement('li');
let c = 'ip-green';
if (ip.visitCount === 2) c = 'ip-yellow';
else if (ip.visitCount > 2) c = 'ip-red';
li.className = c;
li.innerHTML = `${ip.ip} ${ip.clicks} Clicks`;
elements.ipHistoryList.appendChild(li);
});
}
let clickChartInstance;
function updateChart() {
const canvas = document.getElementById('click-chart');
if (!canvas) return;
const ctx = canvas.getContext('2d');
const labels = [];
const dataPoints = [];
for (let i = 29; i >= 0; i--) {
const date = new Date();
date.setDate(date.getDate() - i);
const dateStr = date.toISOString().split('T')[0];
labels.push(date.toLocaleDateString('en-US', { day: 'numeric', month: 'short' }));
const dayData = appData.clickHistory.find(d => d.date === dateStr);
dataPoints.push(dayData ? dayData.clicks : 0);
}
if (clickChartInstance) {
clickChartInstance.data.labels = labels;
clickChartInstance.data.datasets[0].data = dataPoints;
clickChartInstance.update();
} else {
clickChartInstance = new Chart(ctx, {
type: 'line',
data: {
labels,
datasets: [{
label: 'Daily Clicks',
data: dataPoints,
borderColor: 'rgba(233, 69, 96, 1)',
backgroundColor: 'rgba(233, 69, 96, 0.2)',
fill: true,
tension: 0.4
}]
},
options: {
responsive: true,
scales: {
y: { beginAtZero: true, ticks: { color: 'rgba(255,255,255,0.7)' } },
x: { ticks: { color: 'rgba(255,255,255,0.7)' } }
},
plugins: {
legend: { labels: { color: 'rgba(255,255,255,0.9)' } }
}
}
});
}
}
function updateAllUI() {
updateStatsUI();
updateIpHistoryUI();
updateAdButtonUI();
updateChart();
}
// --- Start App ---
initializeApp();
});