function deleteGiftElement(key, title, uid, buyer) {
    var verifyDeleteBool = true;
    var toDelete = -1;

    for (var i = 0; i < giftArr.length; i++){
      if(title == giftArr[i].title) {
        toDelete = i;
        break;
      }
    }

    if(toDelete != -1) {
      giftArr.splice(toDelete, 1);

      for (var i = 0; i < giftArr.length; i++) {
        if (title == giftArr[i].title) {
          verifyDeleteBool = false;
          break;
        }
      }
    } else {
      verifyDeleteBool = false;
    }

    if(verifyDeleteBool){
      removeGiftElement(uid);
      firebase.database().ref("users/" + user.uid).update({
        giftList: giftArr
      });

      modal.style.display = "none";

      noteInfoField.innerHTML = "Gift Deleted";
      noteTitleField.innerHTML = "Gift " + title + " successfully deleted!";
      noteModal.style.display = "block";

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

      //close on click
      window.onclick = function(event) {
        if (event.target == noteModal) {
          noteModal.style.display = "none";
        }
      };

      var nowJ = 0;
      var j = setInterval(function(){
        nowJ = nowJ + 1000;
        if(nowJ >= 3000){
          noteModal.style.display = "none";
          clearInterval(j);
        }
      }, 1000);

      if(buyer != ""){
        var userFound = findUserNameItemInArr(buyer, userArr);
        if(userFound != -1){
          addNotificationToDB(userArr[userFound], title);
        } else {
          console.log("User not found");
        }
      } else {
        console.log("No buyer, no notification needed");
      }

    } else {
      alert("Delete failed, please try again later!");
    }
  }
//This deletes a specific gift from the user's data in the database and adds a notification if it had a buyer
This deletes a specific gift from the user's data in the database and adds a notification if it had a buyer
This deletes a specific gift from the user ' s data in the database and adds a notification if it had a buyer
function deleteGiftElement(key, title, uid, buyer) {
    var verifyDeleteBool = true;
    var toDelete = -1;
    for (var i = 0; i < giftArr.length; i++){
      if(title == giftArr[i].title) {
        toDelete = i;
        break;
      }
    }
    if(toDelete != -1) {
      giftArr.splice(toDelete, 1);
      for (var i = 0; i < giftArr.length; i++) {
        if (title == giftArr[i].title) {
          verifyDeleteBool = false;
          break;
        }
      }
    } else {
      verifyDeleteBool = false;
    }
    if(verifyDeleteBool){
      removeGiftElement(uid);
      firebase.database().ref("users/" + user.uid).update({
        giftList: giftArr
      });
      modal.style.display = "none";
      noteInfoField.innerHTML = "Gift Deleted";
      noteTitleField.innerHTML = "Gift " + title + " successfully deleted!";
      noteModal.style.display = "block";
      noteSpan.onclick = function() {
        noteModal.style.display = "none";
      };
      window.onclick = function(event) {
        if (event.target == noteModal) {
          noteModal.style.display = "none";
        }
      };
      var nowJ = 0;
      var j = setInterval(function(){
        nowJ = nowJ + 1000;
        if(nowJ >= 3000){
          noteModal.style.display = "none";
          clearInterval(j);
        }
      }, 1000);
      if(buyer != ""){
        var userFound = findUserNameItemInArr(buyer, userArr);
        if(userFound != -1){
          addNotificationToDB(userArr[userFound], title);
        } else {
          console.log("User not found");
        }
      } else {
        console.log("No buyer, no notification needed");
      }
    } else {
      alert("Delete failed, please try again later!");
    }
  }
function deleteGiftElement ( key , title , uid , buyer ) { var verifyDeleteBool = true ; var toDelete = - 1 ; for ( var i = 0 ; i < giftArr . length ; i ++ ) { if ( title == giftArr [ i ] . title ) { toDelete = i ; break ; } } if ( toDelete != - 1 ) { giftArr . splice ( toDelete , 1 ) ; for ( var i = 0 ; i < giftArr . length ; i ++ ) { if ( title == giftArr [ i ] . title ) { verifyDeleteBool = false ; break ; } } } else { verifyDeleteBool = false ; } if ( verifyDeleteBool ) { removeGiftElement ( uid ) ; firebase . database ( ) . ref ( "users/" + user . uid ) . update ( { giftList : giftArr } ) ; modal . style . display = "none" ; noteInfoField . innerHTML = "Gift Deleted" ; noteTitleField . innerHTML = "Gift " + title + " successfully deleted!" ; noteModal . style . display = "block" ; noteSpan . onclick = function ( ) { noteModal . style . display = "none" ; } ; window . onclick = function ( event ) { if ( event . target == noteModal ) { noteModal . style . display = "none" ; } } ; var nowJ = 0 ; var j = setInterval ( function ( ) { nowJ = nowJ + 1000 ; if ( nowJ >= 3000 ) { noteModal . style . display = "none" ; clearInterval ( j ) ; } } , 1000 ) ; if ( buyer != "" ) { var userFound = findUserNameItemInArr ( buyer , userArr ) ; if ( userFound != - 1 ) { addNotificationToDB ( userArr [ userFound ] , title ) ; } else { console . log ( "User not found" ) ; } } else { console . log ( "No buyer, no notification needed" ) ; } } else { alert ( "Delete failed, please try again later!" ) ; } }
This deletes a specific gift from the user's data in the database and adds a notification if it had a buyer
This deletes a specific gift from the user ' s data in the database and adds a notification if it had a buyer
//close on close //close on click