Spaces:
Running
Running
File size: 2,087 Bytes
d17291c 7afbe2a d17291c 7afbe2a d17291c 7afbe2a d17291c 7afbe2a f534c67 7afbe2a d17291c 7afbe2a d17291c f534c67 d17291c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
document.addEventListener('DOMContentLoaded', function() {
const buyButtons = document.querySelectorAll('.buy-btn');
const sellButtons = document.querySelectorAll('.sell-btn');
buyButtons.forEach(button => {
button.addEventListener('click', function() {
const card = this.closest('.paper-card');
showNotification(card, 'success', 'Purchase Successful', 'Your paper order has been placed successfully!');
});
});
sellButtons.forEach(button => {
button.addEventListener('click', function() {
const card = this.closest('.paper-card');
showNotification(card, 'error', 'Sell Request Failed', 'Minimum sell quantity not met. Please try again.');
});
});
function showNotification(card, type, title, message) {
const notification = card.querySelector('.notification');
const successIcon = card.querySelector('.success-icon');
const errorIcon = card.querySelector('.error-icon');
const notificationTitle = card.querySelector('.notification-title');
const notificationMessage = card.querySelector('.notification-message');
// Set notification content
notificationTitle.textContent = title;
notificationMessage.textContent = message;
// Show appropriate icon
if (type === 'success') {
successIcon.classList.remove('hidden');
errorIcon.classList.add('hidden');
} else {
successIcon.classList.add('hidden');
errorIcon.classList.remove('hidden');
}
// Show notification
notification.classList.remove('hidden');
// Add close button event
const closeBtn = card.querySelector('.close-notification');
closeBtn.addEventListener('click', () => {
notification.classList.add('hide');
setTimeout(() => {
notification.classList.add('hidden');
notification.classList.remove('hide');
}, 300);
});
}
}); |