Форумы
The great place to discuss topics with other users
To display amount of users already joined your network
'fun little trick
{* Users joined counter with smooth viral effect *}
<div class="mt-4 text-white hero-fade-slide delay-4 position-relative">
<h3 class="fw-bold mb-1" id="user-counter">{$total_users|number_format}</h3>
<p class="mb-0">Users already joined</p>
</div>
{* Smooth viral counter script compatible with Smarty *}
<script>
document.addEventListener("DOMContentLoaded", function() {
var el = document.getElementById("user-counter");
var currentUsers = {$total_users}; // actual total users from DB
// Function to increment counter smoothly
function incrementCounter(amount) {
var start = currentUsers;
var end = currentUsers + amount;
var duration = 800; // animation duration
var startTime = null;
function step(timestamp) {
if (!startTime) startTime = timestamp;
var progress = Math.min((timestamp - startTime) / duration, 1);
var value = Math.floor(start + (end - start) * progress);
el.textContent = value.toLocaleString();
if (progress < 1) requestAnimationFrame(step);
}
requestAnimationFrame(step);
currentUsers = end;
}
// Show small viral +1 effect visually
function showPopup(amount) {
var popup = document.createElement('div');
popup.textContent = '+' + amount; // plain concatenation works with Smarty
popup.style.position = 'absolute';
popup.style.color = '#00ffcc';
popup.style.fontWeight = 'bold';
popup.style.top = (Math.random() * 40 + 0) + '%';
popup.style.left = (Math.random() * 60 + 20) + '%';
popup.style.opacity = '1';
popup.style.transition = 'all 1s ease-out';
el.parentElement.appendChild(popup);
setTimeout(function() {
popup.style.top = (parseFloat(popup.style.top) - 20) + '%';
popup.style.opacity = '0';
}, 50);
setTimeout(function() {
popup.remove();
}, 1000);
}
// Increment counter periodically based on real users
setInterval(function() {
var newUsers = Math.floor(Math.random() * 3 + 1); // 1-3 new users
incrementCounter(newUsers);
showPopup(newUsers);
}, 4000); // every 4 seconds
});
</script>