Upgraded from 3.0.x to 3.3.x, BBcode tables vanished

Get help developing custom BBCodes or request one.
system11
Registered User
Posts: 15
Joined: Fri Oct 07, 2005 7:42 am

Upgraded from 3.0.x to 3.3.x, BBcode tables vanished

Post by system11 »

I just upgraded an old 3.0.x forum to 3.3.x, and everything seemed fine until a user mentioned the table bbcode no longer works - they all vanished.

I'm not sure where exactly the Table bbcode came from, this forum is many years old. It's defined like this:

Code: Select all

Definition:
[Table]{TEXT}[/Table]

Code:
<script language="Javascript">
var texto = '{TEXT}';
texto = texto.replace("\r\n","");
texto = texto.replace("<br>","");
texto = texto.replace(" ","");
var linha = new Array();
linha = texto.split('R=');
var table = '<div align="center"><TABLE width=70% cellpadding=1 cellspacing=1 border=0>';
for (var i=1; i<linha.length; i++)
{
  table = table + '<TR>';
  var coluna = new Array();
  coluna = linha[i].split('&');
  for (var j=0; j<coluna.length; j++)
  {
    if (i == 1)
    {
      table = table + '<TD align=center style="background: #3097FF; font-size:11px; color:black; font-family:  Verdana,Arial, Helvetica, sans-serif;"><b>' + coluna[j].replace("amp;","") + '</b></TD>';      
    }
    else
    {
      table = table + '<TD style="background: #606060; font-size:11px; color:white; font-family:  Verdana,Arial, Helvetica, sans-serif;">' + coluna[j].replace("amp;","") + '</TD>';      
    }

  }
  table = table + '<TR>';
}
table = table + '</TABLE></div>';
document.write(table);
</script>
On the old forum these work fine, the generated HTML segment looks like this on a very simple 2 row table:

Code: Select all

<div class="postbody"><script language="Javascript">
var texto = 'R=hello<br />R=world';
texto = texto.replace("\r\n","");
texto = texto.replace("<br>","");
texto = texto.replace(" ","");
var linha = new Array();
linha = texto.split('R=');
var table = '<div align="center"><TABLE width=70% cellpadding=1 cellspacing=1 border=0>';
for (var i=1; i<linha.length; i++)
{
  table = table + '<TR>';
  var coluna = new Array();
  coluna = linha[i].split('&');
  for (var j=0; j<coluna.length; j++)
  {
    if (i == 1)
    {
      table = table + '<TD align=center style="background: #3097FF; font-size:11px; color:black; font-family:  Verdana,Arial, Helvetica, sans-serif;"><b>' + coluna[j].replace("amp;","") + '</b></TD>';      
    }
    else
    {
      table = table + '<TD style="background: #606060; font-size:11px; color:white; font-family:  Verdana,Arial, Helvetica, sans-serif;">' + coluna[j].replace("amp;","") + '</TD>';      
    }

  }
  table = table + '<TR>';
}
table = table + '</TABLE></div>';
document.write(table);
</script></div>
Viewing the same thing on the 3.3 forum, it seems to have broken fairly badly.

Code: Select all

<div class="content"><script language="Javascript">
var texto = '
R=hello
R=world
';
texto = texto.replace("\r\n","");
texto = texto.replace("<br>","");
texto = texto.replace(" ","");
var linha = new Array();
linha = texto.split('R=');
var table = '<div align="center"><TABLE width=70% cellpadding=1 cellspacing=1 border=0>';
for (var i=1; i<linha.length; i++)
{
  table = table + '<TR>';
  var coluna = new Array();
  coluna = linha[i].split('&');
  for (var j=0; j<coluna.length; j++)
  {
    if (i == 1)
    {
      table = table + '<TD align=center style="background: #3097FF; font-size:11px; color:black; font-family:  Verdana,Arial, Helvetica, sans-serif;"><b>' + coluna[j].replace("amp;","") + '';      
    }
    else
    {
      table = table + '<TD style="background: #606060; font-size:11px; color:white; font-family:  Verdana,Arial, Helvetica, sans-serif;">' + coluna[j].replace("amp;","") + '';      
    }

  }
  table = table + '<TR>';
}
table = table + '</script></div>
I don't understand Javascript or the bbcode parser, I could really use some help please, but it seems like the TEXT tag was parsed in the past but is just throwing newlines into the JS now.
User avatar
warmweer
Jr. Extension Validator
Posts: 11450
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Bel ... gium

Re: Upgraded from 3.0.x to 3.3.x, BBcode tables vanished

Post by warmweer »

You could try an extension providing a table BBCode
ABBcodebox
Rin editor
CK editor
Spelling is freeware, which means you can use it for free.
On the other hand, it is not open source, which means you cannot change it or publish it in a modified form.


Time flies like an arrow, but fruit flies like a banana.

Return to “Custom BBCode Development and Requests”