[Tutorial] Reputation Levels
Page 2 of 2 • Share •
Page 2 of 2 • 1, 2
[Tutorial] Reputation Levels
First topic message reminder :
With this code you can customize the reputation profile by adding levels according to the reputation number.

Create a new JavaScript code with the following content (The placement "In topics" only):

With this code you can customize the reputation profile by adding levels according to the reputation number.

Create a new JavaScript code with the following content (The placement "In topics" only):
- Code:
/*
* Application: Reputation Levels
* Date: 20/04/2018
* Version: 1.220042018
* Copyright (c) 2018 Daemon <help.forumotion.com>
* This work is free. You can redistribute it and/or modify it
*/
function bs_reputation_ipb() {
/*
* Configure below the levels for the reputation profile,
* with the respective number needed to win it.
* You can also add a class to customize the element.
*/
var reputation = [
{
reputation: 0,
level: "Neutral",
class: "zero"
},
{
reputation: 1,
level: "Beginner"
},
{
reputation: 10,
level: "Regular"
},
{
reputation: 20,
level: "Good"
},
{
reputation: 35,
level: "Great"
},
{
reputation: 50,
level: "Excellent",
class: "awesome"
}
];
/*
* No need to change anything from here down
*/
var userLink = null,
repField = null,
repFieldName = null,
repFieldValue= null,
regExp = null,
level = "",
repClass = "",
BreakException = {};
jQuery.each(jQuery(".post"), function(i, post) {
userLink = jQuery(post).find("a[href^='/u']").attr("href");
jQuery.ajax({
type: "GET",
url: userLink,
success: function(data) {
repField = jQuery("#field_id-14", data);
repFieldName = repField.find("dt").text().split(" ")[0];
repFieldValue = parseInt(repField.find("dd").text());
regExp = new RegExp("<span[^>]*>(?:<span[^>]*>)?(" + repFieldName + ")(?:<\\/span>)?\\s:\\s<\\/span>\\s*(\\d+)", "g");
try {
jQuery.each(reputation, function(key, val) {
if (val.reputation <= repFieldValue) {
level = (val.level) ? val.level : "";
repClass = (val.class) ? " " + val.class : "";
} else {
throw BreakException;
}
});
} catch (e) {
if (e !== BreakException) throw e;
}
jQuery(post).find(".label").parent().html(function(key, val) {
return jQuery(this).html().replace(regExp,"<div class='reputation_bs" + repClass + "'>$1 : $2<br><span class='title' style='font-weight:normal'>" + level + "</span></div>")
});
},
error: function(jqXHR, textStatus, errorThrown) {
console.log("**An error occurred while trying to request the data (Application: Reputation Levels)");
}
});
});
};
jQuery(function() {
bs_reputation_ipb();
});
- Code:
.reputation_bs {
background-color: #DFF0D8;
font-weight: bold;
padding: 3px 8px;
display: block !important;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
color: #3C763D;
margin: 5px auto;
font-family: Lato,Arial,Helvetica,sans-serif;
font-size: 13px;
margin-bottom: 5px;
max-width: 123px;
text-align: center;
}
.reputation_bs.zero {
background: none repeat scroll 0% 0% rgba(222, 222, 222, 0.34);
color: #6e6e6e;
}

Last edited by Daemon on April 20th 2018, 11:05 pm; edited 8 times in total
Daemon- Forumember
- Posts : 74
Reputation : 63
Language : Português
Re: [Tutorial] Reputation Levels
AP > Modules > Points/Reputation > Reputation

Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

Re: [Tutorial] Reputation Levels
You're welcome.

Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

Re: [Tutorial] Reputation Levels
I made a little modification in the code!
Daemon- Forumember
- Posts : 74
Reputation : 63
Language : Português
Page 2 of 2 • 1, 2
Page 2 of 2
Permissions in this forum:
You cannot reply to topics in this forum