'Display 'Now Typing' in Chat

I'm looking to try and get a 'Read by userName' confirmation to appear in my chat. The best idea I've considered is to trigger the read confirmation by mouse movement, if the mouse moves after the message has been sent, it has been read.

So I decided to try to write the trigger for the event:

document.onmousemove = function() {}

This was really all I could produce as far as the event trigger goes.

The code to publish the read dialog into the chat is as follows:

channel.event_queue(
            "chat",
            {"object": {"message": "Read by" + userName}}
        );

That's that. If there is any way to set a second event or some additional variable so that the reading of the next message will remove the current read confirmation, then I'll be set.

I want the message to disappear after the next one is sent, the 'read' shouldn't stay around in the conversation, which is where I've drawn a blank.

Putting these two together is where I'm out of luck, my JavaScript experience is very slim.



Solution 1:[1]

You can bind multiple events by using the addEventListener method like:

document.addEventListener('mousemove',function (e) {/** Logic here **/});

Note that event names are written without "on" prefix here.

Not quite sure what your problem is with the removal of the "Read By bla" text, when you receive a new message just remove that notification text.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 LJᛃ