Good art is a taste, good design is an opinion.


Come as guest, stay as family.
Board Index

Come as guest, stay as family.


You are not connected. Please login or register

Foto

[Javascript] Staff Online - Widget



Go to page : 1, 2, 3, 4, 5, 6, 7  Next

View previous topic View next topic Go down Message [Page 1 of 7]

1
Offline

  Shadow

Shadow
Administrator
Administrator
Description:

Widget to show all of the staff members online.

Installation steps:

Code:
[panda=js]            <div id="Staff_Online">
                                                                                                                                                          
            </div>
                    <script type="text/javascript">
                        jQuery(document).ready(function () {
                            var widget = jQuery('#Staff_Online')[0];
                            staff_cache_time = 4*60*1000; // mm*ss*ms;
                    
                            if (localStorage.staffOn && localStorage.staffEx > +new Date - staff_cache_time) {
                                jQuery(widget).html(localStorage.staffOn)
                            } else {
                                jQuery.get('/viewonline', function (data) {
                                    var group = {
                  
                                        ffnd: jQuery('.table span[style="color:#990012"]', data).parents('td'),
                  
                                        adm: jQuery('.table span[style="color:#FF0000"]', data).parents('td'),
                  
                                        gmod: jQuery('.table span[style="color:#800080"]', data).parents('td'),
                
                                        fmod: jQuery('.table span[style="color:#7057FA"]', data).parents('td'),
            
                                        tsup: jQuery('.table span[style="color:#0020C2"]', data).parents('td'),                
                                        };
                                jQuery(widget).append(group.ffnd).append(group.adm).append(group.gmod).append(group.fmod).append(group.tsup);
                                    jQuery('#Staff_Online a[href^="/u"]').each(function () {
                                        var prof = jQuery(this).attr('href');
                                        jQuery('<a href="' + prof + '" class="avatarimage"></a>').insertBefore(this);
                                        jQuery('<div class="Info"></div>').insertAfter(this);
                                        jQuery(this).prev().load(prof + ' #profile-advanced-right .main-content img:eq(0)');
                  
                                        jQuery(this).next().load(prof + ' #field_id5 dd div:eq(0)')
                                        })
                                });
                                jQuery(window).on('load', function () {
                                    localStorage.staffOn = document.getElementById(widget).innerHTML;
                                    localStorage.staffEx = +new Date;
                                })
                            }
                        });
                        </script> <style>
                      #Staff_Online .avatarimage > img {
                        float: left;
                        margin-right: 4px!important;
                        width: 40px;
                        height: 40px;
                        border: 1px solid #0000CD;
                        border-radius: 4px;
                        box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.1);
                    }
                    #Staff_Online .Info {
                        color: #0000A0;
                        margin: 1px 45px;
                        padding: 8px 1px 5px;
                        width: 190px;
                        display: inline;
                    }
                    #Staff_Online {
                    height: auto;
                    }
                    #Staff_Online td {
                    display: block;
                    }
                    </style>

Code by @Daemon (.Load() function, this code is unstable.)


- Widget
Create a new widget [tip]Admin Panel -> Modules -> Forum Widget Manager => Create a new widget[/tip]

Code:
[panda=html]<div class="module main">
            
    <div class="main-head">
                
        <div class="h3">
                 Staff Online    
        </div>
                
    </div>
            
    <div class="main-content clearfix">
                
        <div id="staff_widget">
                    
        </div>

<script>jQuery(document).ready(function () {
    var widget = jQuery('#staff_widget')[0];
    storedValue = sessionStorage.getItem('online_staff');
    if (storedValue) {
        jQuery(widget).html(storedValue)
    } else {
        jQuery.get('/viewonline', function (data) {
            var group = {
                group1: jQuery('.table span[style="color:#FF6600"]', data).parents('td'),
                group2: jQuery('.table span[style="color:#691F67"]', data).parents('td'),
                group3: jQuery('.table span[style="color:#00A1BA"]', data).parents('td'),
                group4: jQuery('.table span[style="color:#CC66CC"]', data).parents('td'),
            };
            jQuery(widget).append(group.group1).append(group.group2).append(group.group3).append(group.group4);
            jQuery('#staff_widget a[href^="/u"]').each(function () {
                var prof = jQuery(this).attr('href');
                jQuery('<a href="' + prof + '" class="lastpost-avatar"></a>').insertBefore(this);
                jQuery('<div class="userTitle"></div>').insertAfter(this);
                jQuery(this).prev().load(prof + ' #profile-advanced-right .main-content img:eq(0)');
                jQuery(this).next().load(prof + ' #field_id1 dd div:eq(0)')
            })
        });
        jQuery(window).on('load', function () {
            var currentValue = document.getElementById(widget).innerHTML;
            sessionStorage.setItem('online_staff', currentValue)
        })
    }
});</script>
Explanation:



[ic]group1: jQuery('.table span[style="color:#FF6600"]', data).parents('td'),[/ic]

This part of the code will display users with group color [ic]"#FF6600"[/ic] to staff online widget.

For example if your Administrator group color is [ic]#FF0000[/ic] (red) the code should look like this:
[ic]group1: jQuery('.table span[style="color:#FF0000"]', data).parents('td'),[/ic]

So you need to change that part of the code with your group color, in this you have 4 different colors (group1, group2, group3, group4) - so you can change everyone with your group colors. After that save the widget and that's it.




- CSS
Put the following code in your CSS.

Code:
[panda=css]#staff_widget td {
display: block;
padding: 6px 0;
zoom: 1;
}
#staff_widget .avt_staff {
margin-right: 5px;
float: left;
zoom: 1;
}
#staff_widget .userTitle {
color: rgb(150,150,150);
margin-top: 3px;
}


Preview:

[Javascript] Staff Online - Widget PzHMOiF

Powered by PunBB
Currently 0 users have thanked Shadow for this post:

2
Offline

  deaneo8

deaneo8
V.I.P. Member
V.I.P. Member
NICE TOPIC BRO

Powered by PunBB
Currently 0 users have thanked deaneo8 for this post:

3
Offline

  Fibo

Fibo
Newbie
Newbie
Nice,

very thanks!!!!

Powered by PunBB
Currently 0 users have thanked Fibo for this post:

4
Offline

  nanako

nanako
Punbb Guru
Punbb Guru
I'll try this, it's good and thanks.

Powered by PunBB
Currently 0 users have thanked nanako for this post:

5
Offline

  Van-Helsing

Van-Helsing
★Moderator★
★Moderator★
Thanks

Powered by PunBB
Currently 0 users have thanked Van-Helsing for this post:

6
Offline

  Lilium'

Lilium'
Punbb Rookie
Punbb Rookie
good job, Shadow.

Powered by PunBB
Currently 0 users have thanked Lilium' for this post:

7
Offline

  SarkZKalie

SarkZKalie
Punbb Rookie
Punbb Rookie
Nice tutorial!

Powered by PunBB
Currently 0 users have thanked SarkZKalie for this post:

8
Offline

  damy_nqn

damy_nqn
Newbie
Newbie
tranks bro

Powered by PunBB
Currently 0 users have thanked damy_nqn for this post:

9
Offline

  Udarsha45

Udarsha45
Punbb Rookie
Punbb Rookie
thanks man.

Powered by PunBB
Currently 0 users have thanked Udarsha45 for this post:

10
Offline

  Note

Note
Punbb Rookie
Punbb Rookie
thanxs

Powered by PunBB
Currently 0 users have thanked Note for this post:

11
Offline

  Micul`Wji

Micul`Wji
Punbb Junior
Punbb Junior
wow that is awsosme

Powered by PunBB
Currently 0 users have thanked Micul`Wji for this post:

12
Offline

  Zildjian

Zildjian
Punbb Junior
Punbb Junior
nice tricks

Powered by PunBB
Currently 0 users have thanked Zildjian for this post:

13
Offline

  KiNGphx

KiNGphx
Punbb Guru
Punbb Guru
wow tnx nice code

Powered by PunBB
Currently 0 users have thanked KiNGphx for this post:

14
Offline

  Patrikkk

Patrikkk
Newbie
Newbie
Thanks

Powered by PunBB
Currently 0 users have thanked Patrikkk for this post:

15
Offline

  Delsin

Delsin
Punbb Rookie
Punbb Rookie
Thanks

Powered by PunBB
Currently 0 users have thanked Delsin for this post:

16
Offline

  DooGy00

DooGy00
Punbb Rookie
Punbb Rookie
thanks bro!

Powered by PunBB
Currently 0 users have thanked DooGy00 for this post:

17
Offline

  darkgoku

darkgoku
Pemanently Banned
Pemanently Banned
this is cool

Powered by PunBB
Currently 0 users have thanked darkgoku for this post:

18
Offline

  Michael_vx

Michael_vx
Punbb Junior
Punbb Junior
looks nice thanks Smile

Powered by PunBB
Currently 0 users have thanked Michael_vx for this post:

19
Offline

  Tecko

Tecko
Punbb Rookie
Punbb Rookie
Wow. Nice code, good job! Very Happy

Powered by PunBB
Currently 0 users have thanked Tecko for this post:

20
Offline

  DeeW.

DeeW.
Newbie
Newbie
not's permited use this code...

Mad

Powered by PunBB
Currently 0 users have thanked DeeW. for this post:

21
Offline

  Sponsored content



Powered by PunBB
Currently 0 users have thanked Sponsored content for this post:

View previous topic View next topic Back to top Message [Page 1 of 7]


Go to page : 1, 2, 3, 4, 5, 6, 7  Next

Topic URL's

URL
BBcode
HTML

Permissions in this forum:
You cannot reply to topics in this forum