FM Design
Would you like to react to this message? Create an account in a few clicks or log in to continue.

IMPORTANT

FM Design is in read-only mode, please click here for more information.

Latest topics
» Forumactif Edge - Releases
by Ange Tuteur Tue 03 Sep 2019, 11:49

» GIFActif - Giphy Button for the Editor
by Ange Tuteur Wed 08 May 2019, 17:21

» Forum Closure
by Ange Tuteur Mon 01 Jan 2018, 01:28

» Chit Chat Thread
by Valoish Sun 31 Dec 2017, 19:15

» Font/Text background color.
by Valoish Sun 31 Dec 2017, 19:11

» Forumactif Messenger - Instant Message Application for Forumotion
by Wolfuryo Sun 31 Dec 2017, 18:24

» [GAME] Count to One Million!
by brandon_g Fri 29 Dec 2017, 18:58

» Post Cards
by manikbiradar Wed 20 Dec 2017, 07:50

» [GAME] Countdown from 200,000
by Valoish Wed 13 Dec 2017, 23:22

» GeekPolice Tech Support Forums - GeekPolice.net
by Dr Jay Mon 11 Dec 2017, 19:12

» Asking about some plugin for Forumotion
by Dr Jay Mon 11 Dec 2017, 19:10

» [GAME] What are you thinking right now?
by Van-Helsing Sat 09 Dec 2017, 14:51

» Widget : Similar topics
by ranbac Wed 06 Dec 2017, 18:11

» Change the Background of the Forum and put an image and how to make prefixs?
by Clement Wed 06 Dec 2017, 15:19

» Hello from Western Australia
by SarkZKalie Wed 06 Dec 2017, 05:34

Recent Tutorials
Top posting users this month

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

None

[ View the whole list ]


Most users ever online was 515 on Tue 14 Sep 2021, 15:24

Recent Topic with Avatar problem

View previous topic View next topic Go down

snows
snows
Member
Gender : Unspecified
Posts : 14
Points : 2713
Reputation : 0
Language : English
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge

Postsnows 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://2img.net/i/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);
        };
   
  });
Wolfuryo
Wolfuryo

Gender : Male
Posts : 256
Points : 3811
Reputation : 81
Language : Romanian and English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other

PostWolfuryo 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.
snows
snows
Member
Gender : Unspecified
Posts : 14
Points : 2713
Reputation : 0
Language : English
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge

Postsnows 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
Wolfuryo
Wolfuryo

Gender : Male
Posts : 256
Points : 3811
Reputation : 81
Language : Romanian and English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other

PostWolfuryo 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://2img.net/i/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);
                };
         
          });
snows
snows
Member
Gender : Unspecified
Posts : 14
Points : 2713
Reputation : 0
Language : English
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge

Postsnows Wed 16 Aug 2017, 18:15

not okay still
Wolfuryo
Wolfuryo

Gender : Male
Posts : 256
Points : 3811
Reputation : 81
Language : Romanian and English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other

PostWolfuryo 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);
})
snows
snows
Member
Gender : Unspecified
Posts : 14
Points : 2713
Reputation : 0
Language : English
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge

Postsnows 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
Wolfuryo
Wolfuryo

Gender : Male
Posts : 256
Points : 3811
Reputation : 81
Language : Romanian and English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other

PostWolfuryo Fri 18 Aug 2017, 08:27

You have to remove the first code for this to run without problems.
snows
snows
Member
Gender : Unspecified
Posts : 14
Points : 2713
Reputation : 0
Language : English
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge

Postsnows 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
Wolfuryo
Wolfuryo

Gender : Male
Posts : 256
Points : 3811
Reputation : 81
Language : Romanian and English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other

PostWolfuryo 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);
})
snows
snows
Member
Gender : Unspecified
Posts : 14
Points : 2713
Reputation : 0
Language : English
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge

Postsnows 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
Sponsored content

PostSponsored content

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