ماكينة ازالة شعر الجسم للرجال
متبقي ${stockValue} فقط!
🔥
كمية محدودة!
${stockValue > 10 ? 'المنتج ينفذ سريعاً!' : 'تنتهي الكمية قريباً!'}
`;
// Insert after the price element
$('.wd-product-info.wd-sold-count').after(fomoBarHTML);
// Counter functionality with enhanced effects
let counter = stockValue;
const counterElement = $('.stock-counter');
const progressBar = $('.stock-progress-bar');
const messageElement = $('.stock-message');
const fomoContainer = $('.fomo-stock-notice');
const fireIcon = $('.fire-icon');
// Update counter function with enhanced visual feedback
function updateCounter() {
if (counter > 0) {
// Higher chance to decrement when stock is low
const decrementChance = counter <= 5 ? 0.5 : 0.3;
if (Math.random() < decrementChance) {
counter--;
// Animate the change with scale effect
counterElement.css('transform', 'scale(1.2)').fadeOut(150, function() {
$(this).text(`متبقي ${counter} فقط!`).fadeIn(150).css('transform', 'scale(1)');
});
// Update progress bar with smooth animation
progressBar.css('width', `${(counter / 20) * 100}%`);
// Update cache
const updatedData = JSON.parse(localStorage.getItem(cacheKey));
if (updatedData) {
updatedData.value = counter;
localStorage.setItem(cacheKey, JSON.stringify(updatedData));
}
// Dynamic styling and messages based on stock level
if (counter <= 3) {
messageElement.html('سارع بالطلب، الكمية على وشك النفاد!');
fomoContainer.addClass('low-stock').removeClass('medium-stock');
fireIcon.text('⚡');
} else if (counter <= 8) {
messageElement.html('الكمية محدودة، أسرع واحجز منتجك الآن!');
fomoContainer.addClass('medium-stock').removeClass('low-stock');
fireIcon.text('🔥');
} else {
messageElement.html('المنتج ينفذ سريعاً!');
fomoContainer.removeClass('low-stock medium-stock');
fireIcon.text('🔥');
}
// Add extra urgent animation
fomoContainer.addClass('extra-urgent');
setTimeout(() => {
fomoContainer.removeClass('extra-urgent');
}, 2000);
}
}
// Set next update with dynamic timing (faster when stock is low)
const baseInterval = counter <= 5 ? 25000 : 50000; // 25s or 50s
const randomOffset = Math.random() * 20000; // Up to 20s
setTimeout(updateCounter, baseInterval + randomOffset);
}
// Start updates after initial delay (8-25 seconds)
setTimeout(updateCounter, Math.random() * 17000 + 10000);
// Add periodic visual effects every 6 seconds
function applyPeriodicEffects() {
// Random chance for extra effects
if (Math.random() < 0.4) {
fomoContainer.addClass('extra-urgent');
setTimeout(() => {
fomoContainer.removeClass('extra-urgent');
}, 2000);
}
// Next effect cycle
setTimeout(applyPeriodicEffects, 6000);
}
setTimeout(applyPeriodicEffects, 6000);
// Enhanced hover effects
fomoContainer.hover(
function() {
$(this).css({
'transform': 'translateY(-3px) scale(1.02)',
'transition': 'all 0.3s ease'
});
},
function() {
$(this).css({
'transform': 'translateY(0) scale(1)',
'transition': 'all 0.3s ease'
});
}
);
// Add click interaction for extra engagement
fomoContainer.on('click', function() {
$(this).addClass('extra-urgent');
setTimeout(() => {
$(this).removeClass('extra-urgent');
}, 2000);
});
}
});
/* ]]> */
-->