Código Javascript:
Ver original
function html2bbcode(data) { if (!data) { return ''; } // unwanted breaklines data = data.replace(/\n|\r/g, ''); // code data = data.replace( new RegExp('<(?:pre|code)>([^]*?)<\\\/(?:pre|code)>', 'g'), function (match, _1) { return '[code]' + strip_tags(_1, '<br><br/><br />') + '[/code]' } ); // quotes data = data.replace( new RegExp('<blockquote><div class="cita"><strong>([^]*?)<\\\/strong> dijo:<\\\/div>', 'g'), '[quote=$1]' ); do { original = data; data = data.replace( new RegExp('<div class="citacuerpo">(?:<p>)?([^]*?)(?:<\\\/p>)<\\\/div><\\\/blockquote>', 'g'), function (m, _1) { if (_1.match(new RegExp('<div class="citacuerpo">(?:<p>)?([^]*?)(?:<\\\/p>)<\\\/div><\\\/blockquote>'))) { return m; } else { return _1 + '[/quote]'; } } ); } while (original != data); // swf data = data.replace( new RegExp('(?:<br>)?(?:<center>)?<embed src="([^]*?)"(.*?)>(?:<\\\/embed>)?(?:<\\\/center>)?', 'g'), '[swf=$1]' ); // images data = data.replace(/<img\s[^<>]*?src=\"?([^<>]*?)\"?(\s[^<>]*)?\/?>/gi, '[img]$1[/img]'); // strong data = data.replace(/<(strong|b)(\s[^<>]*)?>/gi, '[b]'); data = data.replace(/<\/(strong|b)>/gi, '[/b]'); // italic data = data.replace(/<(em|i)(\s[^<>]*)?>/gi, '[i]'); data = data.replace(/<\/(em|i)>/gi, '[/i]'); // underline data = data.replace(/<u(\s[^<>]*)?>/gi, '[u]'); data = data.replace(/<\/u>/gi, '[/u]'); data = data.replace(/<ul(\s[^<>]*)?>/gi, '[ul]'); data = data.replace(/<\/ul>/gi, '[/ul]'); data = data.replace(/<li(\s[^<>]*)?>/gi, '[li]'); data = data.replace(/<\/li>/gi, '[/li]'); // cleanup & pre processing data = data.replace(/<div><br(\s[^<>]*)?>/gi, '<div>'); data = data.replace(/<br(\s[^<>]*)?>/gi, '\n'); data = data.replace(/<p(\s[^<>]*)?>/gi, ''); data = data.replace(/<\/p>/gi, '\n'); data = data.replace(/<\/div>\s*<div([^<>]*)>/gi, '</span>\n<span$1>'); data = data.replace(/<div([^<>]*)>/gi, '\n<span$1>'); data = data.replace(/<\/div>/gi, '</span>\n'); data = data.replace(/ /gi, ' '); data = data.replace(/"/gi, '\"'); data = data.replace(/&/gi, '&'); var sc, sc2; do { sc = data; // font tag (eew!) color data = data.replace(/<font\s[^<>]*?color=\"?([^<>]*?)\"?(\s[^<>]*)?>([^<>]*?)<\/font>/gi, '[color=$1]$3[/color]'); // ...and size data = data.replace( /<font\s[^<>]*?size=\"?([^<>]*?)\"?(\s[^<>]*)?>([^<>]*?)<\/font>/gi, function (m, _1, _2, _3) { return '[size=' +_1 + ']' + _3 + '[/size]'; } ); // font tag cleanup if(sc == data) { data = data.replace(/<font[^<>]*>([^<>]*?)<\/font>/gi, '$1'); } data = data.replace(/<a\s[^<>]*?href=\"?([^<>]*?)\"?(\s[^<>]*)?>([^<>]*?)<\/a>/gi, '[url=$1]$3[/url]'); sc2 = data; data = data.replace(/<(span|blockquote|pre)\s[^<>]*?style=\"?font-weight: ?bold;?\"?\s*([^<]*?)<\/\1>/gi, '[b]<$1 style=$2</$1>[/b]'); data = data.replace(/<(span|blockquote|pre)\s[^<>]*?style=\"?font-weight: ?normal;?\"?\s*([^<]*?)<\/\1>/gi, '<$1 style=$2</$1>'); data = data.replace(/<(span|blockquote|pre)\s[^<>]*?style=\"?font-style: ?italic;?\"?\s*([^<]*?)<\/\1>/gi, '[i]<$1 style=$2</$1>[/i]'); data = data.replace(/<(span|blockquote|pre)\s[^<>]*?style=\"?font-style: ?normal;?\"?\s*([^<]*?)<\/\1>/gi, '<$1 style=$2</$1>'); data = data.replace(/<(span|blockquote|pre)\s[^<>]*?style=\"?text-decoration: ?underline;?\"?\s*([^<]*?)<\/\1>/gi, '[u]<$1 style=$2</$1>[/u]'); data = data.replace(/<(span|blockquote|pre)\s[^<>]*?style=\"?text-decoration: ?none;?\"?\s*([^<]*?)<\/\1>/gi, '<$1 style=$2</$1>'); data = data.replace(/<(span|blockquote|pre)\s[^<>]*?style=\"?color: ?([^<>]*?);\"?\s*([^<]*?)<\/\1>/gi, '[color=$2]<$1 style=$3</$1>[/color]'); data = data.replace(/<(span|blockquote|pre)\s[^<>]*?style=\"?font-family: ?([^<>]*?);\"?\s*([^<]*?)<\/\1>/gi, '[font=$2]<$1 style=$3</$1>[/font]'); // alignment data = data.replace(/<(span|blockquote|pre|p)\s[^<>]*?style=\"?text-align: ?([^<>]*?);\"?\s*([^<]*?)<\/\1>/gi, '[align=$2]<$1 style=$3</$1>[/align]'); data = data.replace( /<(span|blockquote|pre)\s[^<>]*?style=\"?font-size: ?([^<>]*?);\"?\s*([^<]*?)<\/\1>/gi, function (m, _1, _2, _3) { return '[size=' + parseInt(_2) + ']<' + _1 + ' style=' + _3 + '</' + _1 + '>[/size]'; } ); data = data.replace(/<(blockquote|pre)\s[^<>]*?style=\"?\"? (class=|id=)([^<>]*)>([^<>]*?)<\/\1>/gi, '<$1 $2$3>$4</$1>'); data = data.replace(/<span\s[^<>]*?style=\"?\"?>([^<>]*?)<\/span>/gi, '$1'); if(sc2 == data) { data = data.replace(/<span[^<>]*>([^<>]*?)<\/span>/gi, '$1'); sc2 = data; } } while(sc != data); data = data.replace(/<[^<>]*>/gi, ''); data = data.replace(/</gi, '<'); data = data.replace(/>/gi, '>'); // childs against parents /*do { sc = data; data = data.replace(/\[(b|i|u)\]\[quote([^\]]*)\]([\s\S]*?)\[\/quote\]\[\/\1\]/gi, '[quote$2][$1]$3[/$1][/quote]'); data = data.replace(/\[color=([^\]]*)\]\[quote([^\]]*)\]([\s\S]*?)\[\/quote\]\[\/color\]/gi, '[quote$2][color=$1]$3[/color][/quote]'); data = data.replace(/\[(b|i|u)\]\[code\]([\s\S]*?)\[\/code\]\[\/\1\]/gi, '[code][$1]$2[/$1][/code]'); data = data.replace(/\[color=([^\]]*)\]\[code\]([\s\S]*?)\[\/code\]\[\/color\]/gi, '[code][color=$1]$2[/color][/code]'); } while(sc != data);*/ do { sc = data; data = data.replace(/\[b\]\[\/b\]/gi, ''); data = data.replace(/\[i\]\[\/i\]/gi, ''); data = data.replace(/\[u\]\[\/u\]/gi, ''); data = data.replace(/\[quote[^\]]*\]\[\/quote\]/gi, ''); data = data.replace(/\[code\]\[\/code\]/gi, ''); data = data.replace(/\[url=([^\]]+)\]\[\/url\]/gi, ''); data = data.replace(/\[img\]\[\/img\]/gi, ''); data = data.replace(/\[color=([^\]]*)\]\[\/color\]/gi, ''); } while (sc != data); return data; }
Funciona perfectamente en Firefox, pero en explorer no.
Alguien sabe cual es el problema?