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-dom.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
72 lines (60 sloc)
1.84 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
/** | |
* 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)); |