how i can make custom bbcode for forum post content????
how i can make custom bbcode for forum post content????
i am trying many javascript but. i cant make custom bbcode for forum post content... can anyone help me???
Re: how i can make custom bbcode for forum post content????
Forum already support bbcode! What you are missing?
-
- Posts: 29
- Joined: Thu Mar 09, 2023 12:25 pm
Re: how i can make custom bbcode for forum post content????
Hello friend, follow the javascript:
no ender:
Code: Select all
<div id="output"></div>
Code: Select all
<script>
$str = ' %content% ';
// The array of regex patterns to look for
$format_search = [
/\[b\](.*?)\[\/b\]/ig,
/\[youtube\](.*?)\[\/youtube\]/ig,
/\[caixa\](.*?)\[\/caixa\]/ig,
/\[i\](.*?)\[\/i\]/ig,
/\[u\](.*?)\[\/u\]/ig
]; // NOTE: No comma after the last entry
// The matching array of strings to replace matches with
$format_replace = [
'<strong>$1</strong>',
'<iframe width="560" height="315" src="https://www.youtube.com/embed/$1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>',
'<br/><br/>Codigo:<br/><textarea rows="5" cols="30" class="button-45" role="button" style="" disabled>$1</textarea><br/>Caixa:<br/><textarea class="text" rows="5" cols="33">$1</textarea><button id="copy">Copiar</button><br/><br/>',
'<em>$1</em>',
'<span style="text-decoration: underline;">$1</span>'
];
// Perform the actual conversion
for (var i =0;i<$format_search.length;i++) {
$str = $str.replace($format_search[i], $format_replace[i]);
}
document.getElementById('output').innerHTML=$str;
</script> <style> strong { font-weight:bold }
em { font-style:italic } </style>
in the second line of code has a function called $str that pulls the text from (%content%), if you use any variable or you must modify it to your desire.
In the $format_search function it pulls the BBcode displayed in the $str. and in the $format_replace function it converts BBcode to html. Modify the codes to your preferred.
Note: javascript should be the last applied between the codes, if adding it on top would leave the page blank.
http://jsfiddle.net/mplungjan/m8zLX/
-----------------------------BONUS----------------------------------------------------------
I have this javascript that convert links from youtube to player without bbcode.
https://godcode.wapka.xyz/f?id=47818&ti ... m%20bbcode
Last edited by samuel_anttunes on Sat Mar 11, 2023 2:16 pm, edited 1 time in total.
Re: how i can make custom bbcode for forum post content????
This new wapka site is hard to understand, a neutral person can't just config it
Re: how i can make custom bbcode for forum post content????
Yes. But it is also easy if you know about all wapka configuration. It is so easy