Latest topics
» bloquer un membre
by berlingo Yesterday at 18:19

» IconSkouliki Graphics
by skouliki Yesterday at 03:54

» [IN PROGRESS] Can this code work on pun version
by skouliki Thu 16 Nov 2017, 03:50

» Auto-suggest @mentions as You Type
by skouliki Wed 15 Nov 2017, 14:56

» [TUTORIAL] [ALL VERSIONS] Warning before posting
by demon99 Wed 15 Nov 2017, 08:12

» [HELP] About Profile Cover Code
by omarpop23 Tue 14 Nov 2017, 12:35

» About Add Reply & New Topic button (popup form)
by omarpop23 Mon 13 Nov 2017, 20:31

» Hello everyone this is Adam from France
by Adam Mon 13 Nov 2017, 13:32

» Add a login popup for the toolbar
by Ape Sun 12 Nov 2017, 18:41

» Post a message automatically when locking a topic
by ThunderTB Sun 12 Nov 2017, 13:51

» Control pannel issue
by Ange Tuteur Sun 12 Nov 2017, 09:49

» BUG... forum members birthday's
by Ape Sat 11 Nov 2017, 11:44

» Display a Preview of Groups on Hover
by ThunderTB Fri 10 Nov 2017, 21:56

» Search box only visible on hover
by Ange Tuteur Mon 06 Nov 2017, 09:57

» [GAME] Animal Game
by SLGray Sun 05 Nov 2017, 15:04

Recent Tutorials
Who is online?
In total there are 6 users online :: 0 Registered, 0 Hidden and 6 Guests :: 1 Bot

None

[ View the whole list ]


Most users ever online was 172 on Fri 19 Feb 2016, 05:17

Recent Topic with Avatar problem

View previous topic View next topic Go down

avatar
snows
Member
Title :
Gender : Unspecified
Posts : 14
Points : 147
Reputation : 0
Language : English
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile

Postsnows on Tue 15 Aug 2017, 15:19

Hey Fmdesign, i got this code from Forumotion support forum it is a code for recent topic with the poster avatar on it...... when ever i change my  profile avatar it takes 26 hours or more before the recent topic avatar change to the current profile avatar... HERE IS THE CODE, Please help me check the code and if there is any correction to make please let me know

here is my URL www.9jatechs.com
Code:
$(function(){
  var style = document.createElement('STYLE'), css = '.mini_ava2>img{height:50px;margin-right:5px;width:50px;}';
  style.type = 'text/css';
  if (style.styleSheet) style.styleSheet.cssText = css;
  else style.appendChild(document.createTextNode(css));
  document.getElementsByTagName('HEAD')[0].appendChild(style);
   
      if(!window.localStorage) return;
   
      // Default avatar
        var default_avatar= 'http://illiweb.com/fa/invision/pp-blank-thumb.png';
   
      // Time of cache 24h*60m*60s*1000ms - one day
        var caching_time= 24*60*60*1000;
   
      // Time of cache in case of error 60s*1000ms - one minute
        var caching_error= 60*1000;
   
      var set_avatar= function(id) {
            $('.mini_ava2.member'+id).html('<img src="'+get_avatar(id)+'" />');
        };
   
      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= {};
   
      $('#recentTopics a[href^="/u"]').each(function(){
            to_replace[$(this).attr('href').substr(2)]= 1;
            $(this).before('<span class="mini_ava2 member'+$(this).attr('href').substr(2)+'"></span>');
        });
   
      for(i in to_replace)
        {
            set_avatar(i);
        };
   
  });
avatar
Wolfuryo

Gender : Male
Posts : 250
Points : 1238
Reputation : 80
Language : Romanian and English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
Awards :
View all awards
View user profile

PostWolfuryo on Wed 16 Aug 2017, 09:44

You have to modify this part:
Code:
var caching_time= 24*60*60*1000;
24*60*60*1000 is the number of milliseconds a day has. If you want to disable this, replace it with 0.
avatar
snows
Member
Title :
Gender : Unspecified
Posts : 14
Points : 147
Reputation : 0
Language : English
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile

Postsnows on Wed 16 Aug 2017, 14:36

Hey @Wolfuryo please make the modification for me, i did it and it my self and it makes no effect
avatar
Wolfuryo

Gender : Male
Posts : 250
Points : 1238
Reputation : 80
Language : Romanian and English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
Awards :
View all awards
View user profile

PostWolfuryo on Wed 16 Aug 2017, 15:29

Code:
        $(function(){
          var style = document.createElement('STYLE'), css = '.mini_ava2>img{height:50px;margin-right:5px;width:50px;}';
          style.type = 'text/css';
          if (style.styleSheet) style.styleSheet.cssText = css;
          else style.appendChild(document.createTextNode(css));
          document.getElementsByTagName('HEAD')[0].appendChild(style);
         
              if(!window.localStorage) return;
         
              // Default avatar
                var default_avatar= 'http://illiweb.com/fa/invision/pp-blank-thumb.png';
         
              // Time of cache 24h*60m*60s*1000ms - one day
                var caching_time= 0;
         
              // Time of cache in case of error 60s*1000ms - one minute
                var caching_error= 60*1000;
         
              var set_avatar= function(id) {
                    $('.mini_ava2.member'+id).html('<img src="'+get_avatar(id)+'" />');
                };
         
              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= {};
         
              $('#recentTopics a[href^="/u"]').each(function(){
                    to_replace[$(this).attr('href').substr(2)]= 1;
                    $(this).before('<span class="mini_ava2 member'+$(this).attr('href').substr(2)+'"></span>');
                });
         
              for(i in to_replace)
                {
                    set_avatar(i);
                };
         
          });
avatar
snows
Member
Title :
Gender : Unspecified
Posts : 14
Points : 147
Reputation : 0
Language : English
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile

Postsnows on Wed 16 Aug 2017, 18:15

not okay still
avatar
Wolfuryo

Gender : Male
Posts : 250
Points : 1238
Reputation : 80
Language : Romanian and English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
Awards :
View all awards
View user profile

PostWolfuryo on Thu 17 Aug 2017, 16:20

Code:
$(function(){
/*By Justice. No reproduction without written consent from the author*/
if(!_userdata.session_logged_in) return;
var n=$(".js-marquee a:nth-child(2n)"), len=n.length;
var index=0;
function get_ava(i){
$.get(n.eq(i).attr("href"), function(data){
var ava=$("[alt='avatar']", data).eq(0).attr("src");
n.eq(i).after("<img style='width:50px;height:50px' src='"+ava+"'/>");
i++;
if(i==len) return;
get_ava(i);
})
}
get_ava(index);
})
avatar
snows
Member
Title :
Gender : Unspecified
Posts : 14
Points : 147
Reputation : 0
Language : English
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile

Postsnows on Fri 18 Aug 2017, 02:42

@Wolfuryo wrote:
Code:
$(function(){
/*By Justice. No reproduction without written consent from the author*/
if(!_userdata.session_logged_in) return;
var n=$(".js-marquee a:nth-child(2n)"), len=n.length;
var index=0;
function get_ava(i){
$.get(n.eq(i).attr("href"), function(data){
var ava=$("[alt='avatar']", data).eq(0).attr("src");
n.eq(i).after("<img style='width:50px;height:50px' src='"+ava+"'/>");
i++;
if(i==len) return;
get_ava(i);
})
}
get_ava(index);
})
hey,  this code worked fine,  but it disable other code in my forum
avatar
Wolfuryo

Gender : Male
Posts : 250
Points : 1238
Reputation : 80
Language : Romanian and English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
Awards :
View all awards
View user profile

PostWolfuryo on Fri 18 Aug 2017, 08:27

You have to remove the first code for this to run without problems.
avatar
snows
Member
Title :
Gender : Unspecified
Posts : 14
Points : 147
Reputation : 0
Language : English
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile

Postsnows on Mon 21 Aug 2017, 17:44

i removed the first Code, it works fine but disable some Javascript code , Like PostCard By @Ange Tuteur and much more
avatar
Wolfuryo

Gender : Male
Posts : 250
Points : 1238
Reputation : 80
Language : Romanian and English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
Awards :
View all awards
View user profile

PostWolfuryo on Tue 22 Aug 2017, 00:54

See if replacing the code with this solves the problem:
Code:
$(function(){
/*By Justice. No reproduction without written consent from the author*/
if(!_userdata.session_logged_in) return;
var n=$(".js-marquee a:nth-child(2n)"), len=n.length;
if(len==0) return;
var index=0;
function get_ava(i){
$.get(n.eq(i).attr("href"), function(data){
var ava=$("[alt='avatar']", data).eq(0).attr("src");
n.eq(i).after("<img style='width:50px;height:50px' src='"+ava+"'/>");
i++;
if(i==len) return;
get_ava(i);
})
}
get_ava(index);
})
avatar
snows
Member
Title :
Gender : Unspecified
Posts : 14
Points : 147
Reputation : 0
Language : English
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile

Postsnows on Tue 22 Aug 2017, 15:02

@Wolfuryo wrote:See if replacing the code with this solves the problem:
Code:
$(function(){
/*By Justice. No reproduction without written consent from the author*/
if(!_userdata.session_logged_in) return;
var n=$(".js-marquee a:nth-child(2n)"), len=n.length;
if(len==0) return;
var index=0;
function get_ava(i){
$.get(n.eq(i).attr("href"), function(data){
var ava=$("[alt='avatar']", data).eq(0).attr("src");
n.eq(i).after("<img style='width:50px;height:50px' src='"+ava+"'/>");
i++;
if(i==len) return;
get_ava(i);
})
}
get_ava(index);
})
Hey @Wolfuryo understand me ''this code work fine but it disable other functioning code in my forum

View previous topic View next topic Back to top

Create an account or log in to leave a reply

You need to be a member in order to leave a reply.

Create an account

Join our community by creating a new account. It's easy!


Create a new account

Log in

Already have an account? No problem, log in here.


Log in

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