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.
The forum of the forums
4 posters

    BBcode/html in rpg profile

    Farronsister
    Farronsister
    New Member


    Posts : 14
    Reputation : 1
    Language : Dutch/English

    BBcode/html in rpg profile Empty BBcode/html in rpg profile

    Post by Farronsister April 20th 2016, 11:08 am

    Hello,

    I noticed that you can't use BBcode/html in the textfields of the RPG profile. Is there a way to make this possible anyhow?
    Take Notes
    Take Notes
    Helper
    Helper


    Male Posts : 2337
    Reputation : 324
    Language : English
    Location : Forumountain

    BBcode/html in rpg profile Empty Re: BBcode/html in rpg profile

    Post by Take Notes April 20th 2016, 3:44 pm

    Text zones will allow the BBCode.
    Farronsister
    Farronsister
    New Member


    Posts : 14
    Reputation : 1
    Language : Dutch/English

    BBcode/html in rpg profile Empty Re: BBcode/html in rpg profile

    Post by Farronsister April 20th 2016, 7:05 pm

    On the normal profile, yes, but not with the RPG profile. (Admin panel => Modules => Roleplay Game).
    Take Notes
    Take Notes
    Helper
    Helper


    Male Posts : 2337
    Reputation : 324
    Language : English
    Location : Forumountain

    BBcode/html in rpg profile Empty Re: BBcode/html in rpg profile

    Post by Take Notes April 20th 2016, 7:53 pm

    That's because you can't add a text zone in the role-play game. So I am not sure if this is possible.
    Farronsister
    Farronsister
    New Member


    Posts : 14
    Reputation : 1
    Language : Dutch/English

    BBcode/html in rpg profile Empty Re: BBcode/html in rpg profile

    Post by Farronsister April 20th 2016, 11:53 pm

    Maybe there's a way to enable BBcode in rpg fields with javascript? Unfortunately Im not good with that. Html and css I can do fine, but javascript no, so I wouldnt know what to look for.
    Take Notes
    Take Notes
    Helper
    Helper


    Male Posts : 2337
    Reputation : 324
    Language : English
    Location : Forumountain

    BBcode/html in rpg profile Empty Re: BBcode/html in rpg profile

    Post by Take Notes April 21st 2016, 2:57 am

    If I may ask what BBCode would you use?
    Farronsister
    Farronsister
    New Member


    Posts : 14
    Reputation : 1
    Language : Dutch/English

    BBcode/html in rpg profile Empty Re: BBcode/html in rpg profile

    Post by Farronsister April 21st 2016, 7:47 am

    I want members to be able to add pictures, make the text bold/italic etc. Basically the same as what you can do with normal profile fields.
    Take Notes
    Take Notes
    Helper
    Helper


    Male Posts : 2337
    Reputation : 324
    Language : English
    Location : Forumountain

    BBcode/html in rpg profile Empty Re: BBcode/html in rpg profile

    Post by Take Notes April 21st 2016, 6:02 pm

    Try Text/List, it looks the same as a Text Zone.
    Farronsister
    Farronsister
    New Member


    Posts : 14
    Reputation : 1
    Language : Dutch/English

    BBcode/html in rpg profile Empty Re: BBcode/html in rpg profile

    Post by Farronsister April 21st 2016, 9:10 pm

    That doesn't work. Sad
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    BBcode/html in rpg profile Empty Re: BBcode/html in rpg profile

    Post by Ange Tuteur April 23rd 2016, 12:05 am

    @Farronsister It should be possible to parse the bbcode client-side with JavaScript however, I need a little more information :

    1. A link to the page where your RPG field is ( or a link to a topic if the field is in the topics )
    2. What field specifically do you want bbcode to work in ?
    3. What tag(s) do you want parsed ? ( e.g. [b], [i], [img], etc.. )

    Thanks in advance for providing the info above. salut
    Farronsister
    Farronsister
    New Member


    Posts : 14
    Reputation : 1
    Language : Dutch/English

    BBcode/html in rpg profile Empty Re: BBcode/html in rpg profile

    Post by Farronsister April 23rd 2016, 12:18 am

    Someone has found the solution for me! Thanks for your help anyway! Smile
    Take Notes
    Take Notes
    Helper
    Helper


    Male Posts : 2337
    Reputation : 324
    Language : English
    Location : Forumountain

    BBcode/html in rpg profile Empty Re: BBcode/html in rpg profile

    Post by Take Notes April 23rd 2016, 1:01 am

    What was the solution if I may ask?
    Farronsister
    Farronsister
    New Member


    Posts : 14
    Reputation : 1
    Language : Dutch/English

    BBcode/html in rpg profile Empty Re: BBcode/html in rpg profile

    Post by Farronsister April 23rd 2016, 8:58 am

    I'm not sure if I'm allowed to copy the code, but he used JavaScript to turn the fields into a div that allows BBcode (like Ange Tuteur suggested)
    10spetter10
    10spetter10
    Forumember


    Posts : 195
    Reputation : 82
    Language : Dutch

    BBcode/html in rpg profile Empty Re: BBcode/html in rpg profile

    Post by 10spetter10 April 24th 2016, 11:18 am

    I have no problem with sharing the code. Perhaps it could help others with the same problem.

    Code:
    $(function() {
        var pathname = $(location).attr('pathname');
            if (pathname.match("^/u") ) {
              $("textarea").each(function(index, value) {
                var obj = jQuery(value);
                var tmp = obj.val().replace(/[\r\n]/g, "<br />");

                $format_search =  [
                    /\[b\](.*?)\[\/b\]/ig,
                    /\[i\](.*?)\[\/i\]/ig,
                    /\[u\](.*?)\[\/u\]/ig,
                    /\[img\](.*?)\[\/img\]/ig
                ];
               
                $format_replace = [
                    '<strong>$1</strong>',
                    '<em>$1</em>',
                    '<span style="text-decoration: underline;">$1</span>',
                    '<img class="rpgtext_img" src="$1" />'
                ];
               
                for (var i =0;i<$format_search.length;i++) {
                  var tmp = tmp.replace($format_search[i], $format_replace[i]);
                }

                var newTag = jQuery("<div></div>").html(tmp);
                newTag.addClass("rpg_text");
                obj.replaceWith(newTag);

            });
        }
    });

    There are maybe better scripts but this will do.

      Current date/time is September 22nd 2024, 5:28 pm