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 : Previous  1, 2, 3, 4, 5, 6, 7  Next

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

1
Offline

  Shadow

Shadow
Administrator
Administrator
First topic message reminder :

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 - Page 6 PzHMOiF

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

101
Offline

  Drakius

Drakius
Pemanently Banned
Pemanently Banned
.

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

102
Offline

  Shadow

Shadow
Administrator
Administrator
[aviso="Spamming thread"]@Drakius please refrain from posting useless posts, a warning has been issued.

It takes only a second to write a simple thank you or thanks.[/aviso]

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

103
Offline

  Harker

Harker
Newbie
Newbie
Thanks my friend......

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

104
Offline

  Drakius3

Drakius3
Pemanently Banned
Pemanently Banned
,

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

105
Offline

  yaanz

yaanz
Punbb Junior
Punbb Junior
thanks for sharing this code

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

106
Offline

  Dragon 2

Dragon 2
Punbb Rookie
Punbb Rookie
Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy

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

107
Offline

  Meliss

Meliss
Newbie
Newbie
Woow!! Very nice! Surprised

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

108
Offline

  Warrenrank

Warrenrank
Newbie
Newbie
Cool stuff

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

109
Offline

  while

while
Newbie
Newbie
muito bom

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

110
Offline

  skin4fm

skin4fm
Newbie
Newbie
cinder75 wrote:[link="/t658-javascript-staff-online-widget#4784"]nice :3

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

111
Offline

  skin4fm

skin4fm
Newbie
Newbie
thank you sir

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

112
Offline

  Shadow

Shadow
Administrator
Administrator
[aviso="Double Post"]@skin4fm Please don't double post. Your post needs to be separated by at least 24 hours before bumping. Please use the edit button instead![/aviso]

[alerta="Language not English"]@while All publicly displayed messages are only limited to English. This includes posts, titles, signatures, profiles and other forms of public display.[/alerta]

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

113
Offline

  Deswimmer39

Deswimmer39
Punbb Rookie
Punbb Rookie
Nice

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

114
Offline

  Jorpeto

Jorpeto
Punbb Rookie
Punbb Rookie
fefe

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

115
Offline

  Residays

Residays
Newbie
Newbie
I really appreciate this, thank you.

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

116
Offline

  Matrix0

Matrix0
Punbb Rookie
Punbb Rookie
cool

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

117
Offline

  yayayes

yayayes
Newbie
Newbie
Cool!

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

118
Offline

  Stark.sys

Stark.sys
Newbie
Newbie
Very nice code Smile

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

119
Offline

  Profesional

Profesional
Newbie
Newbie
very thanks!!!!

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

120
Offline

  Profesional

Profesional
Newbie
Newbie
very thanks!!!!

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

121
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 6 of 7]


Go to page : Previous  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