Skip to content

Instantly share code, notes, and snippets.

@adeelnasir adeelnasir/onload.js Secret
Last active May 9, 2018

Embed
What would you like to do?
ADFS onload.js branding
// **********************************************
// Customized load process from here...
// **********************************************
//Function used to set HRD based on the dropdown selection
function SetHRD(selectedHRD)
{
if(selectedHRD.value==="0")
return false;
else if (typeof HRD !== "undefined") {
HRD.selection(selectedHRD.value);
return false;
}
}
//Load JQuery and do customization
(function () {
function loadScript(url, callback) {
var script = document.createElement("script");
script.type = "text/javascript";
console.log('Loading jQuery');
if (script.readyState) { //IE
script.onreadystatechange = function () {
if (script.readyState === "loaded" || script.readyState === "complete") {
script.onreadystatechange = null;
callback();
}
};
} else { //Others
script.onload = function () {
callback();
};
}
script.src = url;
document.getElementsByTagName("head")[0].appendChild(script);
}
loadScript("/adfs/portal/script/jquery-3.min.js", function () {
// jQuery loaded
console.log('jQuery loaded');
//Check if we are displaying the hrd page
var myCheckHRD = document.getElementById('hrdArea') ;
if ( myCheckHRD ) {
var sel = $('<select id="idp" onchange="SetHRD(this)" tabindex="1"/>');
sel.append('<option value="0">Choose Your AD FS</option>');
var adIdp= $(".idp[onclick*='AD AUTHORITY']");
var onclickattr=$(adIdp).attr("onclick");
var startIndex= onclickattr.indexOf('(')+2;
onclickattr= onclickattr.substr(startIndex);
var endIndex = onclickattr.length-17;
onclickattr=onclickattr.substr(0,endIndex);
sel.append("<option value='"+onclickattr+"'>Active Directory</option>");
$(".idp[onclick*='adfs']").each(function(){// div
onclickattr=$(this).attr("onclick");
startIndex= onclickattr.indexOf('(')+2;
onclickattr= onclickattr.substr(startIndex);
endIndex = onclickattr.length-17;
onclickattr=onclickattr.substr(0,endIndex);
sel.append('<option value='+onclickattr+'>'+this.innerHTML+'</option>');
});
$('.idp').hide();
$(sel).insertAfter('#openingMessage');
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.