Reputation limits - [Tutorial] Reputation Levels - Page 2 Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
4 posters

    [Tutorial] Reputation Levels

    Daemon
    Daemon
    Forumember


    Posts : 104
    Reputation : 91
    Language : Português

    Reputation limits - [Tutorial] Reputation Levels - Page 2 Empty [Tutorial] Reputation Levels

    Post by Daemon July 20th 2017, 07:59

    First topic message reminder :

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

    Reputation limits - [Tutorial] Reputation Levels - Page 2 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, 21:03; edited 15 times in total
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51554
    Reputation : 3524
    Language : English
    Location : United States

    Reputation limits - [Tutorial] Reputation Levels - Page 2 Empty Re: [Tutorial] Reputation Levels

    Post by SLGray August 6th 2017, 21:38

    AP > Modules > Points/Reputation > Reputation



    Reputation limits - [Tutorial] Reputation Levels - Page 2 Slgray10

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


    Male Posts : 1881
    Reputation : 22
    Language : Bulgarian

    Reputation limits - [Tutorial] Reputation Levels - Page 2 Empty Re: [Tutorial] Reputation Levels

    Post by smurfavr August 6th 2017, 21:41

    Thank you SLGray. Now it works.
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51554
    Reputation : 3524
    Language : English
    Location : United States

    Reputation limits - [Tutorial] Reputation Levels - Page 2 Empty Re: [Tutorial] Reputation Levels

    Post by SLGray August 6th 2017, 21:45

    You're welcome.



    Reputation limits - [Tutorial] Reputation Levels - Page 2 Slgray10

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


    Posts : 104
    Reputation : 91
    Language : Português

    Reputation limits - [Tutorial] Reputation Levels - Page 2 Empty Re: [Tutorial] Reputation Levels

    Post by Daemon April 21st 2018, 00:08

    I made a little modification in the code!