function changeGiftElement(giftData, giftOwner){
    var description = giftData.description;
    var link = giftData.link;
    var title = giftData.title + " - for " + giftOwner;
    var where = giftData.where;
    var uid = giftData.uid;
    var date = giftData.creationDate;

    console.log("Updating " + uid);
    var editGift = document.getElementById("gift" + uid);
    editGift.innerHTML = title;
    editGift.className = "gift";
    editGift.onclick = function (){
      var spanGift = document.getElementsByClassName("close")[0];
      var descField = document.getElementById('giftDescription');
      var titleField = document.getElementById('giftTitle');
      var whereField = document.getElementById('giftWhere');
      var linkField = document.getElementById('giftLink');

      if (link != ""){
        linkField.innerHTML = "Click me to go to the webpage!";
        linkField.onclick = function() {
          var newGiftLink = "http://";
          if(link.includes("https://")){
            link = link.slice(8, link.length);
          } else if (link.includes("http://")){
            link = link.slice(7, link.length);
          }
          newGiftLink += link;
          window.open(newGiftLink, "_blank");
        };
      } else {
        linkField.innerHTML = "There was no link provided";
        linkField.onclick = function() {
        };
      }
      if(description != "") {
        descField.innerHTML = "Description: " + description;
      } else {
        descField.innerHTML = "There was no description provided";
      }
      titleField.innerHTML = title;
      if(where != "") {
        whereField.innerHTML = "This can be found at: " + where;
      } else {
        whereField.innerHTML = "There was no location provided";
      }
      if(date != undefined) {
        if (date != "") {
          giftCreationDate.innerHTML = "Created on: " + date;
        } else {
          giftCreationDate.innerHTML = "Creation date not available";
        }
      } else {
        giftCreationDate.innerHTML = "Creation date not available";
      }

      //show modal
      modal.style.display = "block";
      currentModalOpen = uid;
      console.log("Modal Open: " + currentModalOpen);

      //close on close
      spanGift.onclick = function() {
        currentModalOpen = "";
        console.log("Closed modal");
        modal.style.display = "none";
      };

      //close on click
      window.onclick = function(event) {
        if (event.target == modal) {
          currentModalOpen = "";
          console.log("Closed modal");
          modal.style.display = "none";
        }
      };
    };
  }
//with the proper gift's details.
with the proper gift's details.
with the proper gift ' s details .
function changeGiftElement(giftData, giftOwner){
    var description = giftData.description;
    var link = giftData.link;
    var title = giftData.title + " - for " + giftOwner;
    var where = giftData.where;
    var uid = giftData.uid;
    var date = giftData.creationDate;
    console.log("Updating " + uid);
    var editGift = document.getElementById("gift" + uid);
    editGift.innerHTML = title;
    editGift.className = "gift";
    editGift.onclick = function (){
      var spanGift = document.getElementsByClassName("close")[0];
      var descField = document.getElementById('giftDescription');
      var titleField = document.getElementById('giftTitle');
      var whereField = document.getElementById('giftWhere');
      var linkField = document.getElementById('giftLink');
      if (link != ""){
        linkField.innerHTML = "Click me to go to the webpage!";
        linkField.onclick = function() {
          var newGiftLink = "http://";
          if(link.includes("https://")){
            link = link.slice(8, link.length);
          } else if (link.includes("http://")){
            link = link.slice(7, link.length);
          }
          newGiftLink += link;
          window.open(newGiftLink, "_blank");
        };
      } else {
        linkField.innerHTML = "There was no link provided";
        linkField.onclick = function() {
        };
      }
      if(description != "") {
        descField.innerHTML = "Description: " + description;
      } else {
        descField.innerHTML = "There was no description provided";
      }
      titleField.innerHTML = title;
      if(where != "") {
        whereField.innerHTML = "This can be found at: " + where;
      } else {
        whereField.innerHTML = "There was no location provided";
      }
      if(date != undefined) {
        if (date != "") {
          giftCreationDate.innerHTML = "Created on: " + date;
        } else {
          giftCreationDate.innerHTML = "Creation date not available";
        }
      } else {
        giftCreationDate.innerHTML = "Creation date not available";
      }
      modal.style.display = "block";
      currentModalOpen = uid;
      console.log("Modal Open: " + currentModalOpen);
      spanGift.onclick = function() {
        currentModalOpen = "";
        console.log("Closed modal");
        modal.style.display = "none";
      };
      window.onclick = function(event) {
        if (event.target == modal) {
          currentModalOpen = "";
          console.log("Closed modal");
          modal.style.display = "none";
        }
      };
    };
  }
function changeGiftElement ( giftData , giftOwner ) { var description = giftData . description ; var link = giftData . link ; var title = giftData . title + " - for " + giftOwner ; var where = giftData . where ; var uid = giftData . uid ; var date = giftData . creationDate ; console . log ( "Updating " + uid ) ; var editGift = document . getElementById ( "gift" + uid ) ; editGift . innerHTML = title ; editGift . className = "gift" ; editGift . onclick = function ( ) { var spanGift = document . getElementsByClassName ( "close" ) [ 0 ] ; var descField = document . getElementById ( 'giftDescription' ) ; var titleField = document . getElementById ( 'giftTitle' ) ; var whereField = document . getElementById ( 'giftWhere' ) ; var linkField = document . getElementById ( 'giftLink' ) ; if ( link != "" ) { linkField . innerHTML = "Click me to go to the webpage!" ; linkField . onclick = function ( ) { var newGiftLink = "http://" ; if ( link . includes ( "https://" ) ) { link = link . slice ( 8 , link . length ) ; } else if ( link . includes ( "http://" ) ) { link = link . slice ( 7 , link . length ) ; } newGiftLink += link ; window . open ( newGiftLink , "_blank" ) ; } ; } else { linkField . innerHTML = "There was no link provided" ; linkField . onclick = function ( ) { } ; } if ( description != "" ) { descField . innerHTML = "Description: " + description ; } else { descField . innerHTML = "There was no description provided" ; } titleField . innerHTML = title ; if ( where != "" ) { whereField . innerHTML = "This can be found at: " + where ; } else { whereField . innerHTML = "There was no location provided" ; } if ( date != undefined ) { if ( date != "" ) { giftCreationDate . innerHTML = "Created on: " + date ; } else { giftCreationDate . innerHTML = "Creation date not available" ; } } else { giftCreationDate . innerHTML = "Creation date not available" ; } modal . style . display = "block" ; currentModalOpen = uid ; console . log ( "Modal Open: " + currentModalOpen ) ; spanGift . onclick = function ( ) { currentModalOpen = "" ; console . log ( "Closed modal" ) ; modal . style . display = "none" ; } ; window . onclick = function ( event ) { if ( event . target == modal ) { currentModalOpen = "" ; console . log ( "Closed modal" ) ; modal . style . display = "none" ; } } ; } ; }
with the proper gift's details.
with the proper gift ' s details .
//show modal //close on close //close on click