PDA

View Full Version : Et


101
10-25-2002, 09:14 AM
Hi,
Bettle made most of this script but there is one big bug in it...i think.
The translator goes throught the text and translates them using the words.
Then it goes through the text again and replaces any characters it can.
The only probelm is that if it is translated a word using the words it still goes throught that word with the characters.
(Words Are exceptions to the character rule so this is a problem)

So i was think of doing something like this after the translation of words:
If
A Word Already Translated Using Words
Leave
Else
Translate Other Words Using Characters

Can anyone help me?



<HTML>
<HEAD>
<TITLE>
</TITLE>
</HEAD>
<BODY>

<Script Language="JavaScript">

var copytoclip=1

function HighlightAll(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
if (document.all&&copytoclip==1){
therange=tempval.createTextRange()
therange.execCommand("Copy")
window.status="Contents Highlighted And Copied To Keyboard!"
setTimeout("window.status=''",0)
}
}

</Script>

<Script Language="JavaScript">

function clr()
{
document.f.ff1.value=""
}
</Script>

<Script Language="JavaScript">

function CheckIt(WElem,DLimit){
DWords=document.f["ff"+WElem].value;
if(DWords.length>=DLimit){
DWords=DWords.slice(0,DLimit);
document.f["ff"+WElem].value=DWords;
}
Mess=DWords.length+"/"+DLimit;
if (document.getElementById) {document.getElementById("B"+WElem).innerHTML = Mess}
else if (document.all) {document.all["B"+WElem].innerHTML = Mess}
else if (document.layers) {document.layers["B"+WElem].innerHTML = Mess}
else{}
}

</Script>

<Script Language="JavaScript">

var eliteWords = [
['pheer','fear'],
['skillz','skills'],
['sux0rz','suck'],
['f00','fool'],
['b0xx0rz','boxers'],
['n00b','newbie'],
['j00r','your'],
['j00','you'],
['r0x0rez','rocks'],
['r0x0r','rock'],
['quaek','quake'],
['quaekworld','quakeworld'],
['quaek2','quake2'],
['quaek3','quake3'],
['pr0n','porn'],
['0wned','owned'],
['0wn','own'],
['0wnz','owns'],
['mp3z','mpes'],
['teh','the'],
['hax0red','hacked'],
['hax0r','hacker'],
['l337','elite'],
['d00dz','dudes'],
['d00d','dude'],
['k3wl','cool']
];
var eliteChars = [
['4','a'],
['8','b'],
['k','c'],
['d','d'],
['3','e'],
['ph','f'],
['6','g'],
['h','h'],
['1','i'],
['j','j'],
['k','k'],
['L','l'],
['m','m'],
['n','n'],
['0','o'],
['p','p'],
['q','q'],
['r','r'],
['5','s'],
['7','t'],
['u','u'],
['v','v'],
['w','w'],
['x','x'],
['y','y'],
['z','z']
];

var englishWords = [
['fear','pheer'],
['skills','skillz'],
['suck','sux0rz'],
['fool','f00'],
['boxers','b0xx0rz'],
['newbie','n00b'],
['your','j00r'],
['you','j00'],
['rocks','r0x0rez'],
['rock','r0x0r'],
['quake','quaek'],
['quakeworld','quaekworld'],
['quake2','quaek2'],
['quake3','quaek3'],
['pron','p0rn'],
['owned','0wned'],
['own','0wn'],
['owns','0wnz'],
['mpes','mp3z'],
['the','teh'],
['hacked','hax0red'],
['hacker','hax0r'],
['elite','l337'],
['dudes','d00dz'],
['dude','d00d'],
['cool','kewl']
];
var englishChars = [
['a','4'],
['b','8'],
['c','k'],
['d','d'],
['e','3'],
['f','ph'],
['g','6'],
['h','h'],
['i','1'],
['j','j'],
['k','k'],
['l','L'],
['m','m'],
['n','n'],
['o','0'],
['p','p'],
['q','q'],
['r','r'],
['s','5'],
['t','7'],
['u','u'],
['v','v'],
['w','w'],
['x','x'],
['y','y'],
['z','z']
];

function translateElite() {
var txta = document.f.ff1;
for (i=0; i<eliteWords.length; i++) {
var r = new RegExp(eliteWords[i][1],"gi");
txta.value = txta.value.replace(r,eliteWords[i][0]);
}
for (i=0; i<eliteChars.length; i++) {
var r = new RegExp(eliteChars[i][1],"gi");
txta.value = txta.value.replace(r,eliteChars[i][0]);
}
}

function translateEnglish() {
var txta = document.f.ff1;
for (i=0; i<englishWords.length; i++) {
var r = new RegExp(englishWords[i][1],"gi");
txta.value = txta.value.replace(r,englishWords[i][0]);
}
for (i=0; i<englishChars.length; i++) {
var r = new RegExp(englishChars[i][1],"gi");
txta.value = txta.value.replace(r,englishChars[i][0]);
}
}

</Script>

<FONT size=6>
<B>Elite Translator</B>
</FONT>

<form name="f">
Please Type In Text:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Characters:
<span id="B1">0/10000</span>
<BR>
<textarea name="ff1" cols="68" rows="8" onkeydown="CheckIt(1,10000)" onkeyup="CheckIt(1,10000)" onblur="CheckIt(1,10000)"></textarea>
<BR>
<BR>
<input type="button" value=" Translate To Elite " name="go" onclick="translateElite()">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" value=" Translate To English " name="go" onclick="translateEnglish()">
<BR>
<input type="button" value=" Clear Text " name="clear" onclick="javascript:clr()">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" value=" Copy To Keyboard " onclick="HighlightAll('f.ff1');">
<BR>
</form>

</BODY>
</HTML>

WA
10-25-2002, 12:02 PM
101, please use a more descriptive subject when posting in the future. Also, this thread probably would have been better posted as a reply to the script in question, rather than as a new thread.

See our posting guidelines here: http://www.codingforums.com/postguide.htm