function createNotificationElement(notificationString, notificationKey){
        try{
            document.getElementById("TestGift").remove();
        } catch (err) {}

        var friendUserData;
        var notificationTitle;
        var notificationDetails;
        var notificationPage;
        var notificationSplit = notificationString.split(",");

        if(notificationString.includes("@#$:")) {
            var privateMessage = notificationString.split("@#$:");
            var messageSender = privateMessage[0];

            friendUserData = findFriendUserData(messageSender);
            notificationTitle = "New Message From " + friendUserData.name;
            notificationDetails = privateMessage[1];
            notificationPage = "privateMessage";
        } else {
            if (notificationSplit.length == 1) {
                notificationTitle = "New Message From An Administrator!";
                notificationDetails = notificationSplit[0];
                notificationPage = "globalNotification";
            } else if (notificationSplit.length == 2) {
                var invitedName = notificationSplit[0];
                var pageName = notificationSplit[1];
                //console.log(invitedName + " " + pageName);

                notificationTitle = "You received an invite!";
                notificationDetails = invitedName + " has sent you an invite!";
                notificationPage = pageName;
            } else if (notificationSplit.length == 3) {
                var giftOwner = notificationSplit[0];
                var giftTitle = notificationSplit[1];
                var pageName = notificationSplit[2];
                //console.log(giftOwner + " " + giftTitle + " " + pageName);

                friendUserData = findFriendUserData(giftOwner);
                notificationPage = pageName;

                if (pageName == "friendList.html") {
                    if (friendUserData != -1)
                        notificationTitle = friendUserData.name + " updated a gift you bought!";
                    else
                        notificationTitle = "A gift you bought was updated!";
                    notificationDetails = "The gift, " + giftTitle + ", was updated!";
                } else if (pageName == "privateFriendList.html") {
                    if (friendUserData != -1)
                        notificationTitle = friendUserData.name + "\'s private gift that you bought was updated!";
                    else
                        notificationTitle = "A private gift that you bought was updated!";
                    notificationDetails = "The gift, " + giftTitle + ", was updated!";
                } else if (pageName == "deleteGift") {
                    if (friendUserData != -1)
                        notificationTitle = friendUserData.name + " deleted a gift you bought!";
                    else
                        notificationTitle = "A gift you bought was deleted!";
                    notificationDetails = "The gift, " + giftTitle + ", was deleted...";
                } else {
                    console.log("Notification Page Error, 1");
                }
            } else if (notificationSplit.length == 4) {
                var giftOwner = notificationSplit[0];
                var giftDeleter = notificationSplit[1];
                var giftTitle = notificationSplit[2];
                var pageName = notificationSplit[3];

                friendUserData = findFriendUserData(giftOwner);

                notificationPage = pageName;

                if (friendUserData != -1)
                    notificationTitle = friendUserData.name + "\'s private gift that you bought was deleted!";
                else
                    notificationTitle = giftDeleter + " deleted a gift that you bought!";
                notificationDetails = "The gift, " + giftTitle + ", was deleted by " + giftDeleter + "...";
            } else {
                console.log("Unknown Notification String Received...");
            }
        }

        var liItem = document.createElement("LI");
        liItem.id = "notification" + notificationKey;
        liItem.className = "gift";
        if(readNotificationArr.includes(notificationString)) {
            liItem.className += " checked";
            //console.log("Checked, created");
        }
        liItem.onclick = function (){
            var span = document.getElementsByClassName("close")[0];
            var notificationTitleField = document.getElementById('userNotificationTitle');
            var notificationDetailsField = document.getElementById('notificationDetails');
            var notificationPageField = document.getElementById('notificationPage');
            var notificationDelete = document.getElementById('notificationDelete');

            notificationTitleField.innerHTML = notificationTitle;
            notificationDetailsField.innerHTML = notificationDetails;

            if (notificationPage == "privateMessage") {
                notificationPageField.innerHTML = "To reply to this message, click here!";
                notificationPageField.onclick = function(){
                    generatePrivateMessageDialog(friendUserData);
                };
            } else if (notificationPage == "globalNotification"){
                notificationPageField.innerHTML = "As always, if you need any other information, send me a support email that can" +
                    " be found in the Help/FAQ under settings! Thank you!";
                notificationPageField.onclick = function(){};
            } else if (notificationPage == "invites.html"){
                notificationPageField.innerHTML = "Click here to access your invites!";
                notificationPageField.onclick = function(){
                    navigation(4);
                };
            } else if (notificationPage == "friendList.html" && friendUserData != -1) {
                notificationPageField.innerHTML = "Click here to access their friend list!";
                notificationPageField.onclick = function(){
                    sessionStorage.setItem("validGiftUser", JSON.stringify(friendUserData));//Friend's User Data
                    navigation(5);
                };
            } else if (notificationPage == "privateFriendList.html" && friendUserData != -1) {
                notificationPageField.innerHTML = "Click here to access their private friend list!";
                notificationPageField.onclick = function(){
                    sessionStorage.setItem("validGiftUser", JSON.stringify(friendUserData));//Friend's User Data
                    navigation(6);
                };
            } else if (notificationPage == "deleteGift") {
                notificationPageField.innerHTML = "If this has been done in error, please contact the gift owner.";
                notificationPageField.onclick = function(){};
            } else if (notificationPage == "deleteGiftPrivate") {
                notificationPageField.innerHTML = "If this has been done in error, please contact the person who deleted " +
                    "the gift.";
                notificationPageField.onclick = function(){};
            } else {
                console.log("Notification Page Error, 2");
                notificationPageField.innerHTML = "There was an error loading this link, contact an administrator.";
                notificationPageField.onclick = function(){};
            }

            notificationDelete.onclick = function(){
                deleteNotification(notificationKey);
                modal.style.display = "none";
            };

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

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

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

            if (!readNotificationArr.includes(notificationString)) {
                readNotificationArr.push(notificationString);

                user.readNotifications = readNotificationArr;
                updateReadNotificationToDB();
            }
        };
        var textNode = document.createTextNode(notificationTitle);
        liItem.appendChild(textNode);

        notificationList.insertBefore(liItem, document.getElementById("notificationListContainer").childNodes[0]);

        notificationCount++;
    }
//each notification's type has distinct differences in its data.
each notification's type has distinct differences in its data.
each notification ' s type has distinct differences in its data .
function createNotificationElement(notificationString, notificationKey){
        try{
            document.getElementById("TestGift").remove();
        } catch (err) {}
        var friendUserData;
        var notificationTitle;
        var notificationDetails;
        var notificationPage;
        var notificationSplit = notificationString.split(",");
        if(notificationString.includes("@#$:")) {
            var privateMessage = notificationString.split("@#$:");
            var messageSender = privateMessage[0];
            friendUserData = findFriendUserData(messageSender);
            notificationTitle = "New Message From " + friendUserData.name;
            notificationDetails = privateMessage[1];
            notificationPage = "privateMessage";
        } else {
            if (notificationSplit.length == 1) {
                notificationTitle = "New Message From An Administrator!";
                notificationDetails = notificationSplit[0];
                notificationPage = "globalNotification";
            } else if (notificationSplit.length == 2) {
                var invitedName = notificationSplit[0];
                var pageName = notificationSplit[1];
                notificationTitle = "You received an invite!";
                notificationDetails = invitedName + " has sent you an invite!";
                notificationPage = pageName;
            } else if (notificationSplit.length == 3) {
                var giftOwner = notificationSplit[0];
                var giftTitle = notificationSplit[1];
                var pageName = notificationSplit[2];
                friendUserData = findFriendUserData(giftOwner);
                notificationPage = pageName;
                if (pageName == "friendList.html") {
                    if (friendUserData != -1)
                        notificationTitle = friendUserData.name + " updated a gift you bought!";
                    else
                        notificationTitle = "A gift you bought was updated!";
                    notificationDetails = "The gift, " + giftTitle + ", was updated!";
                } else if (pageName == "privateFriendList.html") {
                    if (friendUserData != -1)
                        notificationTitle = friendUserData.name + "\'s private gift that you bought was updated!";
                    else
                        notificationTitle = "A private gift that you bought was updated!";
                    notificationDetails = "The gift, " + giftTitle + ", was updated!";
                } else if (pageName == "deleteGift") {
                    if (friendUserData != -1)
                        notificationTitle = friendUserData.name + " deleted a gift you bought!";
                    else
                        notificationTitle = "A gift you bought was deleted!";
                    notificationDetails = "The gift, " + giftTitle + ", was deleted...";
                } else {
                    console.log("Notification Page Error, 1");
                }
            } else if (notificationSplit.length == 4) {
                var giftOwner = notificationSplit[0];
                var giftDeleter = notificationSplit[1];
                var giftTitle = notificationSplit[2];
                var pageName = notificationSplit[3];
                friendUserData = findFriendUserData(giftOwner);
                notificationPage = pageName;
                if (friendUserData != -1)
                    notificationTitle = friendUserData.name + "\'s private gift that you bought was deleted!";
                else
                    notificationTitle = giftDeleter + " deleted a gift that you bought!";
                notificationDetails = "The gift, " + giftTitle + ", was deleted by " + giftDeleter + "...";
            } else {
                console.log("Unknown Notification String Received...");
            }
        }
        var liItem = document.createElement("LI");
        liItem.id = "notification" + notificationKey;
        liItem.className = "gift";
        if(readNotificationArr.includes(notificationString)) {
            liItem.className += " checked";
        }
        liItem.onclick = function (){
            var span = document.getElementsByClassName("close")[0];
            var notificationTitleField = document.getElementById('userNotificationTitle');
            var notificationDetailsField = document.getElementById('notificationDetails');
            var notificationPageField = document.getElementById('notificationPage');
            var notificationDelete = document.getElementById('notificationDelete');
            notificationTitleField.innerHTML = notificationTitle;
            notificationDetailsField.innerHTML = notificationDetails;
            if (notificationPage == "privateMessage") {
                notificationPageField.innerHTML = "To reply to this message, click here!";
                notificationPageField.onclick = function(){
                    generatePrivateMessageDialog(friendUserData);
                };
            } else if (notificationPage == "globalNotification"){
                notificationPageField.innerHTML = "As always, if you need any other information, send me a support email that can" +
                    " be found in the Help/FAQ under settings! Thank you!";
                notificationPageField.onclick = function(){};
            } else if (notificationPage == "invites.html"){
                notificationPageField.innerHTML = "Click here to access your invites!";
                notificationPageField.onclick = function(){
                    navigation(4);
                };
            } else if (notificationPage == "friendList.html" && friendUserData != -1) {
                notificationPageField.innerHTML = "Click here to access their friend list!";
                notificationPageField.onclick = function(){
                    sessionStorage.setItem("validGiftUser", JSON.stringify(friendUserData));
                    navigation(5);
                };
            } else if (notificationPage == "privateFriendList.html" && friendUserData != -1) {
                notificationPageField.innerHTML = "Click here to access their private friend list!";
                notificationPageField.onclick = function(){
                    sessionStorage.setItem("validGiftUser", JSON.stringify(friendUserData));
                    navigation(6);
                };
            } else if (notificationPage == "deleteGift") {
                notificationPageField.innerHTML = "If this has been done in error, please contact the gift owner.";
                notificationPageField.onclick = function(){};
            } else if (notificationPage == "deleteGiftPrivate") {
                notificationPageField.innerHTML = "If this has been done in error, please contact the person who deleted " +
                    "the gift.";
                notificationPageField.onclick = function(){};
            } else {
                console.log("Notification Page Error, 2");
                notificationPageField.innerHTML = "There was an error loading this link, contact an administrator.";
                notificationPageField.onclick = function(){};
            }
            notificationDelete.onclick = function(){
                deleteNotification(notificationKey);
                modal.style.display = "none";
            };
            modal.style.display = "block";
            span.onclick = function() {
                modal.style.display = "none";
            };
            window.onclick = function(event) {
                if (event.target == modal) {
                    modal.style.display = "none";
                }
            };
            if (!readNotificationArr.includes(notificationString)) {
                readNotificationArr.push(notificationString);
                user.readNotifications = readNotificationArr;
                updateReadNotificationToDB();
            }
        };
        var textNode = document.createTextNode(notificationTitle);
        liItem.appendChild(textNode);
        notificationList.insertBefore(liItem, document.getElementById("notificationListContainer").childNodes[0]);
        notificationCount++;
    }
function createNotificationElement ( notificationString , notificationKey ) { try { document . getElementById ( "TestGift" ) . remove ( ) ; } catch ( err ) { } var friendUserData ; var notificationTitle ; var notificationDetails ; var notificationPage ; var notificationSplit = notificationString . split ( "," ) ; if ( notificationString . includes ( "@#$:" ) ) { var privateMessage = notificationString . split ( "@#$:" ) ; var messageSender = privateMessage [ 0 ] ; friendUserData = findFriendUserData ( messageSender ) ; notificationTitle = "New Message From " + friendUserData . name ; notificationDetails = privateMessage [ 1 ] ; notificationPage = "privateMessage" ; } else { if ( notificationSplit . length == 1 ) { notificationTitle = "New Message From An Administrator!" ; notificationDetails = notificationSplit [ 0 ] ; notificationPage = "globalNotification" ; } else if ( notificationSplit . length == 2 ) { var invitedName = notificationSplit [ 0 ] ; var pageName = notificationSplit [ 1 ] ; notificationTitle = "You received an invite!" ; notificationDetails = invitedName + " has sent you an invite!" ; notificationPage = pageName ; } else if ( notificationSplit . length == 3 ) { var giftOwner = notificationSplit [ 0 ] ; var giftTitle = notificationSplit [ 1 ] ; var pageName = notificationSplit [ 2 ] ; friendUserData = findFriendUserData ( giftOwner ) ; notificationPage = pageName ; if ( pageName == "friendList.html" ) { if ( friendUserData != - 1 ) notificationTitle = friendUserData . name + " updated a gift you bought!" ; else notificationTitle = "A gift you bought was updated!" ; notificationDetails = "The gift, " + giftTitle + ", was updated!" ; } else if ( pageName == "privateFriendList.html" ) { if ( friendUserData != - 1 ) notificationTitle = friendUserData . name + "\'s private gift that you bought was updated!" ; else notificationTitle = "A private gift that you bought was updated!" ; notificationDetails = "The gift, " + giftTitle + ", was updated!" ; } else if ( pageName == "deleteGift" ) { if ( friendUserData != - 1 ) notificationTitle = friendUserData . name + " deleted a gift you bought!" ; else notificationTitle = "A gift you bought was deleted!" ; notificationDetails = "The gift, " + giftTitle + ", was deleted..." ; } else { console . log ( "Notification Page Error, 1" ) ; } } else if ( notificationSplit . length == 4 ) { var giftOwner = notificationSplit [ 0 ] ; var giftDeleter = notificationSplit [ 1 ] ; var giftTitle = notificationSplit [ 2 ] ; var pageName = notificationSplit [ 3 ] ; friendUserData = findFriendUserData ( giftOwner ) ; notificationPage = pageName ; if ( friendUserData != - 1 ) notificationTitle = friendUserData . name + "\'s private gift that you bought was deleted!" ; else notificationTitle = giftDeleter + " deleted a gift that you bought!" ; notificationDetails = "The gift, " + giftTitle + ", was deleted by " + giftDeleter + "..." ; } else { console . log ( "Unknown Notification String Received..." ) ; } } var liItem = document . createElement ( "LI" ) ; liItem . id = "notification" + notificationKey ; liItem . className = "gift" ; if ( readNotificationArr . includes ( notificationString ) ) { liItem . className += " checked" ; } liItem . onclick = function ( ) { var span = document . getElementsByClassName ( "close" ) [ 0 ] ; var notificationTitleField = document . getElementById ( 'userNotificationTitle' ) ; var notificationDetailsField = document . getElementById ( 'notificationDetails' ) ; var notificationPageField = document . getElementById ( 'notificationPage' ) ; var notificationDelete = document . getElementById ( 'notificationDelete' ) ; notificationTitleField . innerHTML = notificationTitle ; notificationDetailsField . innerHTML = notificationDetails ; if ( notificationPage == "privateMessage" ) { notificationPageField . innerHTML = "To reply to this message, click here!" ; notificationPageField . onclick = function ( ) { generatePrivateMessageDialog ( friendUserData ) ; } ; } else if ( notificationPage == "globalNotification" ) { notificationPageField . innerHTML = "As always, if you need any other information, send me a support email that can" + " be found in the Help/FAQ under settings! Thank you!" ; notificationPageField . onclick = function ( ) { } ; } else if ( notificationPage == "invites.html" ) { notificationPageField . innerHTML = "Click here to access your invites!" ; notificationPageField . onclick = function ( ) { navigation ( 4 ) ; } ; } else if ( notificationPage == "friendList.html" && friendUserData != - 1 ) { notificationPageField . innerHTML = "Click here to access their friend list!" ; notificationPageField . onclick = function ( ) { sessionStorage . setItem ( "validGiftUser" , JSON . stringify ( friendUserData ) ) ; navigation ( 5 ) ; } ; } else if ( notificationPage == "privateFriendList.html" && friendUserData != - 1 ) { notificationPageField . innerHTML = "Click here to access their private friend list!" ; notificationPageField . onclick = function ( ) { sessionStorage . setItem ( "validGiftUser" , JSON . stringify ( friendUserData ) ) ; navigation ( 6 ) ; } ; } else if ( notificationPage == "deleteGift" ) { notificationPageField . innerHTML = "If this has been done in error, please contact the gift owner." ; notificationPageField . onclick = function ( ) { } ; } else if ( notificationPage == "deleteGiftPrivate" ) { notificationPageField . innerHTML = "If this has been done in error, please contact the person who deleted " + "the gift." ; notificationPageField . onclick = function ( ) { } ; } else { console . log ( "Notification Page Error, 2" ) ; notificationPageField . innerHTML = "There was an error loading this link, contact an administrator." ; notificationPageField . onclick = function ( ) { } ; } notificationDelete . onclick = function ( ) { deleteNotification ( notificationKey ) ; modal . style . display = "none" ; } ; modal . style . display = "block" ; span . onclick = function ( ) { modal . style . display = "none" ; } ; window . onclick = function ( event ) { if ( event . target == modal ) { modal . style . display = "none" ; } } ; if ( ! readNotificationArr . includes ( notificationString ) ) { readNotificationArr . push ( notificationString ) ; user . readNotifications = readNotificationArr ; updateReadNotificationToDB ( ) ; } } ; var textNode = document . createTextNode ( notificationTitle ) ; liItem . appendChild ( textNode ) ; notificationList . insertBefore ( liItem , document . getElementById ( "notificationListContainer" ) . childNodes [ 0 ] ) ; notificationCount ++ ; }
each notification's type has distinct differences in its data.
each notification ' s type has distinct differences in its data .
//console.log(invitedName + " " + pageName); //console.log(giftOwner + " " + giftTitle + " " + pageName); //console.log("Checked, created"); //Friend's User Data //Friend's User Data //show modal //close on close //close on click