OnlineList Modification - Show users in Channels?

84 views
Skip to first unread message

Banjo Fox

unread,
Sep 16, 2016, 11:33:35 AM9/16/16
to AJAX-chat

Hi All,


It seems as though my next "big modification" by user request is to replicate the FlashChat Room (channel) list (screenshot below).

Essentially the OnlineList is the complete list of channels that can be expanded to reveal who is in those channels.


My -current- plan is to duplicate the onlineListContainer and then populate it accordingly. That way users have more flexibility with their displays (another common question).

Other than adding some more div's to the loggedIn.html template I haven't really made any progress.


Have any of you guys added side-bar containers to your chats?

Do any of you have mods that fulfill this need already (or are close?)


Thanks!


Banjo


This screenshot was taken from FlashChat 4.7





Frug

unread,
Sep 18, 2016, 1:25:26 PM9/18/16
to AJAX-chat
This is a good feature type request. If you need help getting started, I can point you in the right direction. I guess the best way to do it is to edit the xml response that already exists so that instead of only providing users, it provides a list of rooms and uers. 

If you visit your chat/index.php?ajax=true you'll get a response like this
  1. <root>
    <infos/>
    <users>
    <user userID="2" userRole="3" channelID="5">
    <![CDATA[ Frug ]]>
    </user>
    </users>
    <messages>
    <message id="238606" dateTime="Sun, 18 Sep 2016 16:46:56 +0000" userID="2147483647" userRole="4"channelID="5">
    <username>
    <![CDATA[ Porter ]]>
    </username>
    <text>
    <![CDATA[ /channelEnter Frug ]]>
    </text>
    </message>
    </messages>
    </root>

If you're curious and haven't used your browser inspector to poke around, you can get more data in a response by adding some values to the getInfos key in the query, like
index.php?ajax=true&getInfos=userID,userName,userRole,channelID,channelName
(Note that if you're looking in your inspector, the commas will appear as %2C, but commas work just fine)

As far as I know there's no ajax call that will give you a room list. Rooms are loaded on page load and embedded in the html. You can try using the /list command to see a list of rooms, but that comes back in the contents of a message, not xml.

I guess you could start by adding a new node under root, like <channels> and structure it like this
<channels>
   
<channel channelID="5">
       
<name><![CDATA[ Public ]]></name>
       
<users><user userID="2" userRole="3" channelID="5"><![CDATA[ Frug ]]></user></users>
   
</channel>
</channels>

That's just my guess though. There might be a better way. God I wish this project used json instead of xml.

Banjo Fox

unread,
Sep 19, 2016, 10:54:32 AM9/19/16
to ajax...@googlegroups.com
Thanks Frug!

I will start to give this a shot and report back with my findings :D
Using the browser inspector has been VERY useful in helping me find out where things get put.

In terms of XML vs JSON... is there a reason why you haven't made the switch?


Addendum:
I just found this code snippet for storing values in JSON format using AJAX.

http://www.tutorialspoint.com/json/json_ajax_example.htm
Reply all
Reply to author
Forward
0 new messages