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

109 lines (89 sloc) 2.81 KB
/**
* InCommon Federation Entities web application.
*/
// helps prevent a "flash of unstyled content"
$('html').addClass('js');
$(document).ready(function () {
"use strict";
$('#page-content').hide();
$("#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(); });
// initialize tabs
var tabIndexIdP = 0, tabIndexSP = 1;
var myTabs = $('#tabs').tabs();
// set the hash in the address bar every time a tab is selected
myTabs.bind('tabsselect', function (event, ui) {
window.location.hash = "#" + ui.panel.id;
});
// determine initial state of tabbed interface
var showIdPsTab, showSPsTab;
var hash = window.location.hash;
if (hash != null) {
if ( /^#IdPs/.test(hash) ) {
showIdPsTab = true; showSPsTab = false;
} else if ( /^#SPs/.test(hash) ) {
showIdPsTab = false; showSPsTab = true;
} else {
showIdPsTab = true; showSPsTab = false;
//window.location.hash = "#IdPs";
}
} else {
showIdPsTab = true; showSPsTab = false;
//window.location.hash = "#IdPs";
}
// comparison function used to sort arrays of entity metadata
var comparison_function = function (a, b) {
var a_key = (new SAMLEntity(a)).getDefaultDisplayName();
var b_key = (new SAMLEntity(b)).getDefaultDisplayName();
return (a_key < b_key) ? -1 : ((a_key > b_key) ? 1 : 0);
};
(function (showThisTab) {
// handle successful ajax call for all IdP metadata
var handleDone = function (entities) {
// sort and insert the metadata
entities.sort(comparison_function);
$.insertListAllIdPs(entities);
if (showThisTab) {
myTabs.tabs('select', tabIndexIdP);
$('#page-content').show();
// scroll if necessary
if ( /^#IdPs_/.test(hash) ) {
window.location.hash = hash;
}
}
};
// handle failed ajax call for all IdP metadata
var handleFail = function () {
$.displayErrorMsg("Unable to retrieve IdP metadata");
};
$.getJSONMetadata4AllIdPs(handleDone, handleFail);
}(showIdPsTab));
(function (showThisTab) {
// handle successful ajax call for all SP metadata
var handleDone = function (entities) {
// sort and insert the metadata
entities.sort(comparison_function);
$.insertListAllSPs(entities);
if (showThisTab) {
myTabs.tabs('select', tabIndexSP);
$('#page-content').show();
// scroll if necessary
if ( /^#SPs_/.test(hash) ) {
window.location.hash = hash;
}
}
};
// handle failed ajax call for all SP metadata
var handleFail = function () {
$.displayErrorMsg("Unable to retrieve SP metadata");
};
$.getJSONMetadata4AllSPs(handleDone, handleFail);
}(showSPsTab));
// handle clicked entity links
var dialogOptions = null; // unused
myTabs.handleClickedEntityLinks(dialogOptions);
});