diff --git a/assets/js/weekly.js b/assets/js/weekly.js index 010a4f0..2fa2810 100644 --- a/assets/js/weekly.js +++ b/assets/js/weekly.js @@ -89,7 +89,7 @@ document.addEventListener("DOMContentLoaded", function() { savedMeals[`${day}-${mealType}`] = mealInput.value; localStorage.setItem("weeklyMeals", JSON.stringify(savedMeals)); }); - + // Event listener to handle the drop event mealInput.addEventListener("drop", function(event) { event.preventDefault(); @@ -103,7 +103,7 @@ document.addEventListener("DOMContentLoaded", function() { // Event listener to prevent the default behavior and allow drop events on the input field mealInput.addEventListener("dragover", function(event) { - event.preventDefault(); + event.preventDefault(); }); return mealInput; @@ -121,27 +121,6 @@ document.addEventListener("DOMContentLoaded", function() { // Agregar cualquier código de limpieza necesario aquí } - // Función para manejar el evento de soltar - function handleDrop(event) { - event.preventDefault(); - const draggedItemText = event.dataTransfer.getData("text/plain"); - - // Identificar el campo de entrada de destino - const targetInput = document.activeElement; - - // Verificar si el elemento activo es un campo de entrada - if (targetInput.tagName === 'INPUT' && targetInput.classList.contains('meal-input')) { - // Establecer el valor del campo de entrada al texto arrastrado - targetInput.value = draggedItemText; - - // Guardar la comida ingresada en el almacenamiento local - const day = targetInput.getAttribute('data-day'); - const mealType = targetInput.getAttribute('data-meal-type'); - savedMeals[`${day}-${mealType}`] = targetInput.value; - localStorage.setItem("weeklyMeals", JSON.stringify(savedMeals)); - } - } - // Botón para borrar todos los datos const clearDataBtn = document.getElementById("clearDataBtn"); clearDataBtn.addEventListener("click", function() {