Skip to content
Permalink
master
Switch branches/tags

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?
Go to file
Latest commit dec871f Jan 3, 2018 History
0 contributors

Users who have contributed to this file

72 lines (60 sloc) 1.84 KB
/**
* DOM helper for all-orgs.js
*
*/
(function ($) {
"use strict";
/**
* Insert a list of orgs into the DOM.
*
* @param {Object[orgName]} orgsByName An associative array of orgs indexed by orgName.
* @param orgsByName[orgName].idps[] An array of IdPs owned by the org with given orgName.
* @param orgsByName[orgName].sps[] An array of SPs owned by the org with given orgName.
*/
$.insertListAllOrgs = function (orgsByName) {
var orgName, entity, rowElement;
var numOrgs = 0, numIdPs = 0, numSPs = 0;
// dynamically build the list of organizations
for (orgName in orgsByName) {
// choose a representative entity (there is at least one)
if (orgsByName[orgName].idps.length > 0) {
entity = orgsByName[orgName].idps[0];
} else {
entity = orgsByName[orgName].sps[0];
}
// build up a row of org info
rowElement = $('<tr/>');
$('<td/>').html(
$('<a/>').attr({
'href': entity.getOrgInfoURL(),
'class': 'org_link'
}).text(entity.getOrganizationDisplayName())
).appendTo(rowElement);
$('<td/>')
.addClass('entity-count')
.text(orgsByName[orgName].idps.length)
.appendTo(rowElement);
$('<td/>')
.addClass('entity-count')
.text(orgsByName[orgName].sps.length)
.appendTo(rowElement);
// insert a row of org info into the DOM
rowElement.appendTo('#list-of-orgs');
// count orgs
numOrgs += 1;
// accumulate entity counts
numIdPs += orgsByName[orgName].idps.length;
numSPs += orgsByName[orgName].sps.length;
}
// insert the number of organizations
$('#numOrgs').append(numOrgs);
// insert the total number of IdPs and SPs
$('#numIdPs').append(numIdPs);
$('#numSPs').append(numSPs);
// initialize column sorting
$('#list-of-orgs').tablesorter({
// initial sort on the first column, order ascending
sortList: [[0,0]]
});
};
}(jQuery));