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-entities-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.
81 lines (70 sloc)
2.31 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-entities.js | |
* | |
* @see http://enterprisejquery.com/2010/10/how-good-c-habits-can-encourage-bad-javascript-habits-part-1/ | |
*/ | |
(function ($) { | |
"use strict"; | |
// insert list of all IdPs into the DOM | |
$.insertListAllIdPs = function (idp_entities) { | |
// insert the number of IdP entities | |
$('#idps-tab > a').append(' (' + idp_entities.length + ')'); | |
var i, entity, displayName, divElement, first_letter; | |
// dynamically build the list of IdP entities | |
for (i = 0; i < idp_entities.length; i += 1) { | |
entity = new SAMLEntity(idp_entities[i]); | |
displayName = entity.getDefaultDisplayName(); | |
if (/^http/.test(displayName) || | |
/^[^a-zA-Z]/.test(displayName)) { | |
divElement = '#idpOther'; | |
} else { | |
first_letter = displayName.charAt(0); | |
divElement = '#idp' + first_letter.toUpperCase(); | |
} | |
$('<div/>').append( | |
$('<a/>').attr({ | |
'href': entity.getEntityInfoURL(), | |
'class': 'entity_link' | |
}).text(displayName) | |
).appendTo(divElement); | |
} | |
}; | |
// insert list of all SPs into the DOM | |
$.insertListAllSPs = function (sp_entities) { | |
// insert the number of SP entities | |
$('#sps-tab > a').append(' (' + sp_entities.length + ')'); | |
var i, entity, displayName, divElement, first_letter; | |
var numUnnamedSPs = 0; | |
// dynamically build the list of SP entities | |
for (i = 0; i < sp_entities.length; i += 1) { | |
entity = new SAMLEntity(sp_entities[i]); | |
displayName = entity.getDefaultDisplayName(); | |
if (/^http/.test(displayName) || | |
/^[^a-zA-Z]/.test(displayName)) { | |
divElement = '#spOther'; | |
numUnnamedSPs++; | |
} else { | |
first_letter = displayName.charAt(0); | |
divElement = '#sp' + first_letter.toUpperCase(); | |
} | |
$('<div/>').append( | |
$('<a/>').attr({ | |
'href': entity.getEntityInfoURL(), | |
'class': 'entity_link' | |
}).text(displayName) | |
).appendTo(divElement); | |
} | |
// compute the number of unnamed SPs (hopefully, this is temporary) | |
$('<span/>') | |
.attr('id', 'num_unnamed_SPs') | |
.css('font-size', 'smaller') | |
.appendTo("#SPs_Other"); | |
$('#num_unnamed_SPs').append("(" + numUnnamedSPs + " SPs don't yet have "); | |
var sp_mdui_url = 'https://spaces.internet2.edu/x/-5WAAQ'; | |
$('<a/>') | |
.attr('href', sp_mdui_url) | |
.html('display names in metadata') | |
.appendTo("#num_unnamed_SPs"); | |
$('#num_unnamed_SPs').append(")"); | |
}; | |
}(jQuery)); |