let listContainer = $("#dataList"); let displayedItems = []; let fetchedData = {}; let currentMode = "buy"; let sellClass = 'btn-danger'; let buyClass = 'btn-success'; $(document).ready(async function () { await generateList(); $('#buyButton').addClass(buyClass); $('#saveButton').addClass(buyClass); $('#buyButton').on('click', function () { if (!$(this).hasClass(buyClass)) { $(this).addClass(buyClass); $('#sellButton').removeClass(sellClass); $('#saveButton').removeClass(sellClass).addClass(buyClass); currentMode = "buy"; } }); $('#sellButton').on('click', function () { if (!$(this).hasClass(sellClass)) { $(this).addClass(sellClass); $('#buyButton').removeClass(buyClass); $('#saveButton').removeClass(buyClass).addClass(sellClass); currentMode = "sell"; } }); $('#saveButton').on('click', function () { let values = getValues(); let message = 'Voulez vous vraimer ajouter ces articles au stock ?