Skip to content

Commit

Permalink
Filter working
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidS12321 committed Feb 3, 2024
1 parent b4e0d0b commit 59f4fc4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ function applyFilters() {
// Iterate over place boxes to show/hide based on filters
placeBoxes.forEach(function (placeBox) {
const placeMeal = placeBox.getAttribute('data-meal');
const placeCuisine = placeBox.getAttribute('data-cuisine');
const placeCuisine = placeBox.getAttribute('data-cuisine').split(' '); // Split into an array

const isMealMatch = selectedMeals.length === 0 || selectedMeals.some(meal => placeMeal.includes(meal));
const isCuisineMatch = selectedCuisines.length === 0 || selectedCuisines.includes(placeCuisine);
const isCuisineMatch = selectedCuisines.length === 0 || selectedCuisines.every(cuisine => placeCuisine.includes(cuisine));

// Show/hide place box based on filters
placeBox.style.display = isMealMatch && isCuisineMatch ? 'block' : 'none';
Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ <h3>Panda Express</h3>
<p>Healthy and fresh options for those looking for nutritious meals. Salads, smoothies, and more!</p>
</div>

<div class="place-box" data-meal="lunch_dinner" data-cuisine="asian">
<div class="place-box" data-meal="lunch_dinner" data-cuisine="mexican">
<img src="https://i.pinimg.com/736x/63/b9/2a/63b92ae5f63dfcca5b49a343e9f65e87.jpg" alt="Restaurant 4" width = "300" length = "300">
<h3>QDoba</h3>
<p>Healthy and fresh options for those looking for nutritious meals. Salads, smoothies, and more!</p>
Expand Down Expand Up @@ -127,7 +127,7 @@ <h3>Saddles</h3>
<p>Saddles Café is dedicated to providing an exquisite selection of specialty coffee and tea beverages, complemented by an enticing array of freshly baked pastries, convenient grab-and-go items, and a distinctive menu featuring artisanal paninis.</p>
</div>

<div class="place-box" data-meal="breakfast lunch_dinner" data-cuisine="american asian mexican">
<div class="place-box" data-meal="breakfast lunch_dinner snacks" data-cuisine="american asian mexican">
<img src="https://www.foundation.cpp.edu/dining/assets/img/logo/centerpointe-logo-400w.jpg" alt="Restaurant 12" width = "300" length = "300">
<h3>Centerpointe</h3>
<p>Healthy and fresh options for those looking for nutritious meals. Salads, smoothies, and more!</p>
Expand Down

0 comments on commit 59f4fc4

Please sign in to comment.