Temat: JQuery i replace.
Zrobiłem tak:
$(document).ready(function() {
MyRC = document.getElementsByTagName("table")[5].innerHTML ;
MyRC = MyRC.replace(/<tbody>/g, '[table]');
MyRC = MyRC.replace(/<\/tbody>/g, '[/table]');
MyRC = MyRC.replace(/<tr>/g, '[tr]');
MyRC = MyRC.replace(/<\/tr>/g, '[/tr]');
MyRC = MyRC.replace(/<td colspan=\"5\" class=\"main\">/g, '[td]');
MyRC = MyRC.replace(/<td>/g, '[td]');
MyRC = MyRC.replace(/<\/td>/g, '[/td]');
MyRC = MyRC.replace(/<td class=\"main\" width=\"20%\">/g, '[td]');
MyRC = MyRC.replace(/<td class=\"main\" width=\"15%\">/g, '[td]');
MyRC = MyRC.replace(/<td class=\"main\">/g, '[td]');
MyRC = MyRC.replace(/<td colspan=\"5\">/g, '[td]');
MyRC = MyRC.replace(/<td class=\"main\" valign=\"top\">/g, '[td]');
MyRC = MyRC.replace(/<td colspan=\"2\">/g, '[td]');
MyRC = MyRC.replace(/<td colspan=\"3\">/g, '[td]');
MyRC = MyRC.replace(/<td class=\"main\">/g,/<\/td>/g, '[td]');
MyRC = MyRC.replace(/<br>/g, '');
MyRC = MyRC.replace(/<a href=\"info.php?t=u&w=8\">/g, '');
MyRC = MyRC.replace(/<a href=\"info.php?t=u&w=7\">/g, '');
MyRC = MyRC.replace(/<\/a>/g, '');
MyRC = MyRC.replace(/Battle round 1/g, '[color=#0000FF][size=150]
Battle round 1[/size][/color]');
MyRC = MyRC.replace(/Battle round 2/g, '[color=#0000FF][size=150]
Battle round 2[/size][/color]');
MyRC = MyRC.replace(/Battle round 3/g, '[color=#0000FF][size=150]
Battle round 3[/size][/color]');
MyRC = MyRC.replace(/Battle round 4/g, '[color=#0000FF][size=150]
Battle round 4[/size][/color]');
MyRC = MyRC.replace(/Battle round 5/g, '[color=#0000FF][size=150]
Battle round 5[/size][/color]');
$('td[style="text-align:left;"]').addClass('RW');
//var raport = $('td[colspan="5"]').replaceWith('[table border=1]');
$('.RW').append('<div><form action="noaction"><textarea id="bbcode" cols="50" rows="6">'+MyRC+'</textarea><input type="button" class="planet" value="Zaznacz bbCode" onClick="javascript:bbcode.focus();bbcode.select();"></form></div>');
})
Konsola wypluwa błąd ale działa ;-)
ReferenceError: assignment to undeclared variable MyRC