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.

BBcode doesn't work

3 posters

Go down

Solved BBcode doesn't work

Post by the_rocketeer August 30th 2020, 10:51 am

Technical Details


Forum version : #phpBB2
Position : Founder
Concerned browser(s) : Google Chrome
Screenshot of problem : example
Who the problem concerns : Yourself
Forum link : ( link is hidden, you must reply to see )

Description of problem

Hi guys!

I used this tutorial to create a bbcode. I changed it a bit so this is how it looks now:
Code:
/*
 *  Application: Create New BBCode Tags
 *  Date: 18/05/2018
 *  Version: 1.321052018
 *  Copyright (c) 2018 Daemon <help.forumotion.com>
 *  This work is free. You can redistribute it and/or modify it
 */
(function() {
    BBParser = {
        initialize: function() {
            $(function() {
                BBParser.setupBBParser();
            });
        },
        add: [
            /*
            * Note: Add a comma at the end of each new entry
            * '{option}' corresponds to the optional tag title, and '{content}' correspond to the text between the tags
            */
 
            {
                tag: 'mark',
                close: true,
                replacement: '<span class="mark">{content}</span>',
                replace: function(option, content) {
                    if (_userdata.session_logged_in < 1) {
                        return 'You need to be logged in to view this content';
                        return content;
                    }
                }
            }
 
            // Note: Do not add a comma at the end of the last entry
        ],
        // Do not change anything down
        validateTag: function(a) {
            if (!/^\w+$/.test(a)) throw new RangeError("You added an invalid tag: " + a);
        },
        replacers: function(a, b, c) {
            return (a || "").replace(/{option}/g, b || "").replace(/{content}/g, c || "");
        },
        optionReg: /.*?=("|'|)(.*?)\1\]/,
        parsedContent: function(a, b, c) {
            return a.replace(c ? RegExp("(\\[" + b.tag + "[^\\]]*\\])([\\s\\S]*?)\\[/" + b.tag + "]", "g" + (b.insensitive ? "i" : "")) : RegExp("\\[" + b.tag + "[^\\]]*\\]", "g" + (b.insensitive ? "i" : "")), function(d, e, f) {
                c || (e = d);
                e = BBParser.optionReg.test(e) ? e.replace(BBParser.optionReg, "$2") : b.defaultOption;
                if("undefined" !== typeof b.replace) {
                    d = c ? b.replace(e, f) : b.replace(e);
                    "string" === typeof d ? c ? f = d : e = d : d;
                    "object" === typeof d && (e = d.option || e, f = d.content || f);
                }
                return BBParser.replacers(b.replacement, e, f);
            });
        },
        setupBBParser: function() {
            var postBody = $(".postbody, .blog_message");
            for (var i = 0, e;(e = postBody[i++]);) {
                for (var j in BBParser.add) {
                    var item = BBParser.add[j];
                    // Validating tag
                    BBParser.validateTag(item.tag);
                    e.innerHTML = BBParser.parsedContent(e.innerHTML, item, item.close);
                }
            }
        }
    };
    BBParser.initialize()
})();

I also used this code
Code:
$(function(){$(function(){
 
  $('<a class="sceditor-button" unselectable="on" title="Маркирай"><div unselectable="on" style="background-image:url(https://i.servimg.com/u/f52/20/25/52/85/oqqrsv10.jpg)">Маркирай</div></a>').insertAfter('.sceditor-button-strike').click(function(){
    $('#text_editor_textarea').sceditor("instance").insertText("[mark]","[/mark]");
  });
 
})});

to add it to the SCEditor. Both work fine but only in the posts, nowhere else in the forum even though I placed them in all pages (see the screenshot). I would like to be able to use the code everywhere but since my js knowledge is pretty limited I can't manage to make it work. Can you please help? Embarassed

Thanks in advance! I love you


Last edited by the_rocketeer on August 30th 2020, 6:31 pm; edited 1 time in total
the_rocketeer
the_rocketeer
Forumember

Other / Decline to state Posts : 84
Reputation : 4
Language : English
Location : Europe

http://love-you-hogwarts.bulgarianforum.net/

Back to top Go down

Solved Re: BBcode doesn't work

Post by tikky August 30th 2020, 4:55 pm

Hello @the_rocketeer,

I would like to be able to use the code everywhere
In the first code find and replace:
Code:
var postBody = $(".postbody, .blog_message");
to
Code:
var postBody = $("div");
tikky
tikky
Forumember

Posts : 898
Reputation : 157
Language : 🇵🇹

https://www.forumotion.com/create-forum/modernbb

skouliki, SLGray, TonnyKamper and the_rocketeer like this post

Back to top Go down

Solved Re: BBcode doesn't work

Post by the_rocketeer August 30th 2020, 6:31 pm

Hi @pedxz,

Thanks a million for the help! BBcode doesn't work 2764 I actually tried to add a class to the profile and add that in the js as well but it didn't work Very Happy

Thanks once again and have a nice day!

This topic is now solved!
the_rocketeer
the_rocketeer
Forumember

Other / Decline to state Posts : 84
Reputation : 4
Language : English
Location : Europe

http://love-you-hogwarts.bulgarianforum.net/

Back to top Go down

Solved Re: BBcode doesn't work

Post by SLGray August 30th 2020, 6:39 pm

Problem solved & topic archived.
Please read our forum rules:  ESF General Rules


BBcode doesn't work 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 : 51533
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Back to top

- Similar topics

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