Latest topics
» [GAME] Count to 999 using odd numbers Van-Helsing Edition
by Van-Helsing Yesterday at 16:03

» [GAME] Count to 1000 using even numbers Van-Helsing Edition
by Van-Helsing Yesterday at 16:03

» [GAME] Count to One Million!
by Van-Helsing Yesterday at 16:02

» [GAME] Count to 30 - Ange Edition
by Van-Helsing Yesterday at 16:01

» Is there any new update for ForumActif Edge?
by Van-Helsing Yesterday at 16:01

» Add a login popup for the toolbar
by Ape Sun 24 Sep 2017, 17:26

» [GAME] Post a random picture
by SLGray Fri 22 Sep 2017, 19:23

» Topic'It
by Ange Tuteur Fri 22 Sep 2017, 10:06

» Topic'It
by SLGray Thu 21 Sep 2017, 15:52

» FM Themes
by SLGray Thu 21 Sep 2017, 15:51

» User - Made Creations
by SLGray Thu 21 Sep 2017, 15:50

» IconSkouliki
by skouliki Sun 17 Sep 2017, 11:05

» Awards
by Mr_Grande Sun 17 Sep 2017, 08:52

» Modify Category Tabs lead to a desired position and auto scroll click
by djblah Fri 15 Sep 2017, 14:56

» Display a preview of the user profile on hover
by Eiki Thu 14 Sep 2017, 02:38

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

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 : 13
Points : 93
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 : 249
Points : 1183
Reputation : 79
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 : 13
Points : 93
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 : 249
Points : 1183
Reputation : 79
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 : 13
Points : 93
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 : 249
Points : 1183
Reputation : 79
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 : 13
Points : 93
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 : 249
Points : 1183
Reputation : 79
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 : 13
Points : 93
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 : 249
Points : 1183
Reputation : 79
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 : 13
Points : 93
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