Friday, June 21, 2013

Analys the webpage response time related problems - Using yslow add-on

YSlow


YSlow analyzes web pages and suggests ways to improve their performance based on a set of rules for high performance web pages.
http://yslow.org is the official open source website.

This add-on requires the following add-ons to work properly:

Wednesday, June 19, 2013

Salesforce Code Scanner - Analyse source code



The Force.com Security Source Scanner is a cloud based source code analysis tool built directly into our Force.com offering. Salesforce.com has made it available to all of its developers, for free, as a high value addition, which will help to enable our community to build trusted applications.

Code is scanned on a first come, first serve basis. Depending on the size and complexity of the code and the queue size, speed of results may vary.

You can run the code scanner through this URL


http://security.force.com/security/tools/forcecom/scanner


In this URL you can submit your dev org username , after submit the URL the code analysis result will send to our mail.



Tuesday, June 18, 2013

JAVASCRIPT - MULTIPLE CHECKBOX SELECTION WITH SHIFT KEY PRESS

MULTIPLE CHECKBOX SELECTION WITH SHIFT KEY PRESS

<script>
function checkboxClick(){
       
$(':checkbox').click(function(e){              
if (e.shiftKey){
   // Entered - When the user clicks the checkbox with shift key
shiftCheckBox = $(this).attr('id');
            // salesforce id's having multiple ':' like 'dbpage:dbform:results:j_id173:5:selectStarredCalls'. So we need to split the unique number of the Id
            // If HTML checkbox you dont need to  split the id
var shiftCheckBoxID = shiftCheckBox.split(':');
var shiftCheckBoxIDPos = shiftCheckBoxID[shiftCheckBoxID.length-2];
shiftCheckBoxIDPos = parseInt(shiftCheckBoxIDPos);                
var checkBoxClickID = checkBoxClick.split(':');
var checkBoxClickIDPos = checkBoxClickID[checkBoxClickID.length-2];
checkBoxClickIDPos = parseInt(checkBoxClickIDPos);
// checkboxIdsList - having id's of all checkboxes, When the checkboxes are created, at the time assign all the checkbox id's in this list
var checkboxIdsArray = checkboxIdsList;

if(shiftCheckBoxIDPos > checkBoxClickIDPos){
for(var i=0; i < checkboxIdsArray.length; i++){                          
var innerId = checkboxIdsArray[i];
var splitedInnerId= innerId.split(':');
var splitedInnerIdPos = splitedInnerId[splitedInnerId.length-2];
splitedInnerIdPos = parseInt(splitedInnerIdPos);
if(splitedInnerIdPos > checkBoxClickIDPos && splitedInnerIdPos < shiftCheckBoxIDPos ){
var inBetweenCheckBoxId = checkboxIdsArray[splitedInnerIdPos];
var test = inBetweenCheckBoxId ;                              
document.getElementById(test).checked = true;
  }
}
}else{
for(var j=0; j < checkboxIdsArray.length; j++){
 
var innerId1 = checkboxIdsArray[j];
var splitedInnerId1= innerId1.split(':');
var splitedInnerIdPos1 = splitedInnerId1[splitedInnerId1.length-2];
splitedInnerIdPos1 = parseInt(splitedInnerIdPos1);
if(splitedInnerIdPos1 > shiftCheckBoxIDPos && splitedInnerIdPos1 < checkBoxClickIDPos ){
var inBetweenCheckBoxId1 = checkboxIdsArray[splitedInnerIdPos1];
var test1 = inBetweenCheckBoxId1 ;
document.getElementById(test1).checked = true;
  }
}
}
}else{
            // Id of last clicked checkbox id (Without shift key press )
checkBoxClick = $(this).attr('id');
}
});
}
</script>

Monday, June 17, 2013

JAVASCRIPT FOR GET THE BROWSER NAME & CLICK EVENT

JAVASCRIPT CODE FOR GET THE BROWSER NAME 

window.onload=function(){
 
var nAgt = navigator.userAgent;
var browserName  = navigator.appName;
var nameOffset,verOffset;

if((verOffset=nAgt.indexOf("Opera"))!=-1) {
browserName = "Opera";
}else if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
browserName = "Microsoft Internet Explorer";
}else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) {
browserName = "Chrome";
}else  if ((verOffset=nAgt.indexOf("Safari"))!=-1) {
browserName = "Safari";
}else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
browserName = "Firefox";
}else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/'))) {
browserName = nAgt.substring(nameOffset,verOffset);
if (browserName.toLowerCase()==browserName.toUpperCase()) {
browserName = navigator.appName;
}
}
document.write('::browserName::'+browserName);
}

CLICK EVENT THROUGH JAVASCRIPT 

// In Safari - (Windows OS) javascript click() function doesn't work. So alternatively we can do the click() function like this

                var evObj = document.createEvent('MouseEvents');
evObj.initMouseEvent('click', true, true, window);
document.getElementById('clickedElementId').dispatchEvent(evObj);
Example:

if(browserName == 'Safari'){
var evObj = document.createEvent('MouseEvents');
evObj.initMouseEvent('click', true, true, window);
document.getElementById('clickedElementId').dispatchEvent(evObj);
}else{
   // This code working in all other browsers
document.getElementById('clickedElementId').click();
}

Javascript Character Codes (Key Codes)

WORKING WITH JAVASCRIPT KEY EVENT

 We can get the keycode in key events like onkeyup, onkeydown, onClick, onKeypress.....

window.onkeyup = function (event) {
if(event.keyCode == 38 || event.which == 38){
// here you can put your up arrow functionality code
}else if(event.keyCode == 40 || event.which == 40){      
// here you can put your down arrow functionality code
}   
if (event.keyCode == 27 || event.which == 27) {
// here you can put your esc key functionality code
like window.close();
}
 
}


KeyCode
backspace8
tab9
enter13
shift16
ctrl17
alt18
pause/break19
caps lock20
escape27
page up33
page down34
end35
home36
left arrow37
up arrow38
right arrow39
down arrow40
insert45
delete46
048
149
250
351
452
553
654
755
856
957
a65
b66
c67
d68
 
KeyCode
e69
f70
g71
h72
i73
j74
k75
l76
m77
n78
o79
p80
q81
r82
s83
t84
u85
v86
w87
x88
y89
z90
left window key91
right window key92
select key93
numpad 096
numpad 197
numpad 298
numpad 399
numpad 4100
numpad 5101
numpad 6102
numpad 7103
 
KeyCode
numpad 8104
numpad 9105
multiply106
add107
subtract109
decimal point110
divide111
f1112
f2113
f3114
f4115
f5116
f6117
f7118
f8119
f9120
f10121
f11122
f12123
num lock144
scroll lock145
semi-colon186
equal sign187
comma188
dash189
period190
forward slash191
grave accent192
open bracket219
back slash220
close braket221
single quote222

Salesforce - Generate dynamic inner query to fetch parent and related child records

Use Case: In many scenarios, we need to clone the records with related child records. Issue / Limitation: We may simply use the "cl...