Live Orders Widget
:root{
--lo-bg: #ffffff;
--lo-border: #e5e7eb;
--lo-text: #1f2937;
--lo-muted: #6b7280;
--lo-accent: #16a34a;
--lo-badge-bg: #16a34a;
--lo-icon-bg: #2563eb;
--lo-shadow: 0 10px 30px rgba(0,0,0,0.15);
}
/* Container fixé en bas à gauche de l'écran (adapter left/right selon RTL) */
#liveOrderContainer{
position: fixed;
left: 16px;
bottom: 16px;
z-index: 999999;
max-width: 320px;
width: calc(100% - 32px);
font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
pointer-events: none; /* pour ne pas bloquer les clics sous le widget */
}
.lo-card{
direction: rtl;
background: var(--lo-bg);
border: 1px solid var(--lo-border);
border-radius: 14px;
box-shadow: var(--lo-shadow);
padding: 12px 14px;
display: flex;
align-items: flex-start;
gap: 10px;
opacity: 0;
transform: translateY(30px) scale(0.95);
transition: opacity .45s ease, transform .45s ease;
pointer-events: auto;
}
.lo-card.lo-show{
opacity: 1;
transform: translateY(0) scale(1);
}
.lo-icon{
flex: 0 0 auto;
width: 40px;
height: 40px;
border-radius: 50%;
background: var(--lo-icon-bg);
color: #fff;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
}
.lo-body{
flex: 1;
min-width: 0;
}
.lo-top{
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 2px;
}
.lo-new{
font-size: 12px;
color: var(--lo-muted);
display: flex;
align-items: center;
gap: 4px;
}
.lo-close{
cursor: pointer;
color: var(--lo-muted);
font-size: 14px;
line-height: 1;
padding: 2px 4px;
}
.lo-close:hover{ color: #ef4444; }
.lo-name{
font-size: 14px;
font-weight: 700;
color: var(--lo-text);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.lo-name span#lo-city{
font-weight: 400;
color: var(--lo-muted);
font-size: 13px;
}
.lo-product{
font-size: 13px;
color: var(--lo-text);
margin-top: 2px;
display: flex;
align-items: center;
gap: 4px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.lo-bottom{
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 6px;
}
.lo-time{
font-size: 12px;
color: var(--lo-muted);
display: flex;
align-items: center;
gap: 4px;
}
.lo-badge{
font-size: 11px;
font-weight: 600;
color: #fff;
background: var(--lo-badge-bg);
border-radius: 20px;
padding: 3px 10px;
display: flex;
align-items: center;
gap: 3px;
}
@media (max-width: 480px){
#liveOrderContainer{
left: 10px;
bottom: 10px;
max-width: 260px;
}
.lo-icon{ width: 34px; height: 34px; font-size: 15px; }
.lo-name{ font-size: 13px; }
.lo-product{ font-size: 12px; }
}
<!-- Emplacement du widget : à coller juste avant la balise de votre landing page -->
(function(){
// ================= CONFIGURATION =================
// Modifiez cette liste avec vos propres commandes (vraies ou d'exemple)
const OFFER = "اشترى علبة واحصل على الثانية مجانا";
const orders = [
{ name: "سمية", city: "من سطيف", product: OFFER, timeAgo: "منذ 9 دقائق" },
{ name: "كريم", city: "من وهران", product: OFFER, timeAgo: "منذ 3 دقائق" },
{ name: "ياسين", city: "من الجزائر", product: OFFER, timeAgo: "منذ 6 دقائق" },
{ name: "فاطمة", city: "من قسنطينة", product: OFFER, timeAgo: "منذ دقيقتين" },
{ name: "عبد الله", city: "من عنابة", product: OFFER, timeAgo: "منذ 12 دقيقة" },
{ name: "خديجة", city: "من البليدة", product: OFFER, timeAgo: "منذ 4 دقائق" },
{ name: "محمد", city: "من تلمسان", product: OFFER, timeAgo: "منذ 7 دقائق" },
{ name: "أمينة", city: "من باتنة", product: OFFER, timeAgo: "منذ دقيقة واحدة" },
{ name: "يوسف", city: "من سيدي بلعباس", product: OFFER, timeAgo: "منذ 15 دقيقة" },
{ name: "مريم", city: "من بجاية", product: OFFER, timeAgo: "منذ 5 دقائق" },
{ name: "إسماعيل", city: "من الشلف", product: OFFER, timeAgo: "منذ 8 دقائق" },
{ name: "زينب", city: "من مستغانم", product: OFFER, timeAgo: "منذ 10 دقائق" },
{ name: "بلال", city: "من ورقلة", product: OFFER, timeAgo: "منذ 3 دقائق" },
{ name: "نور الهدى", city: "من الأغواط", product: OFFER, timeAgo: "منذ دقيقتين" },
{ name: "رياض", city: "من تيزي وزو", product: OFFER, timeAgo: "منذ 6 دقائق" },
{ name: "سارة", city: "من غرداية", product: OFFER, timeAgo: "منذ 11 دقيقة" },
{ name: "عمر", city: "من جيجل", product: OFFER, timeAgo: "منذ 4 دقائق" },
{ name: "حنان", city: "من المدية", product: OFFER, timeAgo: "منذ 9 دقائق" },
{ name: "أنيس", city: "من خنشلة", product: OFFER, timeAgo: "منذ دقيقة واحدة" },
{ name: "لمياء", city: "من سكيكدة", product: OFFER, timeAgo: "منذ 7 دقائق" },
{ name: "طارق", city: "من البويرة", product: OFFER, timeAgo: "منذ 13 دقيقة" },
{ name: "إيمان", city: "من تبسة", product: OFFER, timeAgo: "منذ 5 دقائق" },
{ name: "حمزة", city: "من الطارف", product: OFFER, timeAgo: "منذ 8 دقائق" },
{ name: "وفاء", city: "من المسيلة", product: OFFER, timeAgo: "منذ دقيقتين" },
{ name: "سفيان", city: "من أدرار", product: OFFER, timeAgo: "منذ 6 دقائق" }
];
// Délai avant la 1ère notif, durée d'affichage, et intervalle entre 2 notifs (en ms)
const FIRST_DELAY = 2000;
const DISPLAY_TIME = 5000;
const GAP_BETWEEN = 4000;
// ====================================================
const container = document.getElementById('liveOrderContainer');
let index = 0;
function buildCard(order){
const card = document.createElement('div');
card.className = 'lo-card';
card.dir = 'rtl';
card.innerHTML = `
🛍️
🟢 طلب جديد الآن
✕
${order.name} ${order.city}
💎 ${order.product}
🕐 ${order.timeAgo}
✅ طلب مؤكد
`;
card.querySelector('.lo-close').addEventListener('click', () => hideCard(card));
return card;
}
function hideCard(card){
card.classList.remove('lo-show');
setTimeout(() => card.remove(), 450);
}
function showNext(){
// retire toute carte encore visible
container.querySelectorAll('.lo-card').forEach(hideCard);
const order = orders[index % orders.length];
index++;
const card = buildCard(order);
container.appendChild(card);
// forcer le reflow pour déclencher la transition
requestAnimationFrame(() => requestAnimationFrame(() => card.classList.add('lo-show')));
// planifie la disparition puis la prochaine notif
setTimeout(() => {
hideCard(card);
setTimeout(showNext, GAP_BETWEEN);
}, DISPLAY_TIME);
}
setTimeout(showNext, FIRST_DELAY);
})();