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 code

View previous topic View next topic Go down

Solved Reputation code

Post by Pizza Boi on March 30th 2014, 1:58 pm

Hi Very Happy

So, I'm using Ange's reputation code and I've been reading this topic: http://help.forumotion.com/t131893-hide-this-field

I have the same problem as the OP, but there was no solution given and the one posted by Ange didn't work, can someone please help me remove the other reputation?

Test forum: http://tfpb.forumtl.com/

Regards,
Pizza Boi

Pizza Boi
Hyperactive

Male Posts : 2016
Reputation : 160
Language : French
Location : Pizza Hut!

http://redlustempire.forumtl.com/

Back to top Go down

Solved Re: Reputation code

Post by Ange Tuteur on March 30th 2014, 2:19 pm

Hello Pizza Boi,

You used this code :
Code:
$(document).ready(function() {
 
  var repName = 'Reputation';
  var repLv = {
  lv1 : 1,
  lv2 : 2,
  lv3 : 3,
  lv4 : 4,
  lv5 : 5,
  lv6 : 6,
  lv7 : 7,
  lv8 : 8
  };
  var repLvName = {
  lv1 : 'level 1',
  lv2 : 'level 2',
  lv3 : 'level 3',
  lv4 : 'level 4',
  lv5 : 'level 5',
  lv6 : 'level 6',
  lv7 : 'level 7',
  lv8 : 'level 8'
  };
 
  $('.user').each(function() {
  var reg = new RegExp ('.*'+repName+': (\\d+).*');
  var rep = Number($(this).text().replace(reg,'$1'));
  $(this).find('.label:contains('+repName+')').before('<div id="repu">');
  var reg2 = new RegExp ('<span class="label"><span style="color:#[0-9a-f]+;">'+repName+'</span>: </span>\\d+<br>','i');
  $(this).html($(this).html().replace(reg2,''));
  if (rep >= repLv["lv1"]) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv1) }
  if (rep >= repLv["lv2"]) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv2) }
  if (rep >= repLv["lv3"]) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv3) }
  if (rep >= repLv["lv4"]) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv4) }
  if (rep >= repLv["lv5"]) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv5) }
  if (rep >= repLv["lv6"]) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv6) }
  if (rep >= repLv["lv7"]) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv7) }
  if (rep >= repLv["lv8"]) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv8) }
  });
});

and filled in the variables with the values that correspond to your forum ? i.e. repName

I cannot see your rep field, but I tested another field and overwrote it without any problem.

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Reputation code

Post by Pizza Boi on March 30th 2014, 2:33 pm

Hi Very Happy

I actually don't know, and I didn't plan on posting the forum I'm working on but I guess I got no choice (Wanted it to be a surprise too, lol )

http://ygoda.forumtl.com/ There. I went yolo in the first topic so you can see the reputations there x.x.

Regards,
Pizza Boi

Pizza Boi
Hyperactive

Male Posts : 2016
Reputation : 160
Language : French
Location : Pizza Hut!

http://redlustempire.forumtl.com/

Back to top Go down

Solved Re: Reputation code

Post by Ange Tuteur on March 30th 2014, 2:37 pm

I cannot see t1 as a guest
ygoda.forumtl.com/t1-

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Reputation code

Post by Pizza Boi on March 30th 2014, 2:40 pm

Hi Very Happy

Sorry, was working on the CSS x.x... it should be okay now, just finished modifying the topics.

Regards,
Pizza Boi

Pizza Boi
Hyperactive

Male Posts : 2016
Reputation : 160
Language : French
Location : Pizza Hut!

http://redlustempire.forumtl.com/

Back to top Go down

Solved Re: Reputation code

Post by Ange Tuteur on March 30th 2014, 2:44 pm

Your labels are not using color, use this script instead :
Code:
$(document).ready(function() {
 
  var repName = 'Reputation';
  var repLv = {
  lv1 : 1,
  lv2 : 2,
  lv3 : 3,
  lv4 : 4,
  lv5 : 5,
  lv6 : 6,
  lv7 : 7,
  lv8 : 8
  };
  var repLvName = {
  lv1 : 'level 1',
  lv2 : 'level 2',
  lv3 : 'level 3',
  lv4 : 'level 4',
  lv5 : 'level 5',
  lv6 : 'level 6',
  lv7 : 'level 7',
  lv8 : 'level 8'
  };
 
  $('.user').each(function() {
  var reg = new RegExp ('.*'+repName+': (\\d+).*');
  var rep = Number($(this).text().replace(reg,'$1'));
  $(this).find('.label:contains('+repName+')').before('<div id="repu">');
  var reg2 = new RegExp ('<span class="label">'+repName+': </span>\\d+<br>','i');
  $(this).html($(this).html().replace(reg2,''));
  if (rep < repLv.lv1) { $(this).find('#repu').html('Reputation: '+rep+'<br>No reputation') }
  if (rep >= repLv.lv1) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv1) }
  if (rep >= repLv.lv2) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv2) }
  if (rep >= repLv.lv3) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv3) }
  if (rep >= repLv.lv4) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv4) }
  if (rep >= repLv.lv5) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv5) }
  if (rep >= repLv.lv6) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv6) }
  if (rep >= repLv.lv7) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv7) }
  if (rep >= repLv.lv8) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv8) }
  });
});

I also added a condition for users with rep less than lv1.

EDIT :
oh, right I forgot to include a variable for the lv0 name, use this one instead Razz:
Code:
$(document).ready(function() {
 
  var repName = 'Reputation';
  var repLv = {
  lv1 : 1,
  lv2 : 2,
  lv3 : 3,
  lv4 : 4,
  lv5 : 5,
  lv6 : 6,
  lv7 : 7,
  lv8 : 8
  };
  var repLvName = {
  lv0 : 'level 0',
  lv1 : 'level 1',
  lv2 : 'level 2',
  lv3 : 'level 3',
  lv4 : 'level 4',
  lv5 : 'level 5',
  lv6 : 'level 6',
  lv7 : 'level 7',
  lv8 : 'level 8'
  };
 
  $('.user').each(function() {
  var reg = new RegExp ('.*'+repName+': (\\d+).*');
  var rep = Number($(this).text().replace(reg,'$1'));
  $(this).find('.label:contains('+repName+')').before('<div id="repu">');
  var reg2 = new RegExp ('<span class="label">'+repName+': </span>\\d+<br>','i');
  $(this).html($(this).html().replace(reg2,''));
  if (rep < repLv.lv1) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv0) }
  if (rep >= repLv.lv1) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv1) }
  if (rep >= repLv.lv2) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv2) }
  if (rep >= repLv.lv3) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv3) }
  if (rep >= repLv.lv4) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv4) }
  if (rep >= repLv.lv5) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv5) }
  if (rep >= repLv.lv6) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv6) }
  if (rep >= repLv.lv7) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv7) }
  if (rep >= repLv.lv8) { $(this).find('#repu').html('Reputation: '+rep+'<br>'+repLvName.lv8) }
  });
});

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Reputation code

Post by Pizza Boi on March 30th 2014, 2:52 pm

Hi Very Happy

So I just have to change the other variables to the ones I like, huh. I can just adjust the position depending on the hierarchy and stuff or I'll do something else but I got that part figured out Smile .

Thanks, Ange! This is solved Smile .

Regards,
Pizza Boi

Pizza Boi
Hyperactive

Male Posts : 2016
Reputation : 160
Language : French
Location : Pizza Hut!

http://redlustempire.forumtl.com/

Back to top Go down

Solved Re: Reputation code

Post by Ange Tuteur on March 30th 2014, 3:05 pm

You're welcome :rose:

var repLv = {
lv1 : is the amount of rep to achieve this level
}

var repLvName = {
lv1 : is the name achieved on this level
}

Topic solved and archived

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.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