Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ // Mobile menu toggle
+ const menuToggle = document.querySelector('.menu-toggle');
+ const navLinks = document.querySelector('.nav-links');
+
+ menuToggle.addEventListener('click', () => {
+ navLinks.classList.toggle('active');
+ });
+
+ // Drag and drop functionality
+ const exercises = document.querySelectorAll('.exercise');
+ const dropZones = document.querySelectorAll('.drop-zone');
+
+ exercises.forEach(exercise => {
+ exercise.addEventListener('dragstart', dragStart);
+ exercise.addEventListener('dragend', dragEnd);
+ });
+
+ dropZones.forEach(zone => {
+ zone.addEventListener('dragover', dragOver);
+ zone.addEventListener('dragleave', dragLeave);
+ zone.addEventListener('drop', drop);
+ });
+
+ function dragStart(e) {
+ e.target.classList.add('dragging');
+ e.dataTransfer.setData('text/plain', e.target.dataset.exercise);
+ }
+
+ function dragEnd(e) {
+ e.target.classList.remove('dragging');
+ }
+
+ function dragOver(e) {
+ e.preventDefault();
+ e.currentTarget.classList.add('dragover');
+ }
+
+ function dragLeave(e) {
+ e.currentTarget.classList.remove('dragover');
+ }
+
+ function drop(e) {
+ e.preventDefault();
+ const exerciseName = e.dataTransfer.getData('text/plain');
+ const exerciseElement = document.createElement('div');
+ exerciseElement.className = 'exercise';
+ exerciseElement.textContent = exerciseName;
+
+ // Add remove functionality
+ exerciseElement.addEventListener('dblclick', function() {
+ this.remove();
+ });
+
+ e.currentTarget.appendChild(exerciseElement);
+ e.currentTarget.classList.remove('dragover');
+ }
+
+ // Save functionality
+ const savePlan = () => {
+ const plan = {};
+ dropZones.forEach(zone => {
+ const day = zone.parentElement.dataset.day;
+ const exercises = Array.from(zone.children).map(ex => ex.textContent);
+ plan[day] = exercises;
+ });
+ localStorage.setItem('workoutPlan', JSON.stringify(plan));
+ alert('Workout plan saved!');
+ };
+
+ // Load saved plan
+ const loadPlan = () => {
+ const savedPlan = localStorage.getItem('workoutPlan');
+ if (savedPlan) {
+ const plan = JSON.parse(savedPlan);
+ dropZones.forEach(zone => {
+ const day = zone.parentElement.dataset.day;
+ if (plan[day]) {
+ plan[day].forEach(exercise => {
+ const exerciseElement = document.createElement('div');
+ exerciseElement.className = 'exercise';
+ exerciseElement.textContent = exercise;
+ exerciseElement.addEventListener('dblclick', function() {
+ this.remove();
+ });
+ zone.appendChild(exerciseElement);
+ });
+ }
+ });
+ }
+ };
+
+ // Load saved plan on page load
+ loadPlan();
+
+ // Add save button functionality
+ document.querySelector('a[href="#save"]').addEventListener('click', (e) => {
+ e.preventDefault();
+ savePlan();
+ });
+ });