Skip to content

Uncaught ReferenceError: usersArray is not defined in Pings true #150

Open
@yunierescobar

Description

@yunierescobar

Hello!

Thank you very much for this fantastic plugin. I have managed almost everything to work, I only have a problem with the Pings function. When the active, when sending the comment, I receive the error "Uncaught ReferenceError: usersArray is not defined"

This is my code:

                            $(function () {
                                var saveComment = function (data) {
                                    // Convert pings to human readable format
                                    $(data.pings).each(function (index, id) {
                                        var user = usersArray.filter(function (user) {
                                            return user.id == id
                                        })[0];
                                        data.content = data.content.replace('@' + id, '@' + user.fullname);
                                    });
                                    return data;
                                }
                                $('#comments-container').comments({

                                    noCommentsText: 'Aún no hay comentarios en esta foto. ¡Comenta ahora!',
                                    textareaPlaceholderText: '¿Qué te parece esta fotografía? Deja un comentario...',
                                    newestText: 'Más Recientes',
                                    oldestText: 'Más Antiguos',
                                    popularText: 'Más Popular',
                                    sendText: 'Enviar',
                                    replyText: 'Responder',
                                    youText: 'Tú',
                                    editedText: 'Editado',
                                    editText: 'Editar',
                                    deleteText: 'Eliminar',
                                    saveText: 'Guardar',
                                    viewAllRepliesText: 'Mostrar todas las respuestas (__replyCount__)',
                                    hideRepliesText: 'Ocultar respuestas',
                                    roundProfilePictures: true,
                                    enableHashtags: true,
                                    enablePinging: false,
                                    profilePictureURL: '<?php echo $AvatarImg;?>',
                                    maxRepliesVisible: 3,
                                    defaultNavigationSortKey: 'oldest',

                                    getUsers: function (success, error) {
                                        $.ajax({
                                            type: 'get',
                                            dataType: 'json',
                                            contentType: 'application/json',
                                            url: 'get_users.php',
                                            success: function (usersArray) {
                                                success(usersArray)
                                            },
                                            error: error
                                        });
                                    },

                                    getComments: function (success, error) {
                                        $.ajax({
                                            type: 'get',
                                            dataType: 'json',
                                            contentType: 'application/json',
                                            url: 'get_comments.php?photo=<?php echo $id;?>',
                                            success: function (commentsArray) {
                                                success(commentsArray)
                                            },
                                            error: error
                                        });
                                    },

                                    postComment: function (data, success, error) {
                                        $.ajax({
                                            type: 'post',
                                            dataType: "json",
                                            url: 'models/post_comments.php?pid=<?php echo $id;?>&cuid=<?php echo $UserId;?>&username=<?php echo $LoggedUsername;?>',
                                            data: data,
                                            success: function () {
                                                success(saveComment(data))
                                            },
                                            error: error
                                        });
                                    },

                                    putComment: function (data, success, error) {
                                        $.ajax({
                                            type: 'put',
                                            dataType: "json",
                                            url: 'models/put_comments.php?pid=<?php echo $id;?>&id=' + data.id,
                                            data: data,
                                            success: function () {
                                                success(saveComment(data))
                                            },
                                            error: error
                                        });
                                    },

                                    deleteComment: function (commentJSON, success, error) {
                                        $.ajax({
                                            type: 'post',
                                            url: 'models/delete_comments.php?pid=<?php echo $id;?>&id=' + commentJSON.id,
                                            success: success,
                                            error: error
                                        });
                                    },

                                    upvoteComment: function (commentJSON, success, error) {

                                        if (commentJSON.user_has_upvoted) {
                                            $.ajax({
                                                type: 'post',
                                                dataType: "json",
                                                url: 'models/post_upvotes.php?action=post&uid=<?php echo $UserId;?>&pid=<?php echo $id;?>',
                                                data: {
                                                    comment: commentJSON.id
                                                },
                                                success: function () {
                                                    success(commentJSON)
                                                },
                                                error: error
                                            });
                                        } else {
                                            $.ajax({
                                                type: 'post',
                                                dataType: "json",
                                                url: 'models/post_upvotes.php?action=delete&uid=<?php echo $UserId;?>&pid=<?php echo $id;?>',
                                                data: {
                                                    comment: commentJSON.id
                                                },
                                                success: function () {
                                                    success(commentJSON)
                                                },
                                                error: error
                                            });
                                        }
                                    },

                                    hashtagClicked: function (hashtag) {
                                        location = 'tags-' + hashtag + '-1'
                                    },

                                    timeFormatter: function (time) {
                                        moment.locale('es');
                                        return moment.utc(time, 'YYYY-MM-DD HH:mm:ss').local().fromNow();
                                    }

                                });
                            });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions