how i can make custom bbcode for forum post content????
Posted: 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???
Let's talk
https://forum.wapka.org/
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???
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>example i want to put a view full image link in