(function(){
window.tampilkanSocialProof = function(data, position = "bottom") {
let index = 0;
const box = document.createElement("div");
box.style.position = "fixed";
box.style[`${position}`] = "40px";
box.style.left = "20px";
box.style.background = "#fff";
box.style.border = "1px solid #ddd";
box.style.padding = "10px";
box.style.borderRadius = "8px";
box.style.boxShadow = "0 2px 8px rgba(0,0,0,0.2)";
box.style.fontFamily = "Arial, sans-serif";
box.style.fontSize = "14px";
box.style.zIndex = "9999";
box.style.display = "flex";
box.style.alignItems = "center";
box.style.maxWidth = "300px";
box.style.transition = "opacity 0.5s ease";
document.body.appendChild(box);
function tampilkanBerikutnya() {
if (index >= data.length) index = 0;
const item = data[index++];
const waktu = formatTimeAgo(item.timestamp);
box.innerHTML = `
${item.text}
${waktu}
`;
box.style.opacity = "1";
setTimeout(() => box.style.opacity = "0", 6000);
setTimeout(tampilkanBerikutnya, 8000);
}
function maskNama(nama) {
return nama.length > 3 ? nama.substring(0, 3) + '****' : nama;
}
function formatTimeAgo(timestamp) {
const now = Math.floor(Date.now() / 1000);
const diff = now - timestamp;
if (diff < 60) return "baru saja";
if (diff < 3600) return `${Math.floor(diff / 60)} menit lalu`;
if (diff < 86400) return `${Math.floor(diff / 3600)} jam lalu`;
return `${Math.floor(diff / 86400)} hari lalu`;
}
tampilkanBerikutnya();
};
window.tampilkanSocialProof([{"nama":"Bri****","produk":"IMember - Starter","foto":"https:\/\/adhifa.com\/uploads\/cover_1.png","text":"Bri****<\/b> telah membeli produk IMember - Starter","timestamp":1748706719},{"nama":"Arm****","produk":"IMember - Starter","foto":"https:\/\/adhifa.com\/uploads\/cover_1.png","text":"Arm****<\/b> telah membeli produk IMember - Starter","timestamp":1748313296},{"nama":"Kol****","produk":"IMember - Starter","foto":"https:\/\/adhifa.com\/uploads\/cover_1.png","text":"Kol****<\/b> telah membeli produk IMember - Starter","timestamp":1748167747},{"nama":"mon****","produk":"IMember - Starter","foto":"https:\/\/adhifa.com\/uploads\/cover_1.png","text":"mon****<\/b> telah membeli produk IMember - Starter","timestamp":1748148973},{"nama":"Abd****","produk":"IMember - Starter","foto":"https:\/\/adhifa.com\/uploads\/cover_1.png","text":"Abd****<\/b> telah membeli produk IMember - Starter","timestamp":1748137913},{"nama":"ahm****","produk":"IMember - Starter","foto":"https:\/\/adhifa.com\/uploads\/cover_1.png","text":"ahm****<\/b> telah membeli produk IMember - Starter","timestamp":1748103417},{"nama":"izz****","produk":"IMember - Starter","foto":"https:\/\/adhifa.com\/uploads\/cover_1.png","text":"izz****<\/b> telah membeli produk IMember - Starter","timestamp":1748102037},{"nama":"MOH****","produk":"IMember - Starter","foto":"https:\/\/adhifa.com\/uploads\/cover_1.png","text":"MOH****<\/b> telah membeli produk IMember - Starter","timestamp":1718269460},{"nama":"Haz****","produk":"IMember - Starter","foto":"https:\/\/adhifa.com\/uploads\/cover_1.png","text":"Haz****<\/b> telah membeli produk IMember - Starter","timestamp":1717886896}], 'top');
})();