rj1
about | log | files | refs

irc-art.js (1197B) - raw


let irc_art_search = function (event, arts) {
  let filter = irc_art_input.value.toUpperCase();
  let irc_art_gallery = document.getElementById("irc-art-gallery");

  if (irc_art_input.value.length == 0) {
    irc_art_gallery.innerHTML = irc_arts;
    irc_art_gallery.style.display = "";
    document.getElementById("pagination").style.display = "";
    return;
  } else if (irc_art_input.value.length > 2) {
    irc_art_gallery.innerHTML = "";
    document.getElementById("pagination").style.display = "none";

    for (i = 0; i < irc_art_list.length; i++) {
      let item = irc_art_list[i];
      let text = item.toUpperCase();
      if (text.indexOf(filter) > -1) {
        irc_art_gallery.innerHTML +=
          '<div class="irc-art"><a href="/irc-art/' +
          item.toLowerCase().replace(/ /g, "-") +
          '"><img src="/irc-art/png/thumb/' +
          item +
          '.png" loading="lazy"/><span class="caption">' +
          item +
          "</span></a></div>";
      }
    }
  }
};

let irc_art_input = document.getElementById("irc-art-search");
if (irc_art_input) {
  irc_art_input.addEventListener(
    "keyup",
    irc_art_search.bind(event, irc_art_list),
    false
  );
}