π― A comprehensive project demonstrating modern vanilla JavaScript DOM manipulation techniques
This assignment showcases advanced DOM manipulation skills through two interactive web applications built with vanilla JavaScript, HTML, and CSS. The project emphasizes modern web development practices including event delegation, debouncing, local storage persistence, and real-time user interactions.
Open the HTML files directly in your browser to see the applications in action:
- Contact Form: Open
contact-form/index.html
- Todo App: Open
todo-app/index.html
advanced-dom-javascript-assignment/
βββ contact-form/
β βββ index.html # Contact form HTML structure
β βββ style.css # Modern CSS styling with animations
β βββ script.js # Contact form JavaScript logic
βββ todo-app/
β βββ index.html # Todo application HTML structure
β βββ style.css # Responsive CSS with modern design
β βββ script.js # Todo app JavaScript functionality
βββ README.md # Project documentation
- Real-time Validation: Instant feedback as users type
- Debounced Input: Validates after 300ms delay to improve performance
- Message History: Persistent storage of submitted messages
- Event Delegation: Efficient event handling for dynamic delete buttons
- Local Storage: Messages survive browser refresh
- Responsive Design: Mobile-friendly interface
- CRUD Operations: Create, Read, Update, Delete todos
- Debounced Search: Live search with 400ms delay
- Smart Filtering: Filter by All, Active, or Completed todos
- Local Storage: Persistent todo storage
- Event Delegation: Single event listener handles all todo interactions
- Real-time Stats: Live counter of total and completed todos
- HTML5: Semantic markup with proper form elements
- CSS3: Modern styling with Flexbox, animations, and responsive design
- Vanilla JavaScript: ES6+ features with class-based architecture
// Single event listener handles multiple dynamic elements
this.messageHistory.addEventListener('click', (e) => {
if (e.target.classList.contains('delete-btn')) {
const messageId = e.target.dataset.messageId;
this.deleteMessage(messageId);
}
});
debouncedValidate(fieldName, delay) {
if (this.debounceTimers[fieldName]) {
clearTimeout(this.debounceTimers[fieldName]);
}
this.debounceTimers[fieldName] = setTimeout(() => {
this.validateField(fieldName);
this.updateSubmitButton();
}, delay);
}
saveMessage(message) {
try {
let messages = this.getMessagesFromStorage();
messages.unshift(message);
localStorage.setItem('contactMessages', JSON.stringify(messages));
} catch (error) {
console.error('Error saving message to localStorage:', error);
alert('Failed to save message. Please try again.');
}
}
validateField(fieldName) {
const field = document.getElementById(fieldName);
const errorElement = document.getElementById(`${fieldName}Error`);
let isValid = false;
let errorMessage = '';
// Field-specific validation logic
// Updates UI immediately with visual feedback
}
{
id: 1642123456789, // Unique timestamp ID
name: "John Doe", // User's name (min 2 chars)
email: "john@email.com", // Valid email format
message: "Hello, this is a test...", // Message text (min 10 chars)
timestamp: "2024-01-15T10:30:00.000Z" // ISO timestamp
}
{
id: 1642123456789, // Unique timestamp ID
text: "Learn JavaScript DOM", // Todo text (max 200 chars)
completed: false, // Completion status
createdAt: "2024-01-15T10:30:00.000Z" // ISO timestamp
}
- Modern Gradient Backgrounds: Eye-catching color schemes
- Smooth Animations: CSS transitions and keyframe animations
- Interactive Feedback: Hover effects and state changes
- Responsive Layout: Mobile-first design approach
- Real-time Feedback: Instant validation and error messages
- Loading States: Visual feedback during operations
- Empty States: Helpful messages when no data exists
- Accessibility: Proper labels and keyboard navigation
- Debounced Inputs: Reduces unnecessary API calls and validations
- Event Delegation: Minimizes event listeners for better performance
- Efficient DOM Updates: Strategic use of innerHTML vs createElement
- Lazy State Updates: Only re-render when necessary
- Clone or download this repository
- Open the project folder in your preferred code editor
- Launch the applications:
- Contact Form: Open
contact-form/index.html
in your browser - Todo App: Open
todo-app/index.html
in your browser
- Contact Form: Open
- β Pure vanilla JavaScript - no frameworks or build tools
- β Self-contained applications with inline dependencies
- β Works in any modern browser (Chrome, Firefox, Safari, Edge)
- Modern Browsers: Full support for Chrome 60+, Firefox 55+, Safari 11+, Edge 79+
- JavaScript Features: ES6+ classes, arrow functions, template literals
- CSS Features: Flexbox, CSS Grid, CSS Custom Properties
Both applications are fully responsive and optimized for:
- Desktop: Full-featured layout with optimal spacing
- Tablet: Adapted layout with touch-friendly interactions
- Mobile: Stacked design with simplified navigation
- Large screens: 1200px and above
- Medium screens: 768px to 1199px
- Small screens: 480px to 767px
- Extra small: Below 480px
-
Validation Testing:
- Enter invalid email formats
- Try names shorter than 2 characters
- Submit messages shorter than 10 characters
- Test real-time validation timing
-
Functionality Testing:
- Submit valid forms and check message history
- Refresh page and verify persistence
- Delete messages and confirm removal
- Test form reset after submission
-
CRUD Operations:
- Add new todos with various lengths
- Mark todos as complete/incomplete
- Delete todos and verify removal
- Test empty input handling
-
Search & Filter Testing:
- Search for partial text matches
- Test filter combinations (All/Active/Completed)
- Verify search debouncing behavior
- Test edge cases (no results, empty todos)
- localStorage Failures: Graceful degradation when storage is unavailable
- Invalid Data: Validation and sanitization of user inputs
- Browser Compatibility: Fallbacks for older browser features
- User Feedback: Clear error messages and recovery suggestions
- XSS Prevention: HTML escaping for user-generated content
- Data Validation: Client-side validation with server-side mindset
- Type Checking: Runtime validation of data structures
- Debounced Search: 400ms delay prevents excessive filtering
- Debounced Validation: 300ms delay improves user experience
- Efficient Re-rendering: Minimal DOM manipulation
- Event Optimization: Single event listeners with delegation
- Smart Date Formatting: Relative timestamps (2h ago, Yesterday)
- Visual State Management: Loading states and transitions
- Keyboard Accessibility: Enter key support for form submission
- Touch-Friendly: Optimized for mobile interactions
- Persistent Storage: Automatic save/load with localStorage
- Data Integrity: Validation and cleanup of stored data
- Backup Handling: Error recovery for corrupted data
This project demonstrates proficiency in:
- β DOM Manipulation: Dynamic element creation and modification
- β Event Handling: Modern event patterns and delegation
- β Async Programming: Timers and debouncing techniques
- β Data Structures: Object manipulation and array methods
- β Error Handling: Try-catch blocks and graceful degradation
- β Responsive Design: Mobile-first CSS approaches
- β User Experience: Interactive feedback and state management
- β Performance: Optimization techniques and best practices
- β Accessibility: Semantic HTML and keyboard navigation
- β Code Organization: Class-based architecture and separation of concerns
- β Code Quality: Clean, maintainable, and documented code
- β Testing Mindset: Edge case handling and user scenario coverage
- β Problem Solving: Creative solutions to common web challenges
- β Best Practices: Industry-standard patterns and conventions
Feel free to fork this project and submit pull requests for improvements:
- Bug Fixes: Report and fix any issues you encounter
- Feature Enhancements: Add new functionality or improve existing features
- Code Improvements: Optimize performance or code organization
- Documentation: Enhance comments and documentation
This project is open source and available under the MIT License.
Created as part of an advanced DOM & JavaScript assignment to demonstrate modern vanilla JavaScript development techniques.
Happy Coding! π
This project showcases the power of vanilla JavaScript and modern web development practices without relying on external frameworks or libraries.