BBcode doesn't work
3 posters
Page 1 of 1
BBcode doesn't work
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](https://2img.net/i/fa/i/smiles/icon_redface.gif)
Thanks in advance!
![I love you](https://2img.net/i/fa/i/smiles/herz.png)
Last edited by the_rocketeer on August 30th 2020, 6:31 pm; edited 1 time in total
Re: BBcode doesn't work
Hello @the_rocketeer,
In the first code find and replace:I would like to be able to use the code everywhere
- Code:
var postBody = $(".postbody, .blog_message");
- Code:
var postBody = $("div");
skouliki, SLGray, TonnyKamper and the_rocketeer like this post
Re: BBcode doesn't work
Hi @pedxz,
Thanks a million for the help!
I actually tried to add a class to the profile and add that in the js as well but it didn't work
Thanks once again and have a nice day!
This topic is now solved!
Thanks a million for the help!
![BBcode doesn't work 2764](https://2img.net/i/fa/twemoji/16x16/2764.png)
![Very Happy](https://2img.net/i/fa/i/smiles/icon_biggrin.png)
Thanks once again and have a nice day!
This topic is now solved!
Re: BBcode doesn't work
Problem solved & topic archived.
|
![](https://i.servimg.com/u/f18/16/89/96/68/sig_se10.png)
![BBcode doesn't work Slgray10](https://i.servimg.com/u/f28/11/40/02/06/slgray10.png)
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
![-](https://2img.net/i/empty.gif)
» chatbox java doesnt work
» FMChat - auto login doesnt work
» search doesnt work?
» BBCode not work in profiles
» How can add the BBCode Button on the title bar of BBCode Table?
» FMChat - auto login doesnt work
» search doesnt work?
» BBCode not work in profiles
» How can add the BBCode Button on the title bar of BBCode Table?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum