// image upload
const imgContentPopup = document.querySelector(".img-content-popup");
const title = document.querySelector(".img-photo-popup-title");
const crossIcon = document.querySelector(".cross-icon");
const readUrl = document.getElementById("readUrl");

imgContentPopup.addEventListener("click", function () {
  readUrl.click();
});

crossIcon.addEventListener("click", () => {
  uploadedImage.style.display = "none";
  title.classList.remove("remove");
  crossIcon.classList.remove("show");
});

readUrl.addEventListener("change", function () {
  if (this.files[0]) {
    var picture = new FileReader();
    picture.readAsDataURL(this.files[0]);
    picture.addEventListener("load", function (event) {
      // console.log(event.target.result);
      const uploadedImage = document.getElementById("uploadedImage");
      uploadedImage.setAttribute("src", event.target.result);
      uploadedImage.style.display = "block";
      title.classList.add("remove");
      crossIcon.classList.add("show");
    });
  }
});

