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?
Thanks in advance!
Last edited by the_rocketeer on August 30th 2020, 6:31 pm; edited 1 time in total