function createGiftElement(giftDescription, giftLink, giftReceived, giftTitle, giftKey, giftWhere, giftUid, giftDate,
                             giftBuyer){
      try{
          document.getElementById("TestGift").remove();
      } catch (err) {}

      var liItem = document.createElement("LI");
      liItem.id = "gift" + giftUid;
      liItem.className = "gift";
      liItem.onclick = function (){
          var spanGift = document.getElementsByClassName("close")[0];
          var updateBtn = document.getElementById('giftUpdate');
          var deleteBtn = document.getElementById('giftDelete');
          var descField = document.getElementById('giftDescription');
          var titleField = document.getElementById('giftTitle');
          var whereField = document.getElementById('giftWhere');
          var linkField = document.getElementById('giftLink');

          if (giftLink != ""){
              linkField.innerHTML = "Click me to go to the webpage!";
              linkField.onclick = function() {
                  var newGiftLink = "http://";
                  if(giftLink.includes("https://")){
                      giftLink = giftLink.slice(8, giftLink.length);
                  } else if (giftLink.includes("http://")){
                      giftLink = giftLink.slice(7, giftLink.length);
                  }
                  newGiftLink += giftLink;
                  window.open(newGiftLink, "_blank");
              };
          } else {
              linkField.innerHTML = "There was no link provided";
              linkField.onclick = function() {
              };
          }
          if(giftDescription != "") {
              descField.innerHTML = "Description: " + giftDescription;
          } else {
              descField.innerHTML = "There was no description provided";
          }
          titleField.innerHTML = giftTitle;
          if(giftWhere != "") {
              whereField.innerHTML = "This can be found at: " + giftWhere;
          } else {
              whereField.innerHTML = "There was no location provided";
          }
          if(giftDate != undefined) {
              if (giftDate != "") {
                  giftCreationDate.innerHTML = "Created on: " + giftDate;
              } else {
                  giftCreationDate.innerHTML = "Creation date not available";
              }
          } else {
              giftCreationDate.innerHTML = "Creation date not available";
          }
          updateBtn.onclick = function(){
              updateMaintenanceLog("home", "Attempting to update gift: " + giftTitle + " " + giftKey + " " + user.userName);
              updateGiftElement(giftUid);
          };
          deleteBtn.onclick = function(){
              updateMaintenanceLog("home", "Attempting to delete gift: " + giftTitle + " " + giftKey + " " + user.userName);
              deleteGiftElement(giftKey, giftTitle, giftUid, giftBuyer);
          };

          //show modal
          modal.style.display = "block";

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

          //close on click
          window.onclick = function(event) {
              if (event.target == modal) {
                  modal.style.display = "none";
              }
          }
      }
      var textNode = document.createTextNode(giftTitle);
      liItem.appendChild(textNode);
      giftList.insertBefore(liItem, document.getElementById("giftListContainer").childNodes[0]);
      clearInterval(offlineTimer);

      giftCounter++;
      if (giftCounter > 5)
          boughtGifts.style.opacity = ".75";
  }
//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 createGiftElement(giftDescription, giftLink, giftReceived, giftTitle, giftKey, giftWhere, giftUid, giftDate,
                             giftBuyer){
      try{
          document.getElementById("TestGift").remove();
      } catch (err) {}
      var liItem = document.createElement("LI");
      liItem.id = "gift" + giftUid;
      liItem.className = "gift";
      liItem.onclick = function (){
          var spanGift = document.getElementsByClassName("close")[0];
          var updateBtn = document.getElementById('giftUpdate');
          var deleteBtn = document.getElementById('giftDelete');
          var descField = document.getElementById('giftDescription');
          var titleField = document.getElementById('giftTitle');
          var whereField = document.getElementById('giftWhere');
          var linkField = document.getElementById('giftLink');
          if (giftLink != ""){
              linkField.innerHTML = "Click me to go to the webpage!";
              linkField.onclick = function() {
                  var newGiftLink = "http://";
                  if(giftLink.includes("https://")){
                      giftLink = giftLink.slice(8, giftLink.length);
                  } else if (giftLink.includes("http://")){
                      giftLink = giftLink.slice(7, giftLink.length);
                  }
                  newGiftLink += giftLink;
                  window.open(newGiftLink, "_blank");
              };
          } else {
              linkField.innerHTML = "There was no link provided";
              linkField.onclick = function() {
              };
          }
          if(giftDescription != "") {
              descField.innerHTML = "Description: " + giftDescription;
          } else {
              descField.innerHTML = "There was no description provided";
          }
          titleField.innerHTML = giftTitle;
          if(giftWhere != "") {
              whereField.innerHTML = "This can be found at: " + giftWhere;
          } else {
              whereField.innerHTML = "There was no location provided";
          }
          if(giftDate != undefined) {
              if (giftDate != "") {
                  giftCreationDate.innerHTML = "Created on: " + giftDate;
              } else {
                  giftCreationDate.innerHTML = "Creation date not available";
              }
          } else {
              giftCreationDate.innerHTML = "Creation date not available";
          }
          updateBtn.onclick = function(){
              updateMaintenanceLog("home", "Attempting to update gift: " + giftTitle + " " + giftKey + " " + user.userName);
              updateGiftElement(giftUid);
          };
          deleteBtn.onclick = function(){
              updateMaintenanceLog("home", "Attempting to delete gift: " + giftTitle + " " + giftKey + " " + user.userName);
              deleteGiftElement(giftKey, giftTitle, giftUid, giftBuyer);
          };
          modal.style.display = "block";
          spanGift.onclick = function() {
              modal.style.display = "none";
          };
          window.onclick = function(event) {
              if (event.target == modal) {
                  modal.style.display = "none";
              }
          }
      }
      var textNode = document.createTextNode(giftTitle);
      liItem.appendChild(textNode);
      giftList.insertBefore(liItem, document.getElementById("giftListContainer").childNodes[0]);
      clearInterval(offlineTimer);
      giftCounter++;
      if (giftCounter > 5)
          boughtGifts.style.opacity = ".75";
  }
function createGiftElement ( giftDescription , giftLink , giftReceived , giftTitle , giftKey , giftWhere , giftUid , giftDate , giftBuyer ) { try { document . getElementById ( "TestGift" ) . remove ( ) ; } catch ( err ) { } var liItem = document . createElement ( "LI" ) ; liItem . id = "gift" + giftUid ; liItem . className = "gift" ; liItem . onclick = function ( ) { var spanGift = document . getElementsByClassName ( "close" ) [ 0 ] ; var updateBtn = document . getElementById ( 'giftUpdate' ) ; var deleteBtn = document . getElementById ( 'giftDelete' ) ; var descField = document . getElementById ( 'giftDescription' ) ; var titleField = document . getElementById ( 'giftTitle' ) ; var whereField = document . getElementById ( 'giftWhere' ) ; var linkField = document . getElementById ( 'giftLink' ) ; if ( giftLink != "" ) { linkField . innerHTML = "Click me to go to the webpage!" ; linkField . onclick = function ( ) { var newGiftLink = "http://" ; if ( giftLink . includes ( "https://" ) ) { giftLink = giftLink . slice ( 8 , giftLink . length ) ; } else if ( giftLink . includes ( "http://" ) ) { giftLink = giftLink . slice ( 7 , giftLink . length ) ; } newGiftLink += giftLink ; window . open ( newGiftLink , "_blank" ) ; } ; } else { linkField . innerHTML = "There was no link provided" ; linkField . onclick = function ( ) { } ; } if ( giftDescription != "" ) { descField . innerHTML = "Description: " + giftDescription ; } else { descField . innerHTML = "There was no description provided" ; } titleField . innerHTML = giftTitle ; if ( giftWhere != "" ) { whereField . innerHTML = "This can be found at: " + giftWhere ; } else { whereField . innerHTML = "There was no location provided" ; } if ( giftDate != undefined ) { if ( giftDate != "" ) { giftCreationDate . innerHTML = "Created on: " + giftDate ; } else { giftCreationDate . innerHTML = "Creation date not available" ; } } else { giftCreationDate . innerHTML = "Creation date not available" ; } updateBtn . onclick = function ( ) { updateMaintenanceLog ( "home" , "Attempting to update gift: " + giftTitle + " " + giftKey + " " + user . userName ) ; updateGiftElement ( giftUid ) ; } ; deleteBtn . onclick = function ( ) { updateMaintenanceLog ( "home" , "Attempting to delete gift: " + giftTitle + " " + giftKey + " " + user . userName ) ; deleteGiftElement ( giftKey , giftTitle , giftUid , giftBuyer ) ; } ; modal . style . display = "block" ; spanGift . onclick = function ( ) { modal . style . display = "none" ; } ; window . onclick = function ( event ) { if ( event . target == modal ) { modal . style . display = "none" ; } } } var textNode = document . createTextNode ( giftTitle ) ; liItem . appendChild ( textNode ) ; giftList . insertBefore ( liItem , document . getElementById ( "giftListContainer" ) . childNodes [ 0 ] ) ; clearInterval ( offlineTimer ) ; giftCounter ++ ; if ( giftCounter > 5 ) boughtGifts . style . opacity = ".75" ; }
with the proper gift's details and buttons.
with the proper gift ' s details and buttons .
//show modal //close on close //close on click