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.

Reputation bar reset

View previous topic View next topic Go down

Solved Reputation bar reset

Post by Fierce Star on July 16th 2014, 9:05 pm

Hi,
I'm using the code from Add a bar for reputation with a few minor modifications, and am trying to make it so once a user gets to lv16 all the previous rep bars disappear, and they get a star in place of them. I have made it so they get the star, but I've tried several things and still I am unable to make the previously earned rep bars disappear.
Forum version: phpBB3
Codes being used:
Javascript
Code:
$(document).ready(function() {
  
    var version = 'phpbb3';

    var settings = {
      repName : 'Reputation',
      repStyle : 'block',
      repImage : 'http://i57.servimg.com/u/f57/18/21/41/30/star12.png'
    };
    var repLv = {
      lv1 : 1,
      lv2 : 2,
      lv3 : 3,
      lv4 : 4,
      lv5 : 5,
      lv6 : 6,
      lv7 : 7,
      lv8 : 8,
      lv9 : 9,
     lv10 : 10,
    lv11 : 11,
     lv12 : 12,
     lv13 : 13,
     lv14 : 14,
     lv15 : 15,
     lv16 : 16
    };
  
    if (settings.repStyle.toLowerCase() == 'block') { var repBlock = '<span id="rLv" class="repuBlock">' }
    else if (settings.repStyle.toLowerCase() == 'image') { var repBlock = '<img id="rLv" src="'+settings.repImage+'"/>' }
    else { var repBlock = '<span id="rLv" class="repuBlock">' }
    var ver = { phpbb2 : version.toLowerCase() == 'phpbb2', phpbb3 : version.toLowerCase() == 'phpbb3', punbb : version.toLowerCase() == 'punbb', invision : version.toLowerCase() == 'invision' };
    var reg = new RegExp('.*'+settings.repName+':\\s+(\\d+).*');
  
    if (ver.phpbb3 || ver.punbb || ver.invision) {
      if (ver.phpbb3 || ver.invision) { var profSel = '.postprofile'; var addRepu = $(this).find('dt').append('<div id="repu">'); }
      else if (ver.punbb) { var profSel = '.user'; var addRepu = $(this).find('.user-ident').prepend('<div id="repu">'); }
      $(profSel).each(function() {
          var rep = Number($(this).text().replace(reg,'$1'));
          addRepu;
          if (rep >= repLv["lv1"]) { $(this).find('#repu').append('<span class="repuBlock r1">') }
          if (rep >= repLv["lv2"]) { $(this).find('#repu').append('<span class="repuBlock r2">') }
          if (rep >= repLv["lv3"]) { $(this).find('#repu').append('<span class="repuBlock r3">') }
          if (rep >= repLv["lv4"]) { $(this).find('#repu').append('<span class="repuBlock r4">') }
          if (rep >= repLv["lv5"]) { $(this).find('#repu').append('<span class="repuBlock r5">') }
          if (rep >= repLv["lv6"]) { $(this).find('#repu').append('<span class="repuBlock r6">') }
          if (rep >= repLv["lv7"]) { $(this).find('#repu').append('<span class="repuBlock r7">') }
          if (rep >= repLv["lv8"]) { $(this).find('#repu').append('<span class="repuBlock r8">') }
          if (rep >= repLv["lv9"]) { $(this).find('#repu').append('<span class="repuBlock r9">') }
          if (rep >= repLv["lv10"]) { $(this).find('#repu').append('<span class="repuBlock r10">') }
          if (rep >= repLv["lv11"]) { $(this).find('#repu').append('<span class="repuBlock r11">') }
          if (rep >= repLv["lv12"]) { $(this).find('#repu').append('<span class="repuBlock r12">') }
          if (rep >= repLv["lv13"]) { $(this).find('#repu').append('<span class="repuBlock r13">') }
          if (rep >= repLv["lv14"]) { $(this).find('#repu').append('<span class="repuBlock r14">') }
          if (rep >= repLv["lv15"]) { $(this).find('#repu').append('<span class="repuBlock r15">') }
          if (rep >= repLv["lv16"]) { $(this).find('#repu').append('<img id="rLv" src="http://i57.servimg.com/u/f57/18/21/41/30/star12.png"/>') }
          if (rep >= repLv.lv16) { $(this).find('#repu').append(repBlock); var next = 'MAX' }
          $(this).find('#repu').attr('title','Reputation level ' + $(this).find('#rLv').length + '\nNext : (' + next + ')');
      });
    }
    else if (ver.phpbb2) {
      $('td .postdetails.poster-profile').each(function() {
          var rep = Number($(this).text().replace(reg,'$1'));
          $(this).parent().find('.name').next().after('<div id="repu">');
          if (rep >= repLv.lv1) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv2  }
          if (rep >= repLv.lv2) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv3  }
          if (rep >= repLv.lv3) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv4  }
          if (rep >= repLv.lv4) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv5  }
          if (rep >= repLv.lv5) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv6  }
          if (rep >= repLv.lv6) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv7  }
          if (rep >= repLv.lv7) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv8  }
          if (rep >= repLv.lv8) { $(this).parent().find('#repu').append(repBlock); var next = 'MAX'  }
          $(this).parent().find('#repu').attr('title','Reputation level ' + $(this).parent().find('#rLv').length  + '\nNext : (' + next + ')');
      });
    }
});
CSS
Code:
#repu { margin:1px 0; }
.repuBlock.r1,.repuBlock.r2, .repuBlock.r3, .repuBlock.r4, .repuBlock.r5 {
    height:8px;
    width:5px;
    background:#0A0;
    border:1px solid #080;
    border-radius:2px;
    box-shadow:0 3px 3px #0C0 inset;
    display:inline-block;
    margin:0 0.5px;
}
.repuBlock.r6,.repuBlock.r7, .repuBlock.r8, .repuBlock.r9, .repuBlock.r10 {
    height:8px;
    width:5px;
    background:#7FFF00;
    border:1px solid #080;
    border-radius:2px;
    box-shadow:0 3px 3px #0C0 inset;
    display:inline-block;
    margin:0 0.5px;
}

.repuBlock.r11,.repuBlock.r12, .repuBlock.r13, .repuBlock.r14, .repuBlock.r15 {
    height:8px;
    width:5px;
    background: #e5c100;
    border:1px solid #080;
    border-radius:2px;
      box-shadow:0 3px 3px #ffd700 inset;
    display:inline-block;
    margin:0 0.5px;
}

Thanks.


Last edited by Fierce Star on July 16th 2014, 9:16 pm; edited 1 time in total (Reason for editing : Solved)

Fierce Star
Forumember

Male Posts : 110
Reputation : 17
Language : English
Location : United States

http://inactivesite.onlyhelpwithothersnow.com

Back to top Go down

Solved Re: Reputation bar reset

Post by Ange Tuteur on July 16th 2014, 9:13 pm

Hello Fierce Star,

Try replacing your script by :
Code:
$(document).ready(function() {
  
    var version = 'phpbb3';

    var settings = {
      repName : 'Reputation',
      repStyle : 'block',
      repImage : 'http://i57.servimg.com/u/f57/18/21/41/30/star12.png'
    };
    var repLv = {
      lv1 : 1,
      lv2 : 2,
      lv3 : 3,
      lv4 : 4,
      lv5 : 5,
      lv6 : 6,
      lv7 : 7,
      lv8 : 8,
      lv9 : 9,
     lv10 : 10,
    lv11 : 11,
     lv12 : 12,
     lv13 : 13,
     lv14 : 14,
     lv15 : 15,
     lv16 : 16
    };
  
    if (settings.repStyle.toLowerCase() == 'block') { var repBlock = '<span id="rLv" class="repuBlock">' }
    else if (settings.repStyle.toLowerCase() == 'image') { var repBlock = '<img id="rLv" src="'+settings.repImage+'"/>' }
    else { var repBlock = '<span id="rLv" class="repuBlock">' }
    var ver = { phpbb2 : version.toLowerCase() == 'phpbb2', phpbb3 : version.toLowerCase() == 'phpbb3', punbb : version.toLowerCase() == 'punbb', invision : version.toLowerCase() == 'invision' };
    var reg = new RegExp('.*'+settings.repName+':\\s+(\\d+).*');
  
    if (ver.phpbb3 || ver.punbb || ver.invision) {
      if (ver.phpbb3 || ver.invision) { var profSel = '.postprofile'; var addRepu = $(this).find('dt').append('<div id="repu">'); }
      else if (ver.punbb) { var profSel = '.user'; var addRepu = $(this).find('.user-ident').prepend('<div id="repu">'); }
      $(profSel).each(function() {
          var rep = Number($(this).text().replace(reg,'$1'));
          addRepu;
          if (rep >= repLv["lv1"]) { $(this).find('#repu').append('<span class="repuBlock r1">') }
          if (rep >= repLv["lv2"]) { $(this).find('#repu').append('<span class="repuBlock r2">') }
          if (rep >= repLv["lv3"]) { $(this).find('#repu').append('<span class="repuBlock r3">') }
          if (rep >= repLv["lv4"]) { $(this).find('#repu').append('<span class="repuBlock r4">') }
          if (rep >= repLv["lv5"]) { $(this).find('#repu').append('<span class="repuBlock r5">') }
          if (rep >= repLv["lv6"]) { $(this).find('#repu').append('<span class="repuBlock r6">') }
          if (rep >= repLv["lv7"]) { $(this).find('#repu').append('<span class="repuBlock r7">') }
          if (rep >= repLv["lv8"]) { $(this).find('#repu').append('<span class="repuBlock r8">') }
          if (rep >= repLv["lv9"]) { $(this).find('#repu').append('<span class="repuBlock r9">') }
          if (rep >= repLv["lv10"]) { $(this).find('#repu').append('<span class="repuBlock r10">') }
          if (rep >= repLv["lv11"]) { $(this).find('#repu').append('<span class="repuBlock r11">') }
          if (rep >= repLv["lv12"]) { $(this).find('#repu').append('<span class="repuBlock r12">') }
          if (rep >= repLv["lv13"]) { $(this).find('#repu').append('<span class="repuBlock r13">') }
          if (rep >= repLv["lv14"]) { $(this).find('#repu').append('<span class="repuBlock r14">') }
          if (rep >= repLv["lv15"]) { $(this).find('#repu').append('<span class="repuBlock r15">') }
          if (rep >= repLv["lv16"]) { $(this).find('.repuBlock').remove(); $(this).find('#repu').append('<img id="rLv" src="http://i57.servimg.com/u/f57/18/21/41/30/star12.png"/>') }
          if (rep >= repLv.lv16) { $(this).find('#repu').append(repBlock); var next = 'MAX' }
          $(this).find('#repu').attr('title','Reputation level ' + $(this).find('#rLv').length + '\nNext : (' + next + ')');
      });
    }
    else if (ver.phpbb2) {
      $('td .postdetails.poster-profile').each(function() {
          var rep = Number($(this).text().replace(reg,'$1'));
          $(this).parent().find('.name').next().after('<div id="repu">');
          if (rep >= repLv.lv1) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv2  }
          if (rep >= repLv.lv2) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv3  }
          if (rep >= repLv.lv3) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv4  }
          if (rep >= repLv.lv4) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv5  }
          if (rep >= repLv.lv5) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv6  }
          if (rep >= repLv.lv6) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv7  }
          if (rep >= repLv.lv7) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv8  }
          if (rep >= repLv.lv8) { $(this).parent().find('#repu').append(repBlock); var next = 'MAX'  }
          $(this).parent().find('#repu').attr('title','Reputation level ' + $(this).parent().find('#rLv').length  + '\nNext : (' + next + ')');
      });
    }
});
(Removing the rep blocks on lv16 should work)

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2681
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Reputation bar reset

Post by Fierce Star on July 16th 2014, 9:17 pm

@Ange Tuteur wrote:Hello Fierce Star,

Try replacing your script by :
Code:
$(document).ready(function() {
  
    var version = 'phpbb3';

    var settings = {
      repName : 'Reputation',
      repStyle : 'block',
      repImage : 'http://i57.servimg.com/u/f57/18/21/41/30/star12.png'
    };
    var repLv = {
      lv1 : 1,
      lv2 : 2,
      lv3 : 3,
      lv4 : 4,
      lv5 : 5,
      lv6 : 6,
      lv7 : 7,
      lv8 : 8,
      lv9 : 9,
     lv10 : 10,
    lv11 : 11,
     lv12 : 12,
     lv13 : 13,
     lv14 : 14,
     lv15 : 15,
     lv16 : 16
    };
  
    if (settings.repStyle.toLowerCase() == 'block') { var repBlock = '<span id="rLv" class="repuBlock">' }
    else if (settings.repStyle.toLowerCase() == 'image') { var repBlock = '<img id="rLv" src="'+settings.repImage+'"/>' }
    else { var repBlock = '<span id="rLv" class="repuBlock">' }
    var ver = { phpbb2 : version.toLowerCase() == 'phpbb2', phpbb3 : version.toLowerCase() == 'phpbb3', punbb : version.toLowerCase() == 'punbb', invision : version.toLowerCase() == 'invision' };
    var reg = new RegExp('.*'+settings.repName+':\\s+(\\d+).*');
  
    if (ver.phpbb3 || ver.punbb || ver.invision) {
      if (ver.phpbb3 || ver.invision) { var profSel = '.postprofile'; var addRepu = $(this).find('dt').append('<div id="repu">'); }
      else if (ver.punbb) { var profSel = '.user'; var addRepu = $(this).find('.user-ident').prepend('<div id="repu">'); }
      $(profSel).each(function() {
          var rep = Number($(this).text().replace(reg,'$1'));
          addRepu;
          if (rep >= repLv["lv1"]) { $(this).find('#repu').append('<span class="repuBlock r1">') }
          if (rep >= repLv["lv2"]) { $(this).find('#repu').append('<span class="repuBlock r2">') }
          if (rep >= repLv["lv3"]) { $(this).find('#repu').append('<span class="repuBlock r3">') }
          if (rep >= repLv["lv4"]) { $(this).find('#repu').append('<span class="repuBlock r4">') }
          if (rep >= repLv["lv5"]) { $(this).find('#repu').append('<span class="repuBlock r5">') }
          if (rep >= repLv["lv6"]) { $(this).find('#repu').append('<span class="repuBlock r6">') }
          if (rep >= repLv["lv7"]) { $(this).find('#repu').append('<span class="repuBlock r7">') }
          if (rep >= repLv["lv8"]) { $(this).find('#repu').append('<span class="repuBlock r8">') }
          if (rep >= repLv["lv9"]) { $(this).find('#repu').append('<span class="repuBlock r9">') }
          if (rep >= repLv["lv10"]) { $(this).find('#repu').append('<span class="repuBlock r10">') }
          if (rep >= repLv["lv11"]) { $(this).find('#repu').append('<span class="repuBlock r11">') }
          if (rep >= repLv["lv12"]) { $(this).find('#repu').append('<span class="repuBlock r12">') }
          if (rep >= repLv["lv13"]) { $(this).find('#repu').append('<span class="repuBlock r13">') }
          if (rep >= repLv["lv14"]) { $(this).find('#repu').append('<span class="repuBlock r14">') }
          if (rep >= repLv["lv15"]) { $(this).find('#repu').append('<span class="repuBlock r15">') }
          if (rep >= repLv["lv16"]) { $(this).find('.repuBlock').remove(); $(this).find('#repu').append('<img id="rLv" src="http://i57.servimg.com/u/f57/18/21/41/30/star12.png"/>') }
          if (rep >= repLv.lv16) { $(this).find('#repu').append(repBlock); var next = 'MAX' }
          $(this).find('#repu').attr('title','Reputation level ' + $(this).find('#rLv').length + '\nNext : (' + next + ')');
      });
    }
    else if (ver.phpbb2) {
      $('td .postdetails.poster-profile').each(function() {
          var rep = Number($(this).text().replace(reg,'$1'));
          $(this).parent().find('.name').next().after('<div id="repu">');
          if (rep >= repLv.lv1) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv2  }
          if (rep >= repLv.lv2) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv3  }
          if (rep >= repLv.lv3) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv4  }
          if (rep >= repLv.lv4) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv5  }
          if (rep >= repLv.lv5) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv6  }
          if (rep >= repLv.lv6) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv7  }
          if (rep >= repLv.lv7) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv8  }
          if (rep >= repLv.lv8) { $(this).parent().find('#repu').append(repBlock); var next = 'MAX'  }
          $(this).parent().find('#repu').attr('title','Reputation level ' + $(this).parent().find('#rLv').length  + '\nNext : (' + next + ')');
      });
    }
});
(Removing the rep blocks on lv16 should work)
Thanks Ange, it worked.
Solved.

Fierce Star
Forumember

Male Posts : 110
Reputation : 17
Language : English
Location : United States

http://inactivesite.onlyhelpwithothersnow.com

Back to top Go down

Solved Re: Reputation bar reset

Post by SLGray on July 16th 2014, 9:36 pm

Topic Solved & Archived


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.


SLGray
Administrator
Administrator

Male Posts : 35613
Reputation : 2372
Language : English
Location : United States

http://fmthemes.forumotion.com/

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