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.

[Tutorial] Reputation Levels

Page 1 of 2 1, 2  Next

View previous topic View next topic Go down

[Tutorial] Reputation Levels

Post by Daemon on July 20th 2017, 6:59 am

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: 19/05/2017
 *  Version: 1.220072017
 *  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>\\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();
});
Add the following in your css style sheet:
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;
}
The instructions are inside the code.
Wink


Last edited by Daemon on July 20th 2017, 6:23 pm; edited 2 times in total
avatar
Daemon
Forumember

Posts : 51
Reputation : 27
Language : Português

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by Daemon on July 20th 2017, 5:37 pm

I made a small change to the current code. :p
avatar
Daemon
Forumember

Posts : 51
Reputation : 27
Language : Português

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by TonnyKamper on July 20th 2017, 6:02 pm

Awesome @Deamon thank you Yes
avatar
TonnyKamper
Forumember

Female Posts : 71
Reputation : 8
Language : Dutch/English
Location : The Netherlands

http://test-tube.actieforum.com/

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by SLGray on July 20th 2017, 6:09 pm

You need to state where the placement is for the JavaScripts in your tutorials.


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

avatar
SLGray
Administrator
Administrator

Male Posts : 39639
Reputation : 2666
Language : English
Location : United States

https://fmthemes.forumotion.com/

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by Daemon on July 20th 2017, 6:24 pm

@SLGray wrote:You need to state where the placement is for the JavaScripts in your tutorials.

Done! I made another small change.
avatar
Daemon
Forumember

Posts : 51
Reputation : 27
Language : Português

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by smurfavr on July 23rd 2017, 4:51 pm

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 + ')');
                      });
                    }
                });
avatar
smurfavr
Active Poster

Male Posts : 1559
Reputation : 13
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by Daemon on July 23rd 2017, 5:52 pm

These codes are different. The effect of the result is on the image in the topic.
avatar
Daemon
Forumember

Posts : 51
Reputation : 27
Language : Português

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by smurfavr on July 23rd 2017, 6:29 pm

I AM YOUR CODE, BUT Nothing Happens? Here's a link to my test forum.

http://vracatestforum.bulgarianforum.net/t18-topic
avatar
smurfavr
Active Poster

Male Posts : 1559
Reputation : 13
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by Daemon on July 23rd 2017, 7:06 pm

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();
});
Smile
avatar
Daemon
Forumember

Posts : 51
Reputation : 27
Language : Português

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by smurfavr on July 23rd 2017, 7:57 pm

Now it works. Can you increase the reputation to 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
avatar
smurfavr
Active Poster

Male Posts : 1559
Reputation : 13
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by Daemon on July 23rd 2017, 10:53 pm

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"
    }
Each new entry starts with this -> '{' and ends with this -> '}'. Always with a comma at the end, except for the last entry.

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.
avatar
Daemon
Forumember

Posts : 51
Reputation : 27
Language : Português

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by smurfavr on July 23rd 2017, 11:40 pm

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?
avatar
smurfavr
Active Poster

Male Posts : 1559
Reputation : 13
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by smurfavr on July 26th 2017, 7:59 pm

@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
avatar
smurfavr
Active Poster

Male Posts : 1559
Reputation : 13
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by SLGray on July 26th 2017, 8:27 pm

@Daemon wrote: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"
    }
Each new entry starts with this -> '{' and ends with this -> '}'. Always with a comma at the end, except for the last entry.

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.


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

avatar
SLGray
Administrator
Administrator

Male Posts : 39639
Reputation : 2666
Language : English
Location : United States

https://fmthemes.forumotion.com/

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by smurfavr on July 26th 2017, 10:04 pm

@smurfavr wrote:I will not be able to do it because I do not understand English well.
avatar
smurfavr
Active Poster

Male Posts : 1559
Reputation : 13
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by SLGray on July 27th 2017, 3:07 am

Do not Google translate well enough for you to understand what to do?


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

avatar
SLGray
Administrator
Administrator

Male Posts : 39639
Reputation : 2666
Language : English
Location : United States

https://fmthemes.forumotion.com/

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by smurfavr on July 27th 2017, 10:57 am

@SLGray wrote:Do not Google translate well enough for you to understand what to do?
Yes.
avatar
smurfavr
Active Poster

Male Posts : 1559
Reputation : 13
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by smurfavr on July 29th 2017, 11:15 am

@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
avatar
smurfavr
Active Poster

Male Posts : 1559
Reputation : 13
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by smurfavr on August 6th 2017, 1:21 pm

@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
avatar
smurfavr
Active Poster

Male Posts : 1559
Reputation : 13
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by Justice™ on August 6th 2017, 2:00 pm

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();
        });
avatar
Justice™
Forumember

Posts : 489
Reputation : 115
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by smurfavr on August 6th 2017, 4:52 pm

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.

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
avatar
smurfavr
Active Poster

Male Posts : 1559
Reputation : 13
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by Justice™ on August 6th 2017, 5:01 pm

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();
        });
avatar
Justice™
Forumember

Posts : 489
Reputation : 115
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by smurfavr on August 6th 2017, 5:18 pm

Thank you Wolfuryo .


Where can I change the caption from the photo?
avatar
smurfavr
Active Poster

Male Posts : 1559
Reputation : 13
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by smurfavr on August 6th 2017, 5:28 pm

Wolfuryo
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();
        });
avatar
smurfavr
Active Poster

Male Posts : 1559
Reputation : 13
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by Justice™ on August 6th 2017, 5:37 pm

Hmm, I don't see anything wrong at the code. What your forum's link?
avatar
Justice™
Forumember

Posts : 489
Reputation : 115
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by smurfavr on August 6th 2017, 5:39 pm

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.
avatar
smurfavr
Active Poster

Male Posts : 1559
Reputation : 13
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by Justice™ on August 6th 2017, 6:09 pm

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();
        });
avatar
Justice™
Forumember

Posts : 489
Reputation : 115
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by smurfavr on August 6th 2017, 6:15 pm

Thanks now works.
How do I change the caption from the photo in my previous post?

avatar
smurfavr
Active Poster

Male Posts : 1559
Reputation : 13
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by Justice™ on August 6th 2017, 7:06 pm

Replace the script with:
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:
Code:
if (rep) rep.text("Reputation");
Change Reputation to whatever you want.
avatar
Justice™
Forumember

Posts : 489
Reputation : 115
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Re: [Tutorial] Reputation Levels

Post by smurfavr on August 6th 2017, 8:32 pm

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("Репутация");
                });
avatar
smurfavr
Active Poster

Male Posts : 1559
Reputation : 13
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Page 1 of 2 1, 2  Next

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum