Bulk Safe Id Converted within VF page

I just found a way to convert Ids to the safe format using javascript in visualforce page. You can see the demo in the followoing link.
                                                                   Click Here bulk_sf_safe_id_covert
Code:
<apex:page showHeader="false" sidebar="false" standardStylesheets="false" docType="html-5.0" language="en-US" applyHTMLTag="false">
<html>
<body>


<center>
<h1>Convert Salesforce Ids from 15 to 18 characters</h1><br/><br/>
<textarea id="J" style="height:400px;min-height:200px;width:320px"></textarea>
<button onclick='javascript:
 if(document.getElementById("J").value==""){
  alert("Please enter into the left column a list of IDs on 15 chars");
  return;
 }
 var y=document.getElementById("J").value.split("\r").join("").split("\n");
 var z=new Array();
 for(var x=0;x<y.length;x++){
  if(y[x].length==15){var s="";for(var i=0;i<3; i++){
   var f=0;
   for(var j=0;j<5;j++){
    var c=y[x].charAt(i*5+j);
    if(c>="A" && c<="Z")f+=1<<j;
   }
   s+="ABCDEFGHIJKLMNOPQRSTUVWXYZ012345".charAt(f);
  }
  z.push(y[x]+s);
  }else{
   alert("Error : "+y[x]+" has not a length of 15 characters"+y[x].length);return;
  }
 }
 document.getElementById("L").value=z.join("\r\n");'
 >15 => 18</button>
<textarea id="L" style="height:400px;min-height:200px;width:320px"></textarea>
</center>

</body>
</html>
</apex:page>

Comments