function changeGiftElement(description, link, received, title, key, where, uid, date, buyer) {
        var editGift = document.getElementById("gift" + uid);
        editGift.innerHTML = title;
        editGift.className = "gift";
        editGift.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 (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";
            }
            updateBtn.onclick = function(){
                updateMaintenanceLog("home", "Attempting to update gift: " + title + " " + key + " " + user.userName);
                updateGiftElement(uid);
            };
            deleteBtn.onclick = function(){
                updateMaintenanceLog("home", "Attempting to delete gift: " + title + " " + key + " " + user.userName);
                deleteGiftElement(key, title, uid, buyer);
            };

            //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";
                }
            }
        };
    }
//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, uid, date, buyer) {
        var editGift = document.getElementById("gift" + uid);
        editGift.innerHTML = title;
        editGift.className = "gift";
        editGift.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 (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";
            }
            updateBtn.onclick = function(){
                updateMaintenanceLog("home", "Attempting to update gift: " + title + " " + key + " " + user.userName);
                updateGiftElement(uid);
            };
            deleteBtn.onclick = function(){
                updateMaintenanceLog("home", "Attempting to delete gift: " + title + " " + key + " " + user.userName);
                deleteGiftElement(key, title, uid, buyer);
            };
            modal.style.display = "block";
            spanGift.onclick = function() {
                modal.style.display = "none";
            };
            window.onclick = function(event) {
                if (event.target == modal) {
                    modal.style.display = "none";
                }
            }
        };
    }
function changeGiftElement ( description , link , received , title , key , where , uid , date , buyer ) { var editGift = document . getElementById ( "gift" + uid ) ; editGift . innerHTML = title ; editGift . className = "gift" ; editGift . 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 ( 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" ; } updateBtn . onclick = function ( ) { updateMaintenanceLog ( "home" , "Attempting to update gift: " + title + " " + key + " " + user . userName ) ; updateGiftElement ( uid ) ; } ; deleteBtn . onclick = function ( ) { updateMaintenanceLog ( "home" , "Attempting to delete gift: " + title + " " + key + " " + user . userName ) ; deleteGiftElement ( key , title , uid , buyer ) ; } ; modal . style . display = "block" ; spanGift . onclick = function ( ) { modal . style . display = "none" ; } ; window . onclick = function ( event ) { if ( event . target == modal ) { modal . style . display = "none" ; } } } ; }
with the proper gift's details and buttons.
with the proper gift ' s details and buttons .
//show modal //close on close //close on click