<!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><%= user.email %> Dashboard | MyNotes</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
  <link rel="stylesheet" href="../css/style-dashboard.css">
</head>
<body>
  <nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
    <div class="container-fluid">
      <a class="navbar-brand" href="#"><p>MyNotes</p></a>
      <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
            <input class="form-control me-2" id="search" type="search" placeholder="Search" aria-label="Search">
            <button id="sbtn" class="btn btn-outline-success" type="submit" onclick="checkInput()">Search</button>
        <span class="d-flex"></span>
        <div class="navbar-nav ms-auto">
          <form class="d-flex m-auto ms-2">
            <button class="pro btn btn-outline-warning" title="PRO Subscribtion" type="submit">PRO</button>
          </form>
            <a href="#" class="nav-link"><img title="How to use" src="https://img.icons8.com/ios-glyphs/30/4a90e2/help.png"/></a>
            <a href="#" class="nav-link"><img data-bs-toggle="tooltip" id="tombolku" data-bs-placement="bottom" title="My Profile" src="https://img.icons8.com/ios-glyphs/30/000000/test-account.png" alt="profile"/></a>
            <div id="myModal" class="penghalang">
              <div class="modal-content">
                  <span id="tutup">&times;</span>
                  <p>Your id is: <%= user.id %></p>
                  <p>Your email is: <%= user.email %></p>
                  <a href="/logout">Logout</a>
              </div>
            </div>
            <script>
              // profile
              var modal = document.getElementById('myModal');
              var btn = document.getElementById("tombolku");
              var span = document.getElementById("tutup");
              
              btn.onclick = function() {
                  modal.style.display = "block";
              }
              
              span.onclick = function() {
                  modal.style.display = "none";
              }
              
              window.onclick = function(e) {
                  if (e.target == modal) {
                      modal.style.display = "none";
                  }
              }
              </script>

    </div>
        <script>
          var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
  return new bootstrap.Tooltip(tooltipTriggerEl)
})
        </script>
        </div>
      </div>
    </div>
  </nav>
  <div class="container">
    <div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
      <div class="carousel-indicators">
        <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
        <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
        <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
      </div>
      <div class="carousel-inner">
        <div class="carousel-item active">
          <img src="../img/dashboard/notebook-min.jpg" class="d-block w-100" alt="...">
        </div>
        <div class="carousel-item">
          <img src="../img/dashboard/jess-bailey-_969XXSgWc0-unsplash-crop.jpg" class="d-block w-100" alt="...">
        </div>
        <div class="carousel-item">
          <img src="../img/dashboard/kobu-agency-pvMVecxVoW0-unsplash.jpg" class="d-block w-100" alt="...">
        </div>
      </div>
      <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
        <span class="visually-hidden">Previous</span>
      </button>
      <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="visually-hidden">Next</span>
      </button>
    </div>
    <!-- end of carousel -->
    <div class="toast align-items-center" role="alert" aria-live="assertive" aria-atomic="true">
      <div class="d-flex">
        <div class="toast-body">
          <%= message %>
       </div>
        <button type="button" class="btn-close me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
      </div>
    </div>
    <!-- why not shows????? -->
    <!-- body note -->
    <br/>
    <div class="kolom rounded border my-2 d-flex justify-content-center">
      <div class="d-flex">
        <form action="/save" method="POST" class="d-flex flex-column">
        <input id="notift_fill" onkeyup="cek_notift()" onkeydown="cek_notift()" type="text" class="simpan" name="title" placeholder="Title..." required>
        <textarea onkeyup="cek()" onkeydown="cek()" class="my-1" name="teks" id="area" cols="10" rows="3" placeholder="Text here..." required></textarea>
        <div class="notiv">
          <span id="notift">50 Character left for title!</span>
          <span id="notif">3000 Character left to fill!</span>
        </div>
          <button type="reset" onclick="kosongi()" title="Delete & Clear Workspace">Clear</button>
        <button type="submit" class="btn btn-success" title="Save"><img src="https://img.icons8.com/material-sharp/24/ffffff/save.png" alt="save"/></button>
      </form>
      </div>
    </div>
    <!-- to do list -->
    <% notes.forEach((note) => { %>
    <div class="d-flex kolom rounded border mx-auto my-2 row">
      <div class="col col-lg-10" id="conTent">
        <h5 id="judul"><%= note.title %></h5>
        <p id="isi"><%= note.note %></p>
      </div>
      <div class="col col-lg-1 ms-auto tools d-grid gap-2 d-md-block">
        <!-- <div class="tool view_mode"><a class="btn btn-sm btn-success" href="/view/ #ejs tag note.id"></div> -->
        <div class="tool edit_mode"><a class="btn btn-sm btn-warning text" id="text" href="/edit/<%= note.id %>">Edit</a></div>
        <!-- delete -->
        <div class="tool delete_note">
          <input type="button" class="btn btn-sm btn-danger" data-bs-toggle="modal" data-bs-target="#exampleModal<%= note.id %>" value="Delete">
          <!-- masalahnya disini adalah kenapa ketika modal di klik delete malah menghapus catatan teratas dan bukan di id yang sesuai -->
<!-- Modal -->
<div class="modal fade" id="exampleModal<%= note.id %>" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Delete Confirmation For <%= note.title %> </h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        Are you sure to delete this notes?<br> you cannot undo after confirmed.
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <form action="/delete/<%= note.id %>/?method=DELETE" method="post"> 
          <input type="submit" class="btn btn-danger" id="text" value="Delete">
          <!-- jika klik ok maka dihapus, jika cancel maka tidak di hapus  -->
        </form>
      </div>
    </div>
  </div>
</div>
        </div>

      </div>
    </div>
    <% }); %> 
    <!-- body note -->
    
    
    
  </div>
<!-- footer -->
<footer>
  <div class="container-fluid pb-0 mb-0 justify-content-center text-light ">
        <div class="row my-5 justify-content-center py-5">
            <div class="col-11">
                <div class="row ">
                    <div class="col-xl-8 col-md-4 col-sm-4 col-12 my-auto mx-auto a">
                        <h3 class="text-muted mb-md-0 mb-5 bold-text brand">MyNotes.</h3>
                    </div>
                    
                    <div class="ikon">
                      <!-- icon -->
                      <a href="#facebook">
                      <svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="bi bi-facebook" viewBox="0 0 16 16">
                        <path d="M16 8.049c0-4.446-3.582-8.05-8-8.05C3.58 0-.002 3.603-.002 8.05c0 4.017 2.926 7.347 6.75 7.951v-5.625h-2.03V8.05H6.75V6.275c0-2.017 1.195-3.131 3.022-3.131.876 0 1.791.157 1.791.157v1.98h-1.009c-.993 0-1.303.621-1.303 1.258v1.51h2.218l-.354 2.326H9.25V16c3.824-.604 6.75-3.934 6.75-7.951z"/>
                      </svg>
                    </a>
                    
                    <a href="#instagram">
                      <svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="bi bi-instagram" viewBox="0 0 16 16">
                        <path d="M8 0C5.829 0 5.556.01 4.703.048 3.85.088 3.269.222 2.76.42a3.917 3.917 0 0 0-1.417.923A3.927 3.927 0 0 0 .42 2.76C.222 3.268.087 3.85.048 4.7.01 5.555 0 5.827 0 8.001c0 2.172.01 2.444.048 3.297.04.852.174 1.433.372 1.942.205.526.478.972.923 1.417.444.445.89.719 1.416.923.51.198 1.09.333 1.942.372C5.555 15.99 5.827 16 8 16s2.444-.01 3.298-.048c.851-.04 1.434-.174 1.943-.372a3.916 3.916 0 0 0 1.416-.923c.445-.445.718-.891.923-1.417.197-.509.332-1.09.372-1.942C15.99 10.445 16 10.173 16 8s-.01-2.445-.048-3.299c-.04-.851-.175-1.433-.372-1.941a3.926 3.926 0 0 0-.923-1.417A3.911 3.911 0 0 0 13.24.42c-.51-.198-1.092-.333-1.943-.372C10.443.01 10.172 0 7.998 0h.003zm-.717 1.442h.718c2.136 0 2.389.007 3.232.046.78.035 1.204.166 1.486.275.373.145.64.319.92.599.28.28.453.546.598.92.11.281.24.705.275 1.485.039.843.047 1.096.047 3.231s-.008 2.389-.047 3.232c-.035.78-.166 1.203-.275 1.485a2.47 2.47 0 0 1-.599.919c-.28.28-.546.453-.92.598-.28.11-.704.24-1.485.276-.843.038-1.096.047-3.232.047s-2.39-.009-3.233-.047c-.78-.036-1.203-.166-1.485-.276a2.478 2.478 0 0 1-.92-.598 2.48 2.48 0 0 1-.6-.92c-.109-.281-.24-.705-.275-1.485-.038-.843-.046-1.096-.046-3.233 0-2.136.008-2.388.046-3.231.036-.78.166-1.204.276-1.486.145-.373.319-.64.599-.92.28-.28.546-.453.92-.598.282-.11.705-.24 1.485-.276.738-.034 1.024-.044 2.515-.045v.002zm4.988 1.328a.96.96 0 1 0 0 1.92.96.96 0 0 0 0-1.92zm-4.27 1.122a4.109 4.109 0 1 0 0 8.217 4.109 4.109 0 0 0 0-8.217zm0 1.441a2.667 2.667 0 1 1 0 5.334 2.667 2.667 0 0 1 0-5.334z"/>
                      </svg>
                    </a>
  
                    <a href="#telegram">
                      <svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="bi bi-telegram" viewBox="0 0 16 16">
                        <path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8.287 5.906c-.778.324-2.334.994-4.666 2.01-.378.15-.577.298-.595.442-.03.243.275.339.69.47l.175.055c.408.133.958.288 1.243.294.26.006.549-.1.868-.32 2.179-1.471 3.304-2.214 3.374-2.23.05-.012.12-.026.166.016.047.041.042.12.037.141-.03.129-1.227 1.241-1.846 1.817-.193.18-.33.307-.358.336a8.154 8.154 0 0 1-.188.186c-.38.366-.664.64.015 1.088.327.216.589.393.85.571.284.194.568.387.936.629.093.06.183.125.27.187.331.236.63.448.997.414.214-.02.435-.22.547-.82.265-1.417.786-4.486.906-5.751a1.426 1.426 0 0 0-.013-.315.337.337 0 0 0-.114-.217.526.526 0 0 0-.31-.093c-.3.005-.763.166-2.984 1.09z"/>
                      </svg>
                    </a>
  
                    <a href="#twitter">
                      <svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="bi bi-twitter" viewBox="0 0 16 16">
                        <path d="M5.026 15c6.038 0 9.341-5.003 9.341-9.334 0-.14 0-.282-.006-.422A6.685 6.685 0 0 0 16 3.542a6.658 6.658 0 0 1-1.889.518 3.301 3.301 0 0 0 1.447-1.817 6.533 6.533 0 0 1-2.087.793A3.286 3.286 0 0 0 7.875 6.03a9.325 9.325 0 0 1-6.767-3.429 3.289 3.289 0 0 0 1.018 4.382A3.323 3.323 0 0 1 .64 6.575v.045a3.288 3.288 0 0 0 2.632 3.218 3.203 3.203 0 0 1-.865.115 3.23 3.23 0 0 1-.614-.057 3.283 3.283 0 0 0 3.067 2.277A6.588 6.588 0 0 1 .78 13.58a6.32 6.32 0 0 1-.78-.045A9.344 9.344 0 0 0 5.026 15z"/>
                      </svg>
                    </a>
  
                      </div>
                    <div class="col-xl-2 col-md-4 col-sm-4 col-12">
                        <h6 class="mb-3 mb-lg-4 bold-text "><b>MENU</b></h6>
                        <ul class="list-unstyled">
                            <li><a href="#">Home</a></li>
                            <li><a href="#">FAQ</a></li>
                            <li><a href="https://www.google.com?url=https://ardevid.my.id">Blog</a></li>
                            <li><a href="#">Product</a></li>
                            <li><a href="#">Donate</a></li>
                        </ul>
                    </div>
                    <div class="col-xl-2 col-md-4 col-sm-4 col-12">
                        <h6 class="mb-3 mb-lg-4 text-muted bold-text mt-sm-0 mt-5"><b>ADDRESS</b></h6>
                        <p class="mb-1">Special Region of Yogyakarta</p>
                        <p>Indonesia</p>
                    </div>
                </div>
                <div class="row ">
                    <div class="col-xl-8 col-md-4 col-sm-4 col-auto my-md-0 mt-5 order-sm-1 order-3 align-self-end">
                        <p class="social text-muted mb-0 pb-0 bold-text"> <span class="mx-2"><i class="fa fa-facebook" aria-hidden="true"></i></span> <span class="mx-2"><i class="fa fa-linkedin-square" aria-hidden="true"></i></span> <span class="mx-2"><i class="fa fa-twitter" aria-hidden="true"></i></span> <span class="mx-2"><i class="fa fa-instagram" aria-hidden="true"></i></span> </p><small class="rights"><span>&#174;</span> MyNotes All Rights Reserved.</small>
                    </div>
                    <div class="col-xl-2 col-md-4 col-sm-4 col-auto order-1 align-self-end ">
                      <p class="text-muted regards mt-55">if you found any bug's or error please contact me feel free!</br>Regards,</p><h6 class="mt-0 mt-2 text-muted bold-text"><b>LUCKY ARDHIKA</b></h6><small> <span><i class="fa fa-envelope" aria-hidden="true"></i></span> ardhikalucky@ardevid.my.id</small>
                    </div>
                    <div class="col-xl-2 col-md-4 col-sm-4 col-auto order-2 align-self-end mt-3 ">
                        <h6 class="text-muted bold-text"><b>SPONSORED BY</b></h6><small><span><i class="fa fa-envelope" aria-hidden="true"></i></span>Ice Creamy</small>
                    </div>
                </div>
            </div>
        </div>
  </div>
  </footer>
  
  <!-- Copyright -->
  <div class="text-center p-4" style="background-color: rgba(0, 0, 0, 0.05);">
    Â© 2021 Copyright:
    <a class="text-reset fw-bold" href="https://ardevid.my.id/">ArdevID.my.id</a>
  </div>
  <!-- Copyright -->
</footer>
<!-- Footer -->
<!-- search box  -->
<script>
  function checkInput() {
      var query = document.getElementById('search').value;
      window.find(query);
      return true;
  }
</script>
<!-- search enter event btn code=13 -->
<script>
  var input = document.getElementById("search");
  input.addEventListener("keyup", function(event) {
    if (event.keyCode === 13) {
     event.preventDefault();
     document.getElementById("sbtn").click();
    }
  });
  </script>

<!-- counter character -->
<script src="../js/character_counter.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
</body>
</html>