Permalink
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
inc-md-js/info/js/all-orgs-inspector.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
69 lines (57 sloc)
2.04 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* InCommon Federation Organization Inspector. | |
* | |
* Displays all organization metadata. | |
* | |
*/ | |
// helps prevent a "flash of unstyled content" | |
$('html').addClass('js'); | |
$(document).ready(function () { | |
"use strict"; | |
$('#page-content').hide().ajaxStop( | |
function () { $(this).show(); } | |
); | |
$("#loading").ajaxStart(function () { | |
// the image is 31x31 pixels | |
var x = Math.round((document.body.clientWidth - 31) / 2); | |
$(this).css('left', x); | |
$(this).show(); | |
}).ajaxStop(function () { $(this).hide(); }); | |
// handle successful ajax call for all entity metadata | |
var handleDone = function (entities) { | |
var i, entity, orgName, orgDisplayName, orgURL; | |
var orgsByName = [], orgsByDisplayName = []; | |
// dynamically build a list of organization objects | |
for (i = 0; i < entities.length; i += 1) { | |
entity = new SAMLEntity(entities[i]); | |
orgName = entity.getOrganizationName(); | |
orgDisplayName = entity.getOrganizationDisplayName(); | |
orgURL = entity.getOrganizationURL(); | |
if (!(orgsByName[orgName] instanceof Object)) { | |
orgsByName[orgName] = {}; | |
orgsByName[orgName].orgDisplayName = orgDisplayName; | |
orgsByName[orgName].orgURL = orgURL; | |
} | |
if (!(orgsByDisplayName[orgDisplayName] instanceof Object)) { | |
orgsByDisplayName[orgDisplayName] = {}; | |
orgsByDisplayName[orgDisplayName].orgName = orgName; | |
orgsByDisplayName[orgDisplayName].orgURL = orgURL; | |
orgsByDisplayName[orgDisplayName].mustFixOrgDisplayName = false; | |
if (orgsByName[orgName].orgDisplayName !== orgDisplayName) { | |
orgsByDisplayName[orgDisplayName].mustFixOrgDisplayName = true; | |
} | |
orgsByDisplayName[orgDisplayName].mustFixOrgURL = false; | |
if (orgsByName[orgName].orgURL !== orgURL) { | |
orgsByDisplayName[orgDisplayName].mustFixOrgURL = true; | |
} | |
} | |
} | |
// insert the metadata | |
$.insertListAllOrgs(orgsByDisplayName); | |
}; | |
// handle failed ajax call for all entity metadata | |
var handleFail = function () { | |
$.displayErrorMsg("Unable to retrieve all entity metadata"); | |
}; | |
$.getJSONMetadata4AllEntities(handleDone, handleFail); | |
}); |