function changeGiftElement(description, link, received, title, key, where, buyer, uid, date) {
    var editGift = document.getElementById("gift" + uid);
    editGift.innerHTML = title;
    editGift.className = "gift";
    if(received == 1) {
      editGift.className += " checked";
      //console.log("Checked, changed");
    }
    editGift.onclick = function (){
      var spanGift = document.getElementsByClassName("close")[0];
      var buyBtn = document.getElementById('giftBuy');
      var dontBuyBtn = document.getElementById('giftDontBuy');
      var descField = document.getElementById('giftDescription');
      var boughtField = document.getElementById('giftBought');
      var titleField = document.getElementById('giftTitle');
      var whereField = document.getElementById('giftWhere');
      var linkField = document.getElementById('giftLink');

      noteTitleField = document.getElementById('notificationTitle');
      noteInfoField = document.getElementById('notificationInfo');

      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(received == 1){
        if(buyer == "" || buyer == null || buyer == undefined){
          boughtField.innerHTML = "This gift has been bought";
        } else {
          boughtField.innerHTML = "This gift was bought by " + buyer;
        }
      } else {
        boughtField.innerHTML = "This gift has not been bought yet";
      }
      if(date != undefined) {
        if (date != "") {
          giftCreationDate.innerHTML = "Created on: " + date;
        } else {
          giftCreationDate.innerHTML = "Creation date not available";
        }
      } else {
        giftCreationDate.innerHTML = "Creation date not available";
      }
      buyBtn.onclick = function(){
        if(received == 0) {
          firebase.database().ref("users/" + user.uid + "/giftList/" + key).update({
            received: 1,
            buyer: currentUser.userName
          });
        } else {
          alert("This gift has already been marked as bought!");
        }
      };
      dontBuyBtn.onclick = function(){
        if(received == 1) {
          if (buyer == currentUser.userName || buyer == "") {
            firebase.database().ref("users/" + user.uid + "/giftList/" + key).update({
              received: 0,
              buyer: ""
            });
          } else {
            alert("Only the buyer, " + buyer + ", can \"Un-Buy\" this gift. Please contact them to undo this action " +
              "if this has been done in error.");
          }
        } else {
          alert("This gift has already been marked as \"Un-Bought\"!");
        }
      };

      //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 and buttons.
with the proper gift's details and buttons.
with the proper gift ' s details and buttons .
function changeGiftElement(description, link, received, title, key, where, buyer, uid, date) {
    var editGift = document.getElementById("gift" + uid);
    editGift.innerHTML = title;
    editGift.className = "gift";
    if(received == 1) {
      editGift.className += " checked";
    }
    editGift.onclick = function (){
      var spanGift = document.getElementsByClassName("close")[0];
      var buyBtn = document.getElementById('giftBuy');
      var dontBuyBtn = document.getElementById('giftDontBuy');
      var descField = document.getElementById('giftDescription');
      var boughtField = document.getElementById('giftBought');
      var titleField = document.getElementById('giftTitle');
      var whereField = document.getElementById('giftWhere');
      var linkField = document.getElementById('giftLink');
      noteTitleField = document.getElementById('notificationTitle');
      noteInfoField = document.getElementById('notificationInfo');
      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(received == 1){
        if(buyer == "" || buyer == null || buyer == undefined){
          boughtField.innerHTML = "This gift has been bought";
        } else {
          boughtField.innerHTML = "This gift was bought by " + buyer;
        }
      } else {
        boughtField.innerHTML = "This gift has not been bought yet";
      }
      if(date != undefined) {
        if (date != "") {
          giftCreationDate.innerHTML = "Created on: " + date;
        } else {
          giftCreationDate.innerHTML = "Creation date not available";
        }
      } else {
        giftCreationDate.innerHTML = "Creation date not available";
      }
      buyBtn.onclick = function(){
        if(received == 0) {
          firebase.database().ref("users/" + user.uid + "/giftList/" + key).update({
            received: 1,
            buyer: currentUser.userName
          });
        } else {
          alert("This gift has already been marked as bought!");
        }
      };
      dontBuyBtn.onclick = function(){
        if(received == 1) {
          if (buyer == currentUser.userName || buyer == "") {
            firebase.database().ref("users/" + user.uid + "/giftList/" + key).update({
              received: 0,
              buyer: ""
            });
          } else {
            alert("Only the buyer, " + buyer + ", can \"Un-Buy\" this gift. Please contact them to undo this action " +
              "if this has been done in error.");
          }
        } else {
          alert("This gift has already been marked as \"Un-Bought\"!");
        }
      };
      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 ( description , link , received , title , key , where , buyer , uid , date ) { var editGift = document . getElementById ( "gift" + uid ) ; editGift . innerHTML = title ; editGift . className = "gift" ; if ( received == 1 ) { editGift . className += " checked" ; } editGift . onclick = function ( ) { var spanGift = document . getElementsByClassName ( "close" ) [ 0 ] ; var buyBtn = document . getElementById ( 'giftBuy' ) ; var dontBuyBtn = document . getElementById ( 'giftDontBuy' ) ; var descField = document . getElementById ( 'giftDescription' ) ; var boughtField = document . getElementById ( 'giftBought' ) ; var titleField = document . getElementById ( 'giftTitle' ) ; var whereField = document . getElementById ( 'giftWhere' ) ; var linkField = document . getElementById ( 'giftLink' ) ; noteTitleField = document . getElementById ( 'notificationTitle' ) ; noteInfoField = document . getElementById ( 'notificationInfo' ) ; 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 ( received == 1 ) { if ( buyer == "" || buyer == null || buyer == undefined ) { boughtField . innerHTML = "This gift has been bought" ; } else { boughtField . innerHTML = "This gift was bought by " + buyer ; } } else { boughtField . innerHTML = "This gift has not been bought yet" ; } if ( date != undefined ) { if ( date != "" ) { giftCreationDate . innerHTML = "Created on: " + date ; } else { giftCreationDate . innerHTML = "Creation date not available" ; } } else { giftCreationDate . innerHTML = "Creation date not available" ; } buyBtn . onclick = function ( ) { if ( received == 0 ) { firebase . database ( ) . ref ( "users/" + user . uid + "/giftList/" + key ) . update ( { received : 1 , buyer : currentUser . userName } ) ; } else { alert ( "This gift has already been marked as bought!" ) ; } } ; dontBuyBtn . onclick = function ( ) { if ( received == 1 ) { if ( buyer == currentUser . userName || buyer == "" ) { firebase . database ( ) . ref ( "users/" + user . uid + "/giftList/" + key ) . update ( { received : 0 , buyer : "" } ) ; } else { alert ( "Only the buyer, " + buyer + ", can \"Un-Buy\" this gift. Please contact them to undo this action " + "if this has been done in error." ) ; } } else { alert ( "This gift has already been marked as \"Un-Bought\"!" ) ; } } ; 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 and buttons.
with the proper gift ' s details and buttons .
//console.log("Checked, changed"); //show modal //close on close //close on click