doughdash-delights / script.js
ch1245's picture
add{%- comment -%}
6edb49c verified
Raw History Blame Contribute Delete
988 Bytes
document.addEventListener('DOMContentLoaded', function() {
// Format all currency elements
document.querySelectorAll('.currency').forEach(el => {
const amount = parseFloat(el.textContent);
el.textContent = amount.toLocaleString('en-US', {
style: 'currency',
currency: 'USD'
});
});
// Add tooltips to all elements with data-tooltip attribute
tippy('[data-tooltip]', {
content(reference) {
return reference.getAttribute('data-tooltip');
},
});
});
// Balance pulse animation for low balance warning
function animateBalanceWarning() {
const balanceWarning = document.querySelector('.balance-warning');
if (balanceWarning) {
balanceWarning.classList.add('animate-pulse-slow');
}
}
// Initialize when DOM is loaded
if (document.readyState !== 'loading') {
animateBalanceWarning();
} else {
document.addEventListener('DOMContentLoaded', animateBalanceWarning);
}