[Tutorial] Online staff widget - Page 2 Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
+6
Van-Helsing
Luiz~
Valoish
SLGray
Ali Ugbede
Daemon
10 posters

    [Tutorial] Online staff widget

    Daemon
    Daemon
    Forumember


    Posts : 104
    Reputation : 91
    Language : Português

    [Tutorial] Online staff widget - Page 2 Empty [Tutorial] Online staff widget

    Post by Daemon March 1st 2017, 3:28 pm

    First topic message reminder :

    This code serves to create a widget with online team members.

    Image:
    [Tutorial] Online staff widget - Page 2 SJ7wIid

    Create a custom widget with the following content:
    Code:
    <ul id="staff_widget"></ul>
    <script type="text/javascript">
    /*
     *  Application: Staff Online Widget
     *  Date: 14/06/2018
     *  Version: 2.014062018
     *  Copyright (c) 2018 Daemon <help.forumotion.com>
     *  This work is free. You can redistribute it and/or modify it
     */
    jQuery(function() {

        function staffOnline() {

            var staff = [
                {group: "Administrator", color: "FF0000"},
                {group: "Moderator", color: "008C09"},
                {group: "Helper", color: "D69A45"}
            ];

            jQuery.get("/viewonline", function(data) {
                staffWidget.html("");
                // variables
                var table = jQuery(".table, .table1, .ipbtable, .three-col .forumline", data);
                // List each item in the array
                jQuery.each(staff, function(i, val) {
                    var staffColor = table.find("span[style*='" + val.color + "']");
                    // Check span elements that contain array colors
                    if (typeof(staffColor) != "undefined" && staffColor != null) {
                        // For each existing color
                        jQuery.each(staffColor, function(i, el) {
                            var stafferHref = jQuery(el).closest("a").attr("href");
                            jQuery.get(stafferHref, function(data2) {
                                var stafferName = jQuery(el).closest("a").parent().html(),
                                    stafferId = stafferHref.split("/u")[1],
                                    avatarSrc = jQuery(".module", data2).find("img").attr("src");
                                staffWidget.append(
                                    '<li class="online_staff clearfix">' +
                                    '  <div class="div-icon-staff">' +
                                    '    <div class="staff-avatar"><img src="' + avatarSrc + '" alt="avatar"></div>' +
                                    '  </div>' +
                                    '  <div class="div-main-staff">' +
                                    '    <div class="staff-mp"><a href="/privmsg?mode=post&u=' + stafferId + '"><img src="https://2img.net/s/t/18/09/33/i_icon_pm.png" title="Send PM"></a></div>' +
                                    '    <div class="staff-name">' + stafferName + '</div>' +
                                    '    <p class="staff-rank">' + val.group + '</p>' +
                                    '  </div>' +
                                    '</li>'
                                );
                                sessionStorage.setItem("online_staff", staffWidget.html());
                            }); // end request 2
                        }); // end each staffColor
                    }// end if
                });// end each staff
            });// end request 1
        }
     
        var staffWidget = jQuery("#staff_widget");
        storedValue = sessionStorage.getItem("online_staff");
        staffWidget.html((storedValue !== null) ? storedValue : staffOnline());

        setInterval(function() {
            sessionStorage.removeItem("online_staff");
            staffOnline();
        }, 180000); // staffOnline function, reload every 3 minutes

    });
    </script>
    <style type="text/css">
    #staff_widget {padding: 0;}
    #staff_widget:empty:before {
        content: "No staff online!";
    }
    #staff_widget .online_staff {
      display: block;
      font-size: 14px;
      padding: 1px 0;
      zoom: 1;
    }
    #staff_widget .div-icon-staff {
      width: 25px;
      min-width: 25px;
      padding-top: 12px;
    }
    #staff_widget .div-icon-staff, #staff_widget .div-main-staff {
      display: table-cell;
      padding: 8px;
      vertical-align: top;
    }
    #staff_widget .staff-avatar {
      background: #fff;
      vertical-align: middle;
      display: inline-block;
      line-height: 1px;
      position: relative;
      margin: 2px;
    }
    #staff_widget .staff-avatar img {
      width: 34px;
      height: 34px;
      border: 1px solid #ddd;
    }
    #staff_widget .staff-mp {
      display: inline-block;
      float: right;
      margin-right: -25px;
    }
    #staff_widget .staff-rank {
      color: rgb(150, 150, 150);
      margin-top: 5px;
    }
    </style>

    To add groups and their colors, edit in the following lines of code:
    Code:
    var staff = [
        {group: "Administrator", color: "FF0000"},
        {group: "Moderator", color: "008C09"},
        {group: "Helper", color: "D69A45"}
    ];

    Smile


    Last edited by Daemon on February 10th 2020, 8:30 pm; edited 16 times in total
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    [Tutorial] Online staff widget - Page 2 Empty Re: [Tutorial] Online staff widget

    Post by Van-Helsing October 3rd 2017, 10:55 pm

    Hello @Daemon,
    I 've just tested on my new forum and its not working.

    Forum Link:

    ShinyFirefly
    ShinyFirefly
    New Member


    Female Posts : 21
    Reputation : 1
    Language : English
    Location : The Ether

    [Tutorial] Online staff widget - Page 2 Empty Re: [Tutorial] Online staff widget

    Post by ShinyFirefly January 8th 2018, 11:57 pm

    I just tried it on mine (phpbb3) as well and the output was all the lines of code where the widget should be.