Commit 76ae1e79 authored by haemmer's avatar haemmer

Introduced new EW option wayf_overwrite_from_other_federations_text

Code refactoring
Categories in the drop down list are now only shown if they are not empty
parent abbd8609
......@@ -39,6 +39,8 @@ SWITCHwayf Version History
The logos will be dynamically loaded and only if they are visible
- Added new setting $showNumOfPreviouslyUsedIdPs to standalone and embedded
WAYF to show last n used IdPs at top of drop down list. Default is 3.
- Added Embedded WAYF option wayf_overwrite_from_other_federations_text
to overwrite the category name of IdPs from other federations
- Various Javascript improvements to offload computation from WAYF to client
- Replaced the term 'Home Organisation' in the language strings to more
generic terms that probably are better understood by users.
......
......@@ -196,6 +196,10 @@ var wayf_return_url = "https://my-app.switch.ch/aai/index.php?page=show_welcome"
// [Optional, default: none]
// var wayf_overwrite_last_used_idps_text = 'Previously used';
// Overwrites the category name of IdPs from other federations in the drop-down list
// [Optional, default: none]
// var wayf_overwrite_from_other_federations_text = 'Other organisations';
// Whether to hide the WAYF after the user was logged in
// This requires that the _shib_session_* cookie is set when a user
// could be authenticated
......
......@@ -29,6 +29,12 @@ var wayf_auto_login;
var wayf_logged_in_messsage;
var wayf_hide_after_login;
var wayf_most_used_idps;
var wayf_overwrite_last_used_idps_text;
var wayf_overwrite_most_used_idps_text;
var wayf_overwrite_checkbox_label_text;
var wayf_overwrite_submit_button_text;
var wayf_overwrite_intro_text;
var wayf_overwrite_from_other_federations_text;
var wayf_num_last_used_idps;
var wayf_show_categories;
var wayf_hide_categories;
......@@ -116,6 +122,10 @@ function writeOptGroup(IdPElements, category){
return;
}
if (IdPElements == ''){
return;
}
var categoryName = wayf_categories[category].name;
if (wayf_show_categories){
......@@ -261,9 +271,12 @@ function isShibbolethSession(url){
function loadDiscoFeedIdPs(){
var result = queryGetURL(wayf_discofeed_url);
var IdPs = {};
// Load JSON
var IdPs = eval("(" +result + ")");
if (result != ''){
IdPs = eval("(" +result + ")");
}
return IdPs;
}
......@@ -767,6 +780,55 @@ function loadImprovedDropDown(){
){
wayf_most_used_idps = new Array();
}
if(
typeof(wayf_logged_in_messsage) == "undefined"
|| typeof(wayf_logged_in_messsage) != "string"
){
wayf_logged_in_messsage = "<?php echo $loggedInString ?>".replace(/%s/, wayf_return_url);
}
if(
typeof(wayf_overwrite_last_used_idps_text) == "undefined"
|| typeof(wayf_overwrite_last_used_idps_text) != "string"
){
wayf_overwrite_last_used_idps_text = "<?php echo $lastUsedIdPsString ?>";
}
if(
typeof(wayf_overwrite_most_used_idps_text) == "undefined"
|| typeof(wayf_overwrite_most_used_idps_text) != "string"
){
wayf_overwrite_most_used_idps_text = "<?php echo $mostUsedIdPsString ?>";
}
if(
typeof(wayf_overwrite_checkbox_label_text) == "undefined"
|| typeof(wayf_overwrite_checkbox_label_text) != "string"
){
wayf_overwrite_checkbox_label_text = "<?php echo $rememberSelectionText ?>";
}
if(
typeof(wayf_overwrite_submit_button_text) == "undefined"
|| typeof(wayf_overwrite_submit_button_text) != "string"
){
wayf_overwrite_submit_button_text = "<?php echo $loginString ?>";
}
if(
typeof(wayf_overwrite_intro_text) == "undefined"
|| typeof(wayf_overwrite_intro_text) != "string"
){
wayf_overwrite_intro_text = "<?php echo $loginWithString ?>";
}
if(
typeof(wayf_overwrite_from_other_federations_text) == "undefined"
|| typeof(wayf_overwrite_from_other_federations_text) != "string"
){
wayf_overwrite_from_other_federations_text = "<?php echo $otherFederationString ?>";
}
if(
typeof(wayf_show_categories) == "undefined"
......@@ -881,12 +943,8 @@ function loadImprovedDropDown(){
} else {
// Else draw embedded WAYF
// Do we have to draw custom text? or any text at all?
if(typeof(wayf_overwrite_intro_text) == "undefined"){
writeHTML('<label for="user_idp" id="wayf_intro_label" style="float:left; min-width:80px; font-size:' + wayf_font_size + 'px;color:' + wayf_font_color + ';"><?php echo $loginWithString ?></label>');
} else if (wayf_overwrite_intro_text != "") {
writeHTML('<label for="user_idp" id="wayf_intro_label" style="float:left; min-width:80px; font-size:' + wayf_font_size + 'px;color:' + wayf_font_color + ';">' + wayf_overwrite_intro_text + '</label>');
}
// Draw intro text
writeHTML('<label for="user_idp" id="wayf_intro_label" style="float:left; min-width:80px; font-size:' + wayf_font_size + 'px;color:' + wayf_font_color + ';">' + wayf_overwrite_intro_text + '</label>');
var wayf_authReq_URL = '';
var form_start = '';
......@@ -998,12 +1056,15 @@ function loadImprovedDropDown(){
// Last used
if (wayf_show_categories == true && wayf_num_last_used_idps > 0 && last_idps.length > 0){
if(typeof(wayf_overwrite_most_used_idps_text) == "undefined"){
writeHTML('<optgroup label="<?php echo $lastUsedIdPsString ?>">');
} else {
writeHTML('<optgroup label="' + wayf_overwrite_last_used_idps_text + '">');
// Add new category
var category = "wayf_last_used_idps";
wayf_categories.wayf_last_used_idps = {
"type": category,
"name": wayf_overwrite_last_used_idps_text
}
var IdPElements = '';
var counter = wayf_num_last_used_idps;
for ( var i= (last_idps.length - 1); i >= 0; i--){
......@@ -1016,31 +1077,33 @@ function loadImprovedDropDown(){
if (content != ''){
counter--;
writeHTML(content)
IdPElements += content;
}
}
writeHTML('</optgroup>');
writeOptGroup(IdPElements, category);
}
// Favourites
// Most used and Favourites
if (wayf_show_categories == true && wayf_most_used_idps.length > 0){
if(typeof(wayf_overwrite_most_used_idps_text) == "undefined"){
writeHTML('<optgroup label="<?php echo $mostUsedIdPsString ?>">');
} else {
writeHTML('<optgroup label="' + wayf_overwrite_most_used_idps_text + '">');
// Add new category
var category = "wayf_most_used_idps";
wayf_categories.wayf_most_used_idps = {
"type": category,
"name": wayf_overwrite_most_used_idps_text
}
// Show most used IdPs in the order they are defined
var IdPElements = '';
for ( var i=0; i < wayf_most_used_idps.length; i++){
if (wayf_idps[wayf_most_used_idps[i]]){
var content = getOptionHTML(wayf_most_used_idps[i]);
writeHTML(content);
IdPElements += getOptionHTML(wayf_most_used_idps[i]);
}
}
writeHTML('</optgroup>');
writeOptGroup(IdPElements, category);
}
// Draw drop down list
......@@ -1071,27 +1134,28 @@ function loadImprovedDropDown(){
category = idp_type;
}
// Output last remaining elements
// Output last remaining element
writeOptGroup(IdPElements, category);
// Show IdPs from other federations
if ( ! isEmptyObject(wayf_other_fed_idps)){
if (wayf_show_categories == true){
writeHTML('<optgroup label="<?php echo $otherFederationString ?>">');
// Add new category
var category = "wayf_other_federations_idps";
wayf_categories.wayf_other_federations_idps = {
"type": category,
"name": wayf_overwrite_from_other_federations_text
}
// Show additional IdPs
var IdPElements = '';
for (entityID in wayf_other_fed_idps){
if (isAllowedIdP(entityID)){
var content = getOptionHTML(entityID)
writeHTML(content);
IdPElements += getOptionHTML(entityID)
}
}
if (wayf_show_categories == true){
writeHTML('</optgroup>');
}
writeOptGroup(IdPElements, category);
}
writeHTML('</select>');
......@@ -1111,13 +1175,8 @@ function loadImprovedDropDown(){
writeHTML('<input id="wayf_remember_checkbox" type="checkbox" name="session" value="true" <?php echo $checkedBool ?>>&nbsp;');
}
// Do we have to display custom text?
if(typeof(wayf_overwrite_checkbox_label_text) == "undefined"){
writeHTML('<label for="wayf_remember_checkbox" id="wayf_remember_checkbox_label" style="min-width:80px; font-size:' + wayf_font_size + 'px;color:' + wayf_font_color + ';"><?php echo $rememberSelectionText ?></label>');
} else if (wayf_overwrite_checkbox_label_text != "") {
writeHTML('<label for="wayf_remember_checkbox" id="wayf_remember_checkbox_label" style="min-width:80px; font-size:' + wayf_font_size + 'px;color:' + wayf_font_color + ';">' + wayf_overwrite_checkbox_label_text + '</label>');
}
// Draw label
writeHTML('<label for="wayf_remember_checkbox" id="wayf_remember_checkbox_label" style="min-width:80px; font-size:' + wayf_font_size + 'px;color:' + wayf_font_color + ';">' + wayf_overwrite_checkbox_label_text + '</label>');
} else if (wayf_force_remember_for_session){
// Is the checkbox forced to be checked but hidden
writeHTML('<input id="wayf_remember_checkbox" type="hidden" name="session" value="true">&nbsp;');
......@@ -1125,12 +1184,8 @@ function loadImprovedDropDown(){
writeHTML('</div>');
// Do we have to display custom text?
if(typeof(wayf_overwrite_submit_button_text) == "undefined"){
writeHTML('<input id="wayf_submit_button" type="submit" name="Login" accesskey="s" value="<?php echo $loginString ?>" style="float: right;" onClick="javascript:return submitForm();">');
} else {
writeHTML('<input id="wayf_submit_button" type="submit" name="Login" accesskey="s" value="' + wayf_overwrite_submit_button_text + '" style="float: right;" onClick="javascript:return submitForm();">');
}
// Draw submit button
writeHTML('<input id="wayf_submit_button" type="submit" name="Login" accesskey="s" value="' + wayf_overwrite_submit_button_text + '" style="float: right;" onClick="javascript:return submitForm();">');
// Close form
writeHTML('</form>');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment