Decoder

Geek Koder /** * @description Geek Code Decoder (originally written Extension for Firefox ) * @author Bhasker V Kode * @date hacked up in the early hours of Feb 23,2007 . * @copyright Some Rights Reserved * @licence Mozilla Public Licence 1.1 */ var geekKoder = function(code){ this.init(); } geekKoder.prototype = { words :Array(), kode : Array(), init :function(){ this.status = document.getElementById(‘geekKoderCtr’); this.codeDiv = document.getElementById(‘geekcodeDiv’); }, run :function(code){ this.codeDiv = document.getElementById(‘geekcodeDiv’); this.clear(); this.code = code; this.doPass1(code); this.doPass2(); }, doPass1 : function(code){ this.words = code.split(‘ ‘); }, doPass2 : function(){ for(var i=0 ; i @ ? 3. has ranging from to – the () operator 4. the s__:__ handling */ var str = this.words[i]; for(var operator in geekKoder.geekcode[“vars”]){ if(str.indexOf(operator) >0 ){ //console.log(‘operator is ‘+operator+’….’+str.split(operator)); } /* FOR C++(++++) operator is (….C++,++++) operator is )….C++(++++, operator is (….C++,++++) operator is )….C++(++++, */ } if(str.indexOf(‘(‘)>0){ var re = new RegExp(‘[?=^0-9a-zA-Z()]’ ,’g’); var symbol = str.match(re); var args = str.split(/[?!^0-9a-zA-Z()\s]/) ; if(category.toString()[0]==str.toString()[0]){ this.add(category,”Ranging from …”+geekKoder.geekcode[category][symbol[0]+args[1]]+’…to…’+geekKoder.geekcode[category][symbol[0]+args[2]],1); } } var slabs = str.split(‘/’); if(slabs.length>1){ //console.log(‘found /’); //TO DO handle single and multiple /’s if(category.toString()[0]==str.toString()[0]){ var _temp=slabs[0]; this.add(category,geekKoder.geekcode[“types”][_temp],1); for(var k=1;k<slabs.length;k++){ _temp=slabs[0][0]+slabs[k]; this.add(category,geekKoder.geekcode["types"][_temp],0); } } }else{ for(var value in geekKoder.geekcode[category]){ //console.log(value); if(str==value){ this.add(category,geekKoder.geekcode[category][value],1); }else{ //not handled } } } } this.update(i+1); } }, add :function(category,value,isNewCateg){ var _d=document.createElement('div'); if (isNewCateg){ _d.innerHTML = '
‘ + geekKoder.geekcode[“legend”][category]+’
‘ +value+’
‘; }else{ _d.innerHTML = value; } this.results.appendChild(_d); }, set :function(code){ this.codeDiv.value = code; }, get :function(){ return this.codeDiv.value; }, update : function(ctr){ var _p = new Number( (ctr*100)/parseInt(this.words.length,10) ) ; _str = ‘Processing Time: ‘+ _p +’ % . Recognized ‘+ctr+’ out of ‘+this.words.length+’ geek codes.’; this.status.innerHTML = _str; }, clear : function (){ if(document.getElementById(‘geekKode’)!=undefined){ document.getElementById(‘geekKode’).parentNode.removeChild(this.results); } this.results=document.createElement(‘div’); this.results.id = ‘geekKode’; document.body.appendChild(this.results); } }; var str1 = “GED/J d– a– C++(++++) ULU++ P+ L++ E—- W+(-) N+++ o+ K+++ w— O- M+ V– Y++ PGP++ t- 5+++ X++ R+++ tv+ b+ DI+++ D+++ G+++++ e++ h r– x++”; var str2 = “GED/J d– C++(++++)”; function init(){ gK = new geekKoder(); gK.set(str1); } function kode(){ gK.run(gK.get()); } body{ font-family:Georgia, “Times New Roman”, Times, serif; padding-left:50px; border-left:1px dashed gray; } .geeky{ font-family:’Courier New’, Courier, monospace;font-size:12px;margin-left:50px;width:60%; } .beta{ position:relative; top:+12px; left:+3px; color:#660066; } .h1{ font-size:24px; border-bottom:6px solid #660066; } .h2{ padding-top: 10px; font-size:20px; } .note{ font-size:18px; } .todo{ padding-left:75px; } geekkoderbeta