Up css đơn giản : thêm vào css :
Code:
span.monAva img {
width: 29px;
padding: 1px;
border: 1px solid #DDD;
margin-right: 7px;
box-shadow: 0 0 1px #DDD;
}
#theStaff strong {
font-size: 13px;
color: red;
}
Như tiêu đề, tạo một widget mới và thêm vào đoạn code sau:
Code:
<script type="text/javascript">
myStaff = ['/u1', '/u999'];
staff_cache_time = 4*60*1000; // mm*ss*ms;
</script>
<div id="theStaff">
</div>
<div id="theContent" style="display:none">
</div>
<noscript><div style="color:red;font-size:9px">Functionality of this widget is not possible, as JavaScript is disabled or unsupported.</div></noscript> <script type="text/javascript">
if (localStorage.staffOn && localStorage.staffEx > +new Date - staff_cache_time) jQuery('#theStaff').html(localStorage.staffOn);
else loadStaff();
function loadStaff() {
jQuery('#theContent').load('/viewonline #main-content a, a.gen', function() {
for (i=0; i<myStaff.length; i++) jQuery('#theContent a').filter(function() { return jQuery(this).attr('href') === myStaff[i] }).appendTo('#theStaff').wrap('<div class="myStaff">');
if (!jQuery('#theStaff .myStaff').length) jQuery('#theStaff').html('Không có BQT nào đang trực tuyến');
jQuery('.myStaff a').each(function() {
var href = jQuery(this).attr('href');
jQuery(this).before('<span class="monAva"></span>').prev().load(href + ' #profile-advanced-right .module:first div img:first,.forumline td.row1.gensmall:first > img, .frm-set.profile-view.left dd img,dl.left-box.details:first dd img, .row1 b .gen:first img, .real_avatar img', function() {
if (window.localStorage) {
localStorage.staffOn = jQuery('#theStaff').html();
localStorage.staffEx = +new Date;
}
});
});
});
}
</script>
Hướng dẫn: -Thay /u1, /u999 bằng ID của BQT
Code có gì sai sót mong thông cảm. Enjoy !!!
Tags: #code #javascript
Được sửa bởi the_dav ngày 8/29/2016, 21:02; sửa lần 3. (Reason for editing : fix demo)