[Tutorial] Reputation Levels

Page 1 of 2 1, 2  Next

Go down

[Tutorial] Reputation Levels Empty [Tutorial] Reputation Levels

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

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

[Tutorial] Reputation Levels Sem_ty10

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();
});
Add the following in your css stylesheet:
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 June 25th 2018, 8:03 pm; edited 15 times in total
Daemon
Daemon
Forumember

Posts : 104
Reputation : 90
Language : Português

View user profile

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

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

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

Posts : 104
Reputation : 90
Language : Português

View user profile

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

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

Awesome @Deamon thank you Yes
TonnyKamper
TonnyKamper
Forumember

Female Posts : 732
Reputation : 68
Language : Dutch/English
Location : The Netherlands

View user profile http://www.nederlandheelt.nl/forum

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

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

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


[Tutorial] Reputation Levels Slgray10

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

Male Posts : 49146
Reputation : 3423
Language : English
Location : United States

View user profile https://forumsclub.com/gc/128-link-directory/

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

Post by Daemon 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.
Daemon
Daemon
Forumember

Posts : 104
Reputation : 90
Language : Português

View user profile

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

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

Male Posts : 1876
Reputation : 22
Language : Bulgarian

View user profile http://smurfa.bulgarianforum.net/

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

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

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

Posts : 104
Reputation : 90
Language : Português

View user profile

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

Post by smurfavr 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
smurfavr
smurfavr
Active Poster

Male Posts : 1876
Reputation : 22
Language : Bulgarian

View user profile http://smurfa.bulgarianforum.net/

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

Post by Daemon 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
Daemon
Daemon
Forumember

Posts : 104
Reputation : 90
Language : Português

View user profile

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

Post by smurfavr 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
smurfavr
smurfavr
Active Poster

Male Posts : 1876
Reputation : 22
Language : Bulgarian

View user profile http://smurfa.bulgarianforum.net/

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

Post by Daemon 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.
Daemon
Daemon
Forumember

Posts : 104
Reputation : 90
Language : Português

View user profile

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

Post by smurfavr 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?
[Tutorial] Reputation Levels AsaJPGYEkFa1a
smurfavr
smurfavr
Active Poster

Male Posts : 1876
Reputation : 22
Language : Bulgarian

View user profile http://smurfa.bulgarianforum.net/

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

Post by smurfavr 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?
[Tutorial] Reputation Levels AsaJPGYEkFa1a

up
smurfavr
smurfavr
Active Poster

Male Posts : 1876
Reputation : 22
Language : Bulgarian

View user profile http://smurfa.bulgarianforum.net/

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

Post by SLGray 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.


[Tutorial] Reputation Levels Slgray10

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

Male Posts : 49146
Reputation : 3423
Language : English
Location : United States

View user profile https://forumsclub.com/gc/128-link-directory/

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

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

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

Male Posts : 1876
Reputation : 22
Language : Bulgarian

View user profile http://smurfa.bulgarianforum.net/

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

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

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


[Tutorial] Reputation Levels Slgray10

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

Male Posts : 49146
Reputation : 3423
Language : English
Location : United States

View user profile https://forumsclub.com/gc/128-link-directory/

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

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

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

Male Posts : 1876
Reputation : 22
Language : Bulgarian

View user profile http://smurfa.bulgarianforum.net/

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

Post by smurfavr 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?
[Tutorial] Reputation Levels AsaJPGYEkFa1a

up
smurfavr
smurfavr
Active Poster

Male Posts : 1876
Reputation : 22
Language : Bulgarian

View user profile http://smurfa.bulgarianforum.net/

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

Post by smurfavr 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?
[Tutorial] Reputation Levels AsaJPGYEkFa1a

up
smurfavr
smurfavr
Active Poster

Male Posts : 1876
Reputation : 22
Language : Bulgarian

View user profile http://smurfa.bulgarianforum.net/

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

Post by Guest 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
Guest
Guest


Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

Post by smurfavr 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
smurfavr
smurfavr
Active Poster

Male Posts : 1876
Reputation : 22
Language : Bulgarian

View user profile http://smurfa.bulgarianforum.net/

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

Post by Guest 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
Guest
Guest


Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

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

Thank you Wolfuryo .


Where can I change the caption from the photo?
[Tutorial] Reputation Levels AsaJPGYEkFa1a
smurfavr
smurfavr
Active Poster

Male Posts : 1876
Reputation : 22
Language : Bulgarian

View user profile http://smurfa.bulgarianforum.net/

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

Post by smurfavr 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();
        });
smurfavr
smurfavr
Active Poster

Male Posts : 1876
Reputation : 22
Language : Bulgarian

View user profile http://smurfa.bulgarianforum.net/

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

Post by Guest August 6th 2017, 5:37 pm

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


Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

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

Male Posts : 1876
Reputation : 22
Language : Bulgarian

View user profile http://smurfa.bulgarianforum.net/

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

Post by Guest 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
Guest
Guest


Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

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

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

smurfavr
smurfavr
Active Poster

Male Posts : 1876
Reputation : 22
Language : Bulgarian

View user profile http://smurfa.bulgarianforum.net/

Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

Post by Guest 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
Guest
Guest


Back to top Go down

[Tutorial] Reputation Levels Empty Re: [Tutorial] Reputation Levels

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

Male Posts : 1876
Reputation : 22
Language : Bulgarian

View user profile http://smurfa.bulgarianforum.net/

Back to top Go down

Page 1 of 2 1, 2  Next

Back to top


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