<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<style>.red {background-color:#fcc;}</style>

<form onsubmit="return zpracuj();">
<table><tr><td>
<b>text</b><br><textarea id=xxx cols=30 rows=20>
Vojenka: learn whats spam
Vojenka: and toxic
Vojenka: toxic are people who write to you in really bad words
Vojenka: like
Vojenka: KYS NOOB
Vojenka: im adc
Vojenka: i cant 1v1
Vojenka: and now brand show me whats spam
Vojenka: when u in game say onetime kys you can get ban
Vojenka: this is riot logic
Vojenka: and this is how i normaly chat
Vojenka: so boys bad for you
Vojenka: for?
Vojenka: toxic no
Vojenka: and spamming no
Vojenka: im silver
Vojenka: 2
Vojenka: and he is unraked
Vojenka: ye?
Vojenka: this is not about elo
Vojenka: i play normal for fun :)
Vojenka: tell me how i toxic
Vojenka: cuz you are my enemy
Vojenka: and i have to kill u
Vojenka: this happns to me
<br><br>
Ak hráči píšu jeden fuck shit zadruhym, itak im to prejde ak použijú nejakú slovnú prešmyčku: sht, fck, ab0rtion,
a slovne spojenia, ktorých toxicita vyplýva zo spojenia slov: waste of oxygen, end ur purposeless existence...
za toto by museli hrači dostať toľko reportov že by sa na to pozrel nejaký pracovnik riotu a tá hranica je fakt vysoko lebo reportovanych hráčov je veľa a riotaci nemajú čas ani prostriedky fyzicky kontrolovať chat každého hráča ktorý dostane report.
<br><br>
Nechcem vám tu dávať návody ako system obísť len poukazujem na obrovskú dieru v systéme ktorá nezmizne kým o nej nebude vedieť dosť veľa ludí.

</textarea>
</td><td valign="top">
<b>upraveno</b><br><div id=upraveno style="height:300px;overflow:scroll;font:14px Courier New;"></div>
</td><td>
<b>nalezeno</b><br><textarea id=nalezeno cols=20 rows=20></textarea>
</td><td>
<b>slovnik</b><br><textarea id=slovnik cols=20 rows=20></textarea>
</td></tr></table>
<br><input type=submit>
</form>

<script>
function $(id) {return document.getElementById(id);}

function regexpEscape(str)
{
var reg, symbols;
spc = ('['+'\\^$*+?.()|{}[]'.split('').join('\\'))+']';
reg = new RegExp(spc,'gm');
return str.replace(reg,'\\$&');
}

function removeTags(str)
{
str = str.replace(/<[^>]*?>/g,'');
return str;
}



var diacritic = [
	"áäčďéěíĺľňóôöŕšťúůüýřžÁÄČĎÉĚÍĹĽŇÓÔÖŔŠŤÚŮÜÝŘŽ",
	"aacdeeillnooorstuuuyrzAACDEEILLNOOORSTUUUYRZ"
	];

function removeDiacritic (str1)
	{
	var i,j, str2;
	str2 = '';
	for(i = 0; i < str1.length; i++)
		{
		j = diacritic[0].indexOf(str1.charAt(i));
		if (j!==-1)
			{
			str2 += diacritic[1].charAt(j);
			}
		else	{
			str2 += str1.charAt(i);
			}
		}
	return str2;
	}

function replaceCB (match, contents, offset, input_string)
{
nalezeno[nalezeno.length] = match;
//return "----------------------------".substring(0,match.length);
return '<span class="red">'+match+'</span>'
}

function detekce0(arr,str)
{
var i, i_end;
i_end = arr.length;
for(i=0;i<i_end;i++)
	{
	patt = arr[i];
	patt = regexpEscape(patt);
	slovnik[slovnik.length] = patt;
	str  = str.replace(new RegExp(patt,'gmi'),replaceCB);
	}
return str;
}

function detekce1(arr,str)
{
var i, i_end, j, j_end, k, patt_main, patt, patt_arr;
i_end = arr.length;
patt_arr = [];
k = 0;
for(i=0;i<i_end;i++)
	{
	patt_main = arr[i];
	patt_arr[k] = regexpEscape(patt_main);
	k++
	j_end = patt_main.length;
	for(j=0;j<j_end;j++)
		{
		patt = patt_main;
		patt = patt.substring(0,j)+'*'+patt.substring(j+1);
		slovnik[slovnik.length] = patt;
		patt_arr[k] = regexpEscape(patt);
		k++;
		}
	}
str = str.replace(new RegExp(patt_arr.join('|'),'gmi'),replaceCB);
return str;
}

function zpracuj()
{
var str;
slovnik  = [];
nalezeno = [];
str = $('xxx').value;
//alert(str.toSource());
str = removeTags(str);
str = removeDiacritic(str);
str = str.replace(/[ \t,.!?:;]+/gm,' ');
str = str.replace(/[\n]{2,}/gm,'\n\n');
str = str.replace(/[^A-Za-z \n]/gm,'*');
str = detekce0(slovnik0,str);
str = detekce1(slovnik1,str);
$('upraveno').innerHTML = str.replace(/\n/g,'<br>');	// zmenit \n na <br>
$('nalezeno').value = nalezeno.join('\n');
$('slovnik').value  = slovnik.join('\n');
return false;
}

var slovnik0, slovnik1, nalezeno, slovnik;
slovnik0 = [
"waste of oxygen",
"end ur purposeless existence",
"end your purposeless existence"
];
slovnik1 = [
"fuck",
"shit",
"sht",
"fck",
"abortion",
"toxic",
"kys",
"bad",
"spam",
"unraked",
"kill",
"noob",
"ban"
];

zpracuj();
</script>
