Page 1 of 1

how i can make custom bbcode for forum post content????

Posted: Thu Mar 09, 2023 11:18 am
by obaydulbc
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????

Posted: Thu Mar 09, 2023 11:22 am
by zunaid
Forum already support bbcode! What you are missing?

Re: how i can make custom bbcode for forum post content????

Posted: Thu Mar 09, 2023 12:47 pm
by samuel_anttunes
obaydulbc wrote: Thu Mar 09, 2023 11:18 am i am trying many javascript but. i cant make custom bbcode for forum post content... can anyone help me???

Hello friend, follow the javascript:


no ender:

Code: Select all

 <div id="output"></div> 
This div will exit the result of the javascript variable. [br]

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

Re: how i can make custom bbcode for forum post content????

Posted: Fri Mar 10, 2023 8:26 pm
by obaydulbc
cool

Re: how i can make custom bbcode for forum post content????

Posted: Tue Mar 14, 2023 12:51 pm
by obaydulbc
zunaid wrote: Thu Mar 09, 2023 11:22 am Forum already support bbcode! What you are missing?
example i want to put a view full image link in Image tag.. how you will design it???

Re: how i can make custom bbcode for forum post content????

Posted: Mon Apr 03, 2023 5:06 pm
by Rem22
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????

Posted: Mon Apr 03, 2023 5:07 pm
by obaydulbc
Yes. But it is also easy if you know about all wapka configuration. It is so easy