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

104 lines (89 sloc) 3.08 KB
/**
* Display a standalone entity information page.
*
* Two query string parameters are required:
*
* entity.html?entityID=foo&technical=bar
*
* The 'entityID' query string parameter is strictly required.
* If missing, the client will be redirected to the all-entities.html
* webapp. The 'technical' query string parameter is optional. If
* missing, the client will be (transparently) redirected to the
* current window location with technical=false appended.
*
*/
$(document).ready(function () {
"use strict";
$('#entity-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(); });
// The 'linkObj' parameter is a JavaScript Link object
// with one or two query string parameters
(function (linkObj) {
// a redirect page
var redirectPage = "./all-entities.html";
// handle a missing query string
if (linkObj.search == null || linkObj.search == "") {
// redirect the browser
window.location = redirectPage;
return;
}
// get the 'entityID' query string parameter
var entityID = utils.getParameterByName(linkObj, 'entityID');
// handle a missing query string parameter
if (entityID == null || entityID == "") {
// redirect the browser
window.location = redirectPage;
return;
}
// file this away
$.cookiesAreEnabled = function () {
$.cookie('do_not_use_this_key', 'any_value');
var areEnabled = ($.cookie('do_not_use_this_key') === 'any_value');
$.cookie('do_not_use_this_key', null);
return areEnabled;
}
// get the 'technical' query string parameter
var technicalParam = utils.getParameterByName(linkObj, 'technical');
// handle a missing query string parameter
if (technicalParam == null || technicalParam == "") {
// get the 'technical' cookie
var technicalCookie = $.cookie('technical');
if (technicalCookie == null || technicalCookie == "") {
// append a default parameter value
window.location.search += "&technical=false";
return;
} else {
// append the value of the 'technical' cookie
window.location.search += "&technical=" + technicalCookie;
return;
}
}
// set the flag and the 'technical' cookie
var hideTechnicalInfo = (technicalParam === "true") ? false : true;
$.cookie('technical', (hideTechnicalInfo ? 'false' : 'true'));
// handle successful ajax call for metadata
var handleDone = function (metadata) {
// set document title
var displayName = (new SAMLEntity(metadata)).getDefaultDisplayName();
document.title += ": " + displayName;
$.insertEntityMetadata(metadata, hideTechnicalInfo);
};
// handle failed ajax call for metadata
var handleFail = function (jqxhr) {
if (jqxhr.status == "404") {
// oops, bogus entityID
$.displayErrorMsg("Invalid entityID: " + entityID);
return;
}
$.displayErrorMsg("Unable to retrieve entity metadata");
};
$.getJSONMetadata(entityID, handleDone, handleFail);
}(window.location));
});