<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Chapters</title>
    <!-- Latest compiled and minified CSS -->
    <link
      rel="stylesheet"
      href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
    />

    <!-- jQuery library -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

    <!-- Popper JS -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

    <!-- Latest compiled JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
    <script src="https://cdn.lordicon.com/libs/mssddfmo/lord-icon-2.1.0.js"></script>
    <link rel="stylesheet" href="/css/chapter.css" />
  </head>

  <body>
    <div>
      <div class="demo">
        <nav class="navbar navbar-expand-custom navbar-mainbg">
          <img src="/assets/o2.png" style="width: 30px; height: 30px; margin-left: 10px;">
          <a class="navbar-brand navbar-logo" href="#">ChemStudy</a>
          <button
            class="navbar-toggler"
            type="button"
            aria-controls="navbarSupportedContent"
            aria-expanded="false"
            aria-label="Toggle navigation"
          >
            <i class="fas fa-bars text-white"></i>
          </button>
          <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav ml-auto">
              <div class="hori-selector">
                <div class="left"></div>
                <div class="right"></div>
              </div>
              <li class="nav-item">
                <a class="nav-link" href="/dash"
                  ><i class="fas fa-tachometer-alt"></i>Dashboard</a
                >
              </li>
              <li class="nav-item active">
                <a class="nav-link" href="/chapter"
                  ><i class="far fa-address-book"></i>Chapters</a
                >
              </li>
              <li class="nav-item">
                <a class="nav-link" href="/quiz"
                  ><i class="far fa-address-book"></i>Quiz</a
                >
              </li>
              <li class="nav-item">
                <a class="nav-link" href="/contact"
                  ><i class="far fa-calendar-alt"></i>Contact Us</a
                >
              </li>
            </ul>
          </div>
        </nav>
      </div>

      <div class="container">
        <ul>
          <li>
            <div class="card card-green col-md-12">
              <p class="card-question">Aldehydes</p>
              <div class="card-separator"></div>
              <p style="text-align: justify">Aldehyde Information</p>
              <a href="/molecules">View Aldehyde Molecules</a>
              <a
                href="/reactions"
                >View Aldehyde Reactions</a
              >
              <div class="card-separator"></div>
            </div>
          </li>

          <li>
            <div class="card card-blue col-md-12 card-top">
              <p class="card-question">Ketones</p>
              <div class="card-separator"></div>
              <p style="text-align: justify">Ketone Information</p>
              <a
                href="/molecules"
                >View Ketone Molecules</a
              >
              <a
                href="/molecules"
                >View Ketone Reactions</a
              >
              <div class="card-separator"></div>
            </div>
          </li>
        </ul>
      </div>
    </div>
  </body>
  <script>
    function test() {
      var tabsNewAnim = $("#navbarSupportedContent");
      var selectorNewAnim = $("#navbarSupportedContent").find("li").length;
      var activeItemNewAnim = tabsNewAnim.find(".active");
      var activeWidthNewAnimHeight = activeItemNewAnim.innerHeight();
      var activeWidthNewAnimWidth = activeItemNewAnim.innerWidth();
      var itemPosNewAnimTop = activeItemNewAnim.position();
      var itemPosNewAnimLeft = activeItemNewAnim.position();
      $(".hori-selector").css({
        top: itemPosNewAnimTop.top + "px",
        left: itemPosNewAnimLeft.left + "px",
        height: activeWidthNewAnimHeight + "px",
        width: activeWidthNewAnimWidth + "px",
      });
      $("#navbarSupportedContent").on("click", "li", function (e) {
        $("#navbarSupportedContent ul li").removeClass("active");
        $(this).addClass("active");
        var activeWidthNewAnimHeight = $(this).innerHeight();
        var activeWidthNewAnimWidth = $(this).innerWidth();
        var itemPosNewAnimTop = $(this).position();
        var itemPosNewAnimLeft = $(this).position();
        $(".hori-selector").css({
          top: itemPosNewAnimTop.top + "px",
          left: itemPosNewAnimLeft.left + "px",
          height: activeWidthNewAnimHeight + "px",
          width: activeWidthNewAnimWidth + "px",
        });
      });
    }
    $(document).ready(function () {
      setTimeout(function () {
        test();
      });
    });
    $(window).on("resize", function () {
      setTimeout(function () {
        test();
      }, 500);
    });
    $(".navbar-toggler").click(function () {
      $(".navbar-collapse").slideToggle(300);
      setTimeout(function () {
        test();
      });
    });

    // --------------add active class-on another-page move----------
    jQuery(document).ready(function ($) {
      // Get current path and find target link
      var path = window.location.pathname.split("/").pop();

      // Account for home page with empty path
      if (path == "") {
        path = "index.ejs";
      }

      var target = $('#navbarSupportedContent ul li a[href="' + path + '"]');
      // Add active class to target link
      target.parent().addClass("active");
    });
  </script>
</html>
