[Tutorial] Reputation Levels
4 posters
Page 1 of 2
Page 1 of 2 • 1, 2
[Tutorial] Reputation Levels
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):
Create a new JavaScript code with the following content (The placement "In topics" only):
- Code:
/*
* Application: Reputation Levels
* Date: 14/06/2018
* Version: 2.014062018
* 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 post = $(".post"),
level = "",
repClass = "",
BreakException = {};
$.ajax({
url: post.first().find("a[href^='/u']").attr("href"),
type: "GET",
success: function(data) {
var fieldName = $("#field_id-14", data).find("dt").text().split(" ")[0],
regExp = RegExp("<span[^>]*>(?:<span[^>]*>)?(" + fieldName + ")(?:<\\/span>)?\\s:\\s<\\/span>\\s*(\\d+)", "g");
$.each($(".post"), function(idx) {
$(this).html(
$(this).html()
.replace(regExp, "<div class='reputation-bs'>$1 : $2<br><span class='title' style='font-weight:normal'></span></div>")
);
var repDiv = $(".reputation-bs", this),
fieldValue = repDiv.text().match(/\d+/);
try {
$.each(reputation, function(i, item) {
if (item.reputation <= fieldValue) {
level = (item.level) ? item.level : "",
repClass = (item.class) ? item.class : "";
} else {
throw BreakException;
}
});
} catch (e) {
if (e !== BreakException) throw e;
}
repDiv.addClass(repClass).find(".title").text(level);
});
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
});
};
$(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 June 25th 2018, 8:03 pm; edited 15 times in total
Daemon- Forumember
- Posts : 104
Reputation : 91
Language : Português
Re: [Tutorial] Reputation Levels
I made a small change to the current code. :p
Daemon- Forumember
- Posts : 104
Reputation : 91
Language : Português
Re: [Tutorial] Reputation Levels
You need to state where the placement is for the JavaScripts in your tutorials.
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
SLGray wrote:You need to state where the placement is for the JavaScripts in your tutorials.
Done! I made another small change.
Daemon- Forumember
- Posts : 104
Reputation : 91
Language : Português
Re: [Tutorial] Reputation Levels
Should I remove the old code I use?
- Code:
$(document).ready(function() {
var version = 'phpBB2';
var settings = {
repName : 'Reputation',
repStyle : 'block',
repImage : 'http://i57.servimg.com/u/f57/18/21/41/30/star12.png'
};
var repLv = {
lv1 : 1,
lv2 : 20,
lv3 : 30,
lv4 : 40,
lv5 : 50,
lv6 : 60,
lv7 : 70,
lv8 : 80,
lv9 : 90,
lv10 : 200
};
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', modernbb : version.toLowerCase() == 'modernbb' };
var reg = new RegExp('.*'+settings.repName+'\\s+:\\s+(\\d+).*');
if (ver.phpbb3 || ver.punbb || ver.invision || ver.modernbb) {
if (ver.phpbb3 || ver.invision || ver.modernbb) { 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(repBlock); var next = rep + '/' + repLv.lv2 }
if (rep >= repLv.lv2) { $(this).find('#repu').append(repBlock); var next = rep + '/' + repLv.lv3 }
if (rep >= repLv.lv3) { $(this).find('#repu').append(repBlock); var next = rep + '/' + repLv.lv4 }
if (rep >= repLv.lv4) { $(this).find('#repu').append(repBlock); var next = rep + '/' + repLv.lv5 }
if (rep >= repLv.lv5) { $(this).find('#repu').append(repBlock); var next = rep + '/' + repLv.lv6 }
if (rep >= repLv.lv6) { $(this).find('#repu').append(repBlock); var next = rep + '/' + repLv.lv7 }
if (rep >= repLv.lv7) { $(this).find('#repu').append(repBlock); var next = rep + '/' + repLv.lv8 }
if (rep >= repLv.lv8) { $(this).find('#repu').append(repBlock); var next = rep + '/' + repLv.lv9 }
if (rep >= repLv.lv9) { $(this).find('#repu').append(repBlock); var next = rep + '/' + repLv.lv10 }
if (rep >= repLv.lv10) { $(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 = rep + '/' + repLv.lv9 }
if (rep >= repLv.lv9) { $(this).parent().find('#repu').append(repBlock); var next = rep + '/' + repLv.lv10 }
if (rep >= repLv.lv10) { $(this).parent().find('#repu').append(repBlock); var next = 'MAX' }
$(this).parent().find('#repu').attr('title','Ниво на репутация ' + $(this).parent().find('#rLv').length + '\nСледващo ниво: (' + next + ')');
});
}
});
Re: [Tutorial] Reputation Levels
These codes are different. The effect of the result is on the image in the topic.
Daemon- Forumember
- Posts : 104
Reputation : 91
Language : Português
Re: [Tutorial] Reputation Levels
I AM YOUR CODE, BUT Nothing Happens? Here's a link to my test forum.
http://vracatestforum.bulgarianforum.net/t18-topic
http://vracatestforum.bulgarianforum.net/t18-topic
Re: [Tutorial] Reputation Levels
Try that:
- Code:
/*
* Application: Reputation Levels
* Date: 19/05/2017
* Version: 1.219072017
* Copyright (c) 2017 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 arrConfig = [
{
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, repField, repFieldName, repFieldValue, regExp, level, repClass;
var BreakException = {};
jQuery.each(jQuery(".post"), function(i, val) {
var thisPost = jQuery(val);
userLink = thisPost.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 class=\"label\">(?:<span style=\"[^\"]*\">)?" + repFieldName + "(?:<\\/span>)?\\s:\\s<\\/span>\\s\\d+)", "g");
try {
jQuery.each(arrConfig, function(i, 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;
}
thisPost.find(".label").parent().html(function(i, val) {
return val.replace(regExp, "<div class='reputation_bs" + repClass + "'>$1<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");
}
});
});
};
jQuery(function() {
bs_reputation_ipb();
});
Daemon- Forumember
- Posts : 104
Reputation : 91
Language : Português
Re: [Tutorial] Reputation Levels
Now it works. Can you increase the reputation to 100?
reputation: 65
reputation: 75
reputation: 90
reputation: 100
- Code:
/*
* Application: Reputation Levels
* Date: 19/05/2017
* Version: 1.219072017
* Copyright (c) 2017 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 arrConfig = [
{
reputation: 0,
level: "Neutral",
class: "Потребител"
},
{
reputation: 1,
level: "Начинаещ"
},
{
reputation: 10,
level: "Редовен потребител"
},
{
reputation: 20,
level: "Фен"
},
{
reputation: 35,
level: "Напредващ"
},
{
reputation: 50,
level: "HL маняк",
class: "awesome"
}
];
/*
* No need to change anything from here down
*/
var userLink, repField, repFieldName, repFieldValue, regExp, level, repClass;
var BreakException = {};
jQuery.each(jQuery(".post"), function(i, val) {
var thisPost = jQuery(val);
userLink = thisPost.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 class=\"label\">(?:<span style=\"[^\"]*\">)?" + repFieldName + "(?:<\\/span>)?\\s:\\s<\\/span>\\s\\d+)", "g");
try {
jQuery.each(arrConfig, function(i, 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;
}
thisPost.find(".label").parent().html(function(i, val) {
return val.replace(regExp, "<div class='reputation_bs" + repClass + "'>$1<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");
}
});
});
};
jQuery(function() {
bs_reputation_ipb();
});
reputation: 65
reputation: 75
reputation: 90
reputation: 100
Re: [Tutorial] Reputation Levels
See how the structure works:
- Code:
{
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"
}
Reputation: equals the required number of reputations to reach the level.
Level: The name of the level equivalent to the number of reputations.
Class: add an optional class to customize the reputation element.
Daemon- Forumember
- Posts : 104
Reputation : 91
Language : Português
Re: [Tutorial] Reputation Levels
Can you do that code from my previous post? I will not be able to do it because I do not understand English well.
Where can I change the caption from the photo?
Where can I change the caption from the photo?
Re: [Tutorial] Reputation Levels
smurfavr wrote:Can you do that code from my previous post? I will not be able to do it because I do not understand English well.
Where can I change the caption from the photo?
up
Re: [Tutorial] Reputation Levels
Daemon wrote:See how the structure works:Each new entry starts with this -> '{' and ends with this -> '}'. Always with a comma at the end, except for the last entry.
- Code:
{
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"
}Reputation: equals the required number of reputations to reach the level.
Level: The name of the level equivalent to the number of reputations.
Class: add an optional class to customize the reputation element.
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
smurfavr wrote:I will not be able to do it because I do not understand English well.
Re: [Tutorial] Reputation Levels
Do not Google translate well enough for you to understand what to do?
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
Yes.SLGray wrote:Do not Google translate well enough for you to understand what to do?
Re: [Tutorial] Reputation Levels
smurfavr wrote:smurfavr wrote:Can you do that code from my previous post? I will not be able to do it because I do not understand English well.
Where can I change the caption from the photo?
up
Re: [Tutorial] Reputation Levels
smurfavr wrote:smurfavr wrote:smurfavr wrote:Can you do that code from my previous post? I will not be able to do it because I do not understand English well.
Where can I change the caption from the photo?
up
Re: [Tutorial] Reputation Levels
- Code:
/*
* Application: Reputation Levels
* Date: 19/05/2017
* Version: 1.219072017
* Copyright (c) 2017 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 arrConfig = [
{
reputation: 0,
level: "Neutral",
class: "zero"
},
{
reputation: 65,
level: "Beginner"
},
{
reputation: 75,
level: "Regular"
},
{
reputation: 90,
level: "Good"
},
{
reputation: 100,
level: "Great"
},
{
reputation: 50,
level: "Excellent",
class: "awesome"
}
];
/*
* No need to change anything from here down
*/
var userLink, repField, repFieldName, repFieldValue, regExp, level, repClass;
var BreakException = {};
jQuery.each(jQuery(".post"), function(i, val) {
var thisPost = jQuery(val);
userLink = thisPost.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 class=\"label\">(?:<span style=\"[^\"]*\">)?" + repFieldName + "(?:<\\/span>)?\\s:\\s<\\/span>\\s\\d+)", "g");
try {
jQuery.each(arrConfig, function(i, 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;
}
thisPost.find(".label").parent().html(function(i, val) {
return val.replace(regExp, "<div class='reputation_bs" + repClass + "'>$1<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");
}
});
});
};
jQuery(function() {
bs_reputation_ipb();
});
Guest- Guest
Re: [Tutorial] Reputation Levels
I intended to add these numbers to the others.
0,1,10,20,35,50.65......
reputation: 65
reputation: 75
reputation: 90
If you can add them to this code I've given. At the new line item level, write xxx I will add names.
reputation: 100
0,1,10,20,35,50.65......
reputation: 65
reputation: 75
reputation: 90
If you can add them to this code I've given. At the new line item level, write xxx I will add names.
- Code:
/*
* Application: Reputation Levels
* Date: 19/05/2017
* Version: 1.219072017
* Copyright (c) 2017 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 arrConfig = [
{
reputation: 0,
level: "Neutral",
class: "Потребител"
},
{
reputation: 1,
level: "Начинаещ"
},
{
reputation: 10,
level: "Редовен потребител"
},
{
reputation: 20,
level: "Фен"
},
{
reputation: 35,
level: "Напредващ"
},
{
reputation: 50,
level: "HL маняк",
class: "awesome"
}
];
/*
* No need to change anything from here down
*/
var userLink, repField, repFieldName, repFieldValue, regExp, level, repClass;
var BreakException = {};
jQuery.each(jQuery(".post"), function(i, val) {
var thisPost = jQuery(val);
userLink = thisPost.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 class="label">(?:<span style="[^"]*">)?" + repFieldName + "(?:<\\/span>)?\\s:\\s<\\/span>\\s\\d+)", "g");
try {
jQuery.each(arrConfig, function(i, 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;
}
thisPost.find(".label").parent().html(function(i, val) {
return val.replace(regExp, "<div class='reputation_bs" + repClass + "'>$1<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");
}
});
});
};
jQuery(function() {
bs_reputation_ipb();
});
reputation: 100
Re: [Tutorial] Reputation Levels
- Code:
/*
* Application: Reputation Levels
* Date: 19/05/2017
* Version: 1.219072017
* Copyright (c) 2017 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 arrConfig = [
{
reputation: 0,
level: "Neutral",
class: "??????????"
},
{
reputation: 1,
level: "????????"
},
{
reputation: 10,
level: "??????? ??????????"
},
{
reputation: 20,
level: "???"
},
{
reputation: 35,
level: "?????????"
},
{
reputation: 50,
level: "HL ?????"
},
{
reputation: 65,
level: "HL ?????"
},
{
reputation: 75,
level: "HL ?????"
},
{
reputation: 90,
level: "HL ?????"
},
{
reputation: 100,
level: "HL ?????"
}
];
/*
* No need to change anything from here down
*/
var userLink, repField, repFieldName, repFieldValue, regExp, level, repClass;
var BreakException = {};
jQuery.each(jQuery(".post"), function(i, val) {
var thisPost = jQuery(val);
userLink = thisPost.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 class="label">(?:<span style="[^"]*">)?" + repFieldName + "(?:<\\/span>)?\\s:\\s<\\/span>\\s\\d+)", "g");
try {
jQuery.each(arrConfig, function(i, 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;
}
thisPost.find(".label").parent().html(function(i, val) {
return val.replace(regExp, "<div class='reputation_bs" + repClass + "'>$1<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");
}
});
});
};
jQuery(function() {
bs_reputation_ipb();
});
Guest- Guest
Re: [Tutorial] Reputation Levels
Wolfuryo
I put the code, but I do not work.
I put the code, but I do not work.
- Code:
/*
* Application: Reputation Levels
* Date: 19/05/2017
* Version: 1.219072017
* Copyright (c) 2017 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 arrConfig = [
{
reputation: 0,
level: "Neutral",
class: "Потребител"
},
{
reputation: 1,
level: "Начинаещ"
},
{
reputation: 10,
level: "Редовен потребител"
},
{
reputation: 20,
level: "Фен"
},
{
reputation: 35,
level: "Напредващ"
},
{
reputation: 50,
level: "HL маняк"
},
{
reputation: 65,
level: "Пристрастен"
},
{
reputation: 75,
level: "Разбирач"
},
{
reputation: 90,
level: "VIP"
},
{
reputation: 100,
level: "HL постер"
}
];
/*
* No need to change anything from here down
*/
var userLink, repField, repFieldName, repFieldValue, regExp, level, repClass;
var BreakException = {};
jQuery.each(jQuery(".post"), function(i, val) {
var thisPost = jQuery(val);
userLink = thisPost.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 class="label">(?:<span style="[^"]*">)?" + repFieldName + "(?:<\\/span>)?\\s:\\s<\\/span>\\s\\d+)", "g");
try {
jQuery.each(arrConfig, function(i, 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;
}
thisPost.find(".label").parent().html(function(i, val) {
return val.replace(regExp, "<div class='reputation_bs" + repClass + "'>$1<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");
}
});
});
};
jQuery(function() {
bs_reputation_ipb();
});
Re: [Tutorial] Reputation Levels
Hmm, I don't see anything wrong at the code. What your forum's link?
Guest- Guest
Re: [Tutorial] Reputation Levels
This is my test forum.
http://vracatestforum.bulgarianforum.net/t52-topic#210
psp
Something happened because I tried and the original code did not work.
http://vracatestforum.bulgarianforum.net/t52-topic#210
psp
Something happened because I tried and the original code did not work.
Re: [Tutorial] Reputation Levels
- Code:
/*
* Application: Reputation Levels
* Date: 19/05/2017
* Version: 1.219072017
* Copyright (c) 2017 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 arrConfig = [
{
reputation: 0,
level: "Neutral",
class: "Потребител"
},
{
reputation: 1,
level: "Начинаещ"
},
{
reputation: 10,
level: "Редовен потребител"
},
{
reputation: 20,
level: "Фен"
},
{
reputation: 35,
level: "Напредващ"
},
{
reputation: 50,
level: "HL маняк"
},
{
reputation: 65,
level: "Пристрастен"
},
{
reputation: 75,
level: "Разбирач"
},
{
reputation: 90,
level: "VIP"
},
{
reputation: 100,
level: "HL постер"
}
];
/*
* No need to change anything from here down
*/
var userLink, repField, repFieldName, repFieldValue, regExp, level, repClass;
var BreakException = {};
jQuery.each(jQuery(".post"), function(i, val) {
var thisPost = jQuery(val);
userLink = thisPost.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 class=\"label\">(?:<span style=\"[^\"]*\">)?" + repFieldName + "(?:<\\/span>)?\\s:\\s<\\/span>\\s\\d+)", "g");
try {
jQuery.each(arrConfig, function(i, 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;
}
thisPost.find(".label").parent().html(function(i, val) {
return val.replace(regExp, "<div class='reputation_bs" + repClass + "'>$1<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");
}
});
});
};
jQuery(function() {
bs_reputation_ipb();
});
Guest- Guest
Re: [Tutorial] Reputation Levels
Thanks now works.
How do I change the caption from the photo in my previous post?
How do I change the caption from the photo in my previous post?
Re: [Tutorial] Reputation Levels
Replace the script with:
At the end of the code, look for this:
Change Reputation to whatever you want.
- Code:
/*
* Application: Reputation Levels
* Date: 19/05/2017
* Version: 1.219072017
* Copyright (c) 2017 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 arrConfig = [{
reputation: 0,
level: "Neutral",
class: "Потребител"
}, {
reputation: 1,
level: "Начинаещ"
}, {
reputation: 10,
level: "Редовен потребител"
}, {
reputation: 20,
level: "Фен"
}, {
reputation: 35,
level: "Напредващ"
}, {
reputation: 50,
level: "HL маняк"
}, {
reputation: 65,
level: "Пристрастен"
}, {
reputation: 75,
level: "Разбирач"
}, {
reputation: 90,
level: "VIP"
}, {
reputation: 100,
level: "HL постер"
}];
/*
* No need to change anything from here down
*/
var userLink, repField, repFieldName, repFieldValue, regExp, level, repClass;
var BreakException = {};
jQuery.each(jQuery(".post"), function(i, val) {
var thisPost = jQuery(val);
userLink = thisPost.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 class=\"label\">(?:<span style=\"[^\"]*\">)?" + repFieldName + "(?:<\\/span>)?\\s:\\s<\\/span>\\s\\d+)", "g");
try {
jQuery.each(arrConfig, function(i, 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;
}
thisPost.find(".label").parent().html(function(i, val) {
return val.replace(regExp, "<div class='reputation_bs" + repClass + "'>$1<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");
}
});
});
};
jQuery(function() {
bs_reputation_ipb();
var rep = $(".reputation_bs>span.label>span");
if (rep) rep.text("Reputation");
});
At the end of the code, look for this:
|
Guest- Guest
Re: [Tutorial] Reputation Levels
I changed the code, but the caption did not change.
- Code:
/*
* Application: Reputation Levels
* Date: 19/05/2017
* Version: 1.219072017
* Copyright (c) 2017 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 arrConfig = [{
reputation: 0,
level: "Neutral",
class: "Потребител"
}, {
reputation: 1,
level: "Начинаещ"
}, {
reputation: 10,
level: "Редовен потребител"
}, {
Репутация: 20,
level: "Фен"
}, {
reputation: 35,
level: "Напредващ"
}, {
reputation: 50,
level: "HL маняк"
}, {
reputation: 65,
level: "Пристрастен"
}, {
reputation: 75,
level: "Разбирач"
}, {
reputation: 90,
level: "VIP"
}, {
reputation: 100,
level: "HL постер"
}];
/*
* No need to change anything from here down
*/
var userLink, repField, repFieldName, repFieldValue, regExp, level, repClass;
var BreakException = {};
jQuery.each(jQuery(".post"), function(i, val) {
var thisPost = jQuery(val);
userLink = thisPost.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 class="label">(?:<span style="[^"]*">)?" + repFieldName + "(?:<\\/span>)?\\s:\\s<\\/span>\\s\\d+)", "g");
try {
jQuery.each(arrConfig, function(i, 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;
}
thisPost.find(".label").parent().html(function(i, val) {
return val.replace(regExp, "<div class='reputation_bs" + repClass + "'>$1<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");
}
});
});
};
jQuery(function() {
bs_reputation_ipb();
var rep = $(".reputation_bs>span.label>span");
if (rep) rep.text("Репутация");
});
Page 1 of 2 • 1, 2
Similar topics
» How do I get sub levels on the forum
» Different Levels of access to the Admin panel
» [Tutorial] CKEditor
» Sub-levels (subform) - how to put the word in front of the sub level links?
» How can i put a tutorial on here?
» Different Levels of access to the Admin panel
» [Tutorial] CKEditor
» Sub-levels (subform) - how to put the word in front of the sub level links?
» How can i put a tutorial on here?
Page 1 of 2
Permissions in this forum:
You cannot reply to topics in this forum