HTML to UBB and UBB to HTML
Function Pattern (STR)
{
// STR = Str. Replace (/(\ r \ n | \ r)/ig ,'');
STR = Str. Replace (/<br [^>] *>/ig, '\ n ');
STR = Str. Replace (/<p [^> \/] * \/>/ig, '\ n ');
STR = Str. Replace (/\ [Code \] (. + ?) \ [\/Code \]/ig, Function ($1, $2 ){ Return Phpcode ($2 );});
STR = Str. Replace (/\ son [\ W] {3, 16} \ s? = \ S * ([\ '\ "]). +? \ 1/ig ,'');
STR = Str. Replace (/<HR [^>] *>/ig, '[HR]');
STR = Str. Replace (/<(sub | sup | u | strike | B | I | pre)>/ig, '[$1]');
STR = Str. Replace (/<\/(sub | sup | u | strike | B | I | pre)>/ig, '[/$1]');
STR = Str. Replace (/<(\/)? Strong>/ig, '[$ 1b]');
STR = Str. Replace (/<(\/)? Em>/ig, '[$ 1i]');
STR = Str. Replace (/<(\/)? BLOCKQUOTE ([^>] *)>/ig, '[$1 BLOCKQUOTE]');
STR = Str. replace (/] * smile = \ "(\ D +) \" [^>] *>/ig, '[s: $1]');
STR = Str. replace (/] * src = [\ '\ "\ s] * ([^ \ s \' \"] +) [^>] *>/ig, '[img]' + '$ 1' +' [/img] ');
STR = Str. replace (/<A [^>] * href = [\ '\ "\ s] * ([^ \ s \' \"] *) [^>] *> (. + ?) <\/A>/ig, '[url = $1]' + '$ 2' +' [/url] ');
STR = Str. Replace (/<H ([1-6] +) ([^>] *)> (.*?) <\/H \ 1>/ig,Function($1, $2, $3, $4 ){ReturnH ($3, $4, $2 );});
STR = Str. Replace (/<[^>] *?> /Ig ,'');
STR = Str. Replace (/& amp;/ig ,'&');
STR = Str. Replace (/& lt;/ig, '<');
STR = Str. Replace (/& gt;/ig, '> ');
ReturnSTR;
}
FunctionHtmltoubb ()
{
VaRSTR = pattern (document. getelementbyid ("htmlsource"). value );
Document. getelementbyid ("ubbresult"). value = STR;
}
FunctionUp (STR)
{
STR = Str. Replace (/</ig, '& lt ;');
STR = Str. Replace (/>/ig, '& gt ;');
STR = Str. Replace (/\ n/ig, '<br/> ');
STR = Str. Replace (/\ [Code \] (. + ?) \ [\/Code \]/ig,Function($1, $2 ){ReturnPhpcode ($2 );});
STR = Str. replace (/\ [HR \]/ig, '
');
STR = Str. replace (/\ [\/(size | color | font | backcolor) \]/ig, '');
STR = Str. replace (/\ [(sub | sup | u | I | strike | B | BLOCKQUOTE | Li) \]/ig, '<$1> ');
STR = Str. replace (/\ [\/(sub | sup | u | I | strike | B | BLOCKQUOTE | Li) \]/ig, ' ');
STR = Str. replace (/\ [\/align \]/ig, '
');
STR = Str. replace (/\[(\/)? H ([1-6]) \]/ig, '<$1 h $2>');
STR = Str. replace (/\ [align = (left | center | right | justify) \]/ig, '
');
STR = Str. replace (/\ [size = (\ D + ?) \]/Ig, '');
STR = Str. replace (/\ [color = ([^ \ [\ <] + ?) \]/Ig, '');
STR = Str. replace (/\ [backcolor = ([^ \ [\ <] + ?) \]/Ig, '');
STR = Str. replace (/\ [font = ([^ \ [\ <] + ?) \]/Ig, '');
STR = Str. replace (/\ [list = (a | A | 1) \] (. + ?) \ [\/List \]/ig, '
$2
');
STR = Str. replace (/\[(\/)? List \]/ig, '<$ 1ul>');
STR = Str. Replace (/\ [s :( \ D +) \]/ig,Function($1, $2 ){ReturnSmilepath ($2 );});
STR = Str. replace (/\ [img \] ([^ \ [] *) \ [\/IMG \]/ig, ' ');
STR = Str. replace (/\ [url = ([^ \] +) \] ([^ \ [] +) \ [\/URL \]/ig, '<a href = "$1">' + '$ 2' +' </a> ');
STR = Str. replace (/\ [url \] ([^ \ [] +) \ [\/URL \]/ig, '<a href = "$1">' + '$1' + '</a> ');
ReturnSTR;
}
FunctionUbbtohtml ()
{
STR = up (document. getelementbyid ("ubbsource"). value );
Document. getelementbyid ("htmlresult"). value = STR;
}