The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Avatar at last post on the index

View previous topic View next topic Go down

Avatar at last post on the index

Post by Guest on December 6th 2013, 7:33 pm

Hello,
I found a tutorial a long time ago and the result is that there is an avatar from the user on the index who posted the latest message.
No I have the avatar changed into the Hogwarts crest but I want to make it work like, if someone from "slytherin" has posted the latest message, that it turns into the slytherin crest and if someone from ravenclaw has posted the latest message, that it turn into the ravenclaw crest.

What I mean or actually want is: if someone from group #1 has posted, image #1 appears. And if someone from group #2 has posted, image #2 appears (See the pictures). Is this possible?

PICTURE 1:
PICTURE 2:

This is the Javascript I'm using, my forum is PHPBB2.
Code:
$(function(){
 
    if(!window.localStorage) return;
 
    // Avatar par défaut
    var default_avatar= 'http://i.imgur.com/p1oUY1M.png';
 
    // Temps de cache, ici 24 h * 60 m * 60 s * 1000 ms donc un jour
    var caching_time= 24*60*60*1000;
 
    // Temps de cache d'une erreur, ici 60 s * 1000 ms donc une minute
    var caching_error= 60*1000;
 
    var set_avatar= function(id) {
        $('.mini_ava.member'+id).html('<img src="http://i.imgur.com/p1oUY1M.png" />');
    };
 
    var get_avatar= function(id) {
        if(localStorage.getItem('t_ava'+id) < +new Date - caching_time || (localStorage.getItem('d_ava'+id)==default_avatar && localStorage.getItem('t_ava'+id) < +new Date - caching_error))
        {
            localStorage.setItem('d_ava'+id, default_avatar);
            $.get('/u'+id, function (d){
                localStorage.setItem('t_ava'+id,+new Date);
                localStorage.setItem('d_ava'+id, $('#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',d).first().attr('src')||default_avatar);
                set_avatar(id);
            });
        }
        return localStorage.getItem('d_ava'+id);
    };
 
    var to_replace= {};
 
    $('dd.lastpost strong a.gensmall, .ipbtable tr td:last-child span strong a.gensmall, .table td.tcr strong a.gensmall, .forumline .row3.over strong a.gensmall').each(function(){
        to_replace[$(this).attr('href').substr(2)]= 1;
        $(this).closest('td,dd').prepend('<div class="mini_ava member'+$(this).attr('href').substr(2)+'"></div>');
    });
 
    for(i in to_replace)
    {
        set_avatar(i);
    };
 
});

Guest
Guest


Back to top Go down

Re: Avatar at last post on the index

Post by Guest on December 8th 2013, 8:12 pm

I hope anyone could help me?

Guest
Guest


Back to top Go down

Re: Avatar at last post on the index

Post by Guest on December 15th 2013, 11:42 am

I'm still looking for someone who could help me?

Guest
Guest


Back to top Go down

View previous topic View next topic Back to top


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