function deleteGiftElement(key, title, 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) {
            alert("Attempting to delete " + giftArr[toDelete].title + "! If this is successful, the page will reload.");
            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){
            firebase.database().ref("users/" + user.uid).update({
                privateList: giftArr
            });

            if(buyer != ""){
                var userFound = findUserNameItemInArr(buyer, userArr);
                if(userFound != -1){
                    if(userArr[userFound].uid != currentUser.uid) {
                        addNotificationToDB(userArr[userFound], currentUser.name, 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, 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) {
            alert("Attempting to delete " + giftArr[toDelete].title + "! If this is successful, the page will reload.");
            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){
            firebase.database().ref("users/" + user.uid).update({
                privateList: giftArr
            });
            if(buyer != ""){
                var userFound = findUserNameItemInArr(buyer, userArr);
                if(userFound != -1){
                    if(userArr[userFound].uid != currentUser.uid) {
                        addNotificationToDB(userArr[userFound], currentUser.name, 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 , 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 ) { alert ( "Attempting to delete " + giftArr [ toDelete ] . title + "! If this is successful, the page will reload." ) ; 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 ) { firebase . database ( ) . ref ( "users/" + user . uid ) . update ( { privateList : giftArr } ) ; if ( buyer != "" ) { var userFound = findUserNameItemInArr ( buyer , userArr ) ; if ( userFound != - 1 ) { if ( userArr [ userFound ] . uid != currentUser . uid ) { addNotificationToDB ( userArr [ userFound ] , currentUser . name , 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