Progress bar for custom button

Progress bar for custom button on click salesforce

{!REQUIRESCRIPT("/soap/ajax/36.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/36.0/apex.js")} 
var CaseId = '{!Case.Id}'; 
var sta= '{!Case.status}'; 
if(sta){ 
var result=sforce.apex.execute("ApexClassName","Method",{CaseId:CaseId}); 

var overlay = document.createElement('overlay'); 
overlay.style.background = '#000'; 
overlay.style.position = 'absolute'; 
overlay.style.top='0px'; 
overlay.style.bottom = '0px'; 
overlay.style.right = '0px'; 
overlay.style.left = '0px'; 
overlay.style.zIndex = '1000'; 
overlay.style.opacity='0.7'; 

var loading = document.createElement('img'); 
loading.src = 'https://c.na5050.content.force.com/servlet/servlet.ImageServer?id=014446000001yJpw&oid=00De2323340uNx0'; 
loading.style.position = 'absolute'; 
loading.style.top='50%'; 
loading.style.left = '50%'; 
loading.style.zIndex = '1000'; 

overlay.appendChild(loading); 
document.body.appendChild(overlay); 

if(result!=null && result!='success'){ 

document.body.removeChild(overlay); 
var outerdiv = document.createElement('div'); 
outerdiv.innerHTML = result; 
outerdiv.style.display = 'inline-block'; 
outerdiv.style.fontSize ='14px'; 
outerdiv.style.color = 'red'; 
//outerdiv.style.border = '1px solid grey'; 
outerdiv.style.padding = '10px'; 


var mainDiv = document.createElement('div'); 
mainDiv.style.marginLeft = '30%'; 
mainDiv.style.marginTop = '10px'; 
mainDiv.appendChild(outerdiv); 

document.getElementById('errorDiv_ep').innerHTML = result; 
document.getElementById('errorDiv_ep').style.display=''; 
setTimeout(function(){ 
document.getElementById('errorDiv_ep').innerHTML = ''; 
document.getElementById('errorDiv_ep').style.display='none'; 
},5000); 


}else{ 
document.location.reload(true); 

}else{ 
alert('You can not revert back the case to Queue.'); 
document.getElementById('errorDiv_ep').innerHTML = 'You can not close the case.'; 
document.getElementById('errorDiv_ep').style.display=''; 
setTimeout(function(){ 
document.getElementById('errorDiv_ep').innerHTML = ''; 
document.getElementById('errorDiv_ep').style.display='none'; 
},5000); 
}

Custom Buttons in Service Cloud Console

Custom Buttons  in Service Cloud Console


{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
{!REQUIRESCRIPT('/soap/ajax/35.0/apex.js')} 
{!REQUIRESCRIPT("/support/console/28.0/integration.js")}
//identify the id 
var c = new sforce.SObject("case"); 
c.id = "{!Case.Id}"; 
var Cstatus= "{!Case.Status}"; 
var resultOk = confirm("Are you sure,you want to clone the case"); 
if(resultOk){ 
var result = sforce.apex.execute("Casecloningfrombutton","cloneCaseList",{caseIds:"{!Case.Id}"}); 
alert(result);
if(result!=null){ 
var redirectUrl = '/'+result;
if (sforce.console.isInConsole()) {
sforce.console.getEnclosingTabId(function(enclosingResult){
sforce.console.getEnclosingPrimaryTabId(function(primaryResult){
sforce.console.openSubtab(primaryResult.id, redirectUrl, true, '', null);
});
});
}else{
window.location.href = redirectUrl;
}
}else{ 
alert('Insert failed - please contact with system admin'); 
}