Re: Display # of users in chat on forum home page

  •  11-26-2007, 12:01 PM

    Re: Display # of users in chat on forum home page

    You can do this way :
     
    modify the inc_footer.asp # 70 :

    Response.Write "<script src='ChatterListScript.aspx'></script>"
     
    and then create a new file ChatterListScript.aspx , fill this code into it :
     

    <%@ Page Language="C#" %>
    <%@ Import Namespace="CuteChat" %>
    <script runat=server>
    static string Encode(string val)
    {
     if(val==null)return "";
     return val.Replace("\\","\\\\").Replace("\"","\\\\");
    }
    </script>

    var onlineusers=[];

    <%
    ChatPortal portal=ChatSystem.Instance.GetCurrentPortal();
    lock(portal)
    {

    foreach(ChatChannel channel in portal.GetStartedChannels())
    {
    foreach(ChatPlaceUser user in channel.GetAllUsers())
    {
     if(user.AppearOffline)continue;

    %>

    onlineusers.push({
    UserId:"<%=user.Identity.UniqueId%>"
    ,
    Name:"<%=Encode(user.DisplayName)%>"
    ,
    IsGuest:<%=user.Identity.IsAnonymous?"true":"false"%>
    });


    <%}%>

    <%}%>

    <%}%>


    for(var i=0;i<onlineusers.length;i++)
    {
     var user=onlineusersIdea;
     document.write("<span class='onlineuser'>");
     document.write(user.Name);
     document.write("</span>");
    }

     
     
     
     
     
    Hope this helps.
     
    Regards , Terry.
View Complete Thread