Peasant Translator

by Gaurav Gandhi

HTML

<h1 id="title">Peasant Speak</h1>
<textarea rows="4" cols="60" id="words"></textarea><br/>
<button onclick="myFunction()">Translate</button>
<p id="demo"></p>

JavaScript

console_dict = {  
    'ait|ate':'8',
    '(be){0,1}cause|be.*coz|coz':'cuz',
    'see':'c',      
    'it\'s':'its',
    'there':'their',
    'you\'re':'your',
    'you':'u',
    'master.*race':'mustard',
    'ter':'tar',
    'gaben':'geybin',
    ' pc ':' peesee ',
    'th':'d',
    'hack':'huck',
    'a':'4',
    'd':'c|',
    'e':'3',
    'i':'1',
    's( |$)':'z ',
    ' s':' $',
    's':'5',
    'o':'0',
    't':'7',
    'w':'\\/\\/'
}
function myFunction() {
    
   var text = document.getElementById('words').value;
   if( text.length==0 ){
       alert('Write Some real Text please.');
       return;
   }

   for (key in console_dict) {     
       text = text.replace(new RegExp(key, 'gi'),console_dict[key]);       
   }
    
   document.getElementById("demo").innerHTML = text;
}