Sha256: 90835eae30a005d949c0f3e3a065fe01f9870f92d5bbd552412de4ddffb65d8d

Contents?: true

Size: 678 Bytes

Versions: 10

Compression:

Stored size: 678 Bytes

Contents

// Searchbar functionality

function searchPosts() {
  // Find the cards
  let cards = document.querySelectorAll('.card')
  // Locate search input
  let search_query = document.getElementById('searchbar').value;
  // Loop through the cards
  for (var i = 0; i < cards.length; i++) {
    // If text is in the card:
    if (cards[i].innerHTML.toLowerCase()
    // AND if the text matches the search query:
      .includes(search_query.toLowerCase())) {
        // THEN remove the '.is-hidden' class
        cards[i].classList.remove('is-hidden');
      } else {
        // Otherwise, add the class:
        cards[i].classList.add('is-hidden');
      }
  }
};

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ols-theme-1.0.2 assets/js/posts.js
ols-theme-1.0.1 assets/js/posts.js
ols-theme-0.8.0 assets/js/posts.js
ols-theme-0.7.0 assets/js/posts.js
ols-theme-0.6.0 assets/js/posts.js
ols-theme-0.5.0 assets/js/posts.js
ols-theme-0.4.0 assets/js/posts.js
ols-theme-0.3.0 assets/js/posts.js
ols-theme-0.2.0 assets/js/posts.js
ols-theme-0.1.0 assets/js/posts.js