(function(){
window.tampilkanSocialProof = function(data, position = "bottom") {
let index = 0;
const box = document.createElement("div");
box.style.position = "fixed";
box.style[`${position}`] = "20px";
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":"Rif****","produk":"WA Promosi - Personal","foto":"https:\/\/adhifa.com\/uploads\/WA Promosi.png","text":"Rif****<\/b> telah membeli WA Promosi - Personal","timestamp":1746161076},{"nama":"IMA****","produk":"WA Promosi - Personal","foto":"https:\/\/adhifa.com\/uploads\/WA Promosi.png","text":"IMA****<\/b> telah membeli WA Promosi - Personal","timestamp":1745637646},{"nama":"Yan****","produk":"WA Promosi - Personal","foto":"https:\/\/adhifa.com\/uploads\/WA Promosi.png","text":"Yan****<\/b> telah membeli WA Promosi - Personal","timestamp":1728399301},{"nama":"Ani****","produk":"WA Promosi - Personal","foto":"https:\/\/adhifa.com\/uploads\/WA Promosi.png","text":"Ani****<\/b> telah membeli WA Promosi - Personal","timestamp":1726103847},{"nama":"Oke****","produk":"WA Promosi - Personal","foto":"https:\/\/adhifa.com\/uploads\/WA Promosi.png","text":"Oke****<\/b> telah membeli WA Promosi - Personal","timestamp":1724217999},{"nama":"Non****","produk":"WA Promosi - Personal","foto":"https:\/\/adhifa.com\/uploads\/WA Promosi.png","text":"Non****<\/b> telah membeli WA Promosi - Personal","timestamp":1724152875},{"nama":"Cat****","produk":"WA Promosi - Personal","foto":"https:\/\/adhifa.com\/uploads\/WA Promosi.png","text":"Cat****<\/b> telah membeli WA Promosi - Personal","timestamp":1723026851},{"nama":"And****","produk":"WA Promosi - Personal","foto":"https:\/\/adhifa.com\/uploads\/WA Promosi.png","text":"And****<\/b> telah membeli WA Promosi - Personal","timestamp":1722825451},{"nama":"Ahm****","produk":"WA Promosi - Personal","foto":"https:\/\/adhifa.com\/uploads\/WA Promosi.png","text":"Ahm****<\/b> telah membeli WA Promosi - Personal","timestamp":1722769224}], 'top');
})();