lemonldap-ng/modules/lemonldap-ng-portal/example/skins/common/portal.js

112 lines
2.5 KiB
JavaScript
Raw Normal View History

/**
2010-10-22 12:03:42 +02:00
* LemonLDAP::NG Portal jQuery scripts
*/
/* Used variables
* - displaytab
2010-10-22 12:03:42 +02:00
* - choicetab
* - autocomplete
* - login
* - newwindow
2010-10-22 12:03:42 +02:00
* - antiframe
*/
/* Set autocomplete real value */
if(autocomplete.match('1')){autocomplete='on';}
if(autocomplete.match('0')){autocomplete='off';}
2010-10-22 12:03:42 +02:00
/* Set antiframe value (default is true) */
if(antiframe.match('0')){antiframe=false;}else{antiframe=true};
/* jQuery */
$(document).ready(function(){
2010-10-22 12:03:42 +02:00
/* AntiFrame script */
if(antiframe && top!=self){
top.location.href = location.href;
}
/* Display message */
$("div.message").fadeIn('slow');
2010-10-22 12:03:42 +02:00
/* Set timezone */
$("input[name=timezone]").val( -(new Date().getTimezoneOffset()/60) );
2010-10-22 12:03:42 +02:00
/* Menu tabs */
$("#menu").tabs({ fx: { opacity: 'toggle' } });
$("#menu").tabs("select",displaytab);
2010-10-22 12:03:42 +02:00
/* Authentication choice tabs */
$("#authMenu").tabs({
fx: {opacity: 'toggle'},
cookie: {name: 'lemonldapauthchoice'},
});
$("#authMenu").tabs("select",choicetab);
2010-10-22 12:03:42 +02:00
/* Focus on first visible input */
$("input[type!=hidden]:first").focus();
2010-10-22 12:03:42 +02:00
if(login){ $("input[type=password]:first").focus(); }
2010-10-22 12:03:42 +02:00
/* Password autocompletion */
$("input[type='password']").attr("autocomplete",autocomplete);
2010-10-22 12:03:42 +02:00
/* Open links in new windows */
if(newwindow){ $('#appslist a[href^="http://"]').attr("target", "_blank"); }
2010-10-22 12:03:42 +02:00
/* Complete removeOther link */
if ($("p.removeOther").length) {
var action = $("form.login").attr("action");
var method = $("form.login").attr("method");
var back_url = "";
if (action.indexOf("?") != -1) {
back_url = action.substring(0,action.indexOf("?")) + "?";
} else {
back_url = action + "?";
}
$("form.login input[type=hidden]").each(function(index){
back_url = back_url + "&" + $(this).attr("name") + "=" + $(this).val();
});
var link = $("p.removeOther a").attr("href");
link = link + "&method=" + method + "&url=" + $.base64Encode(back_url);
$("p.removeOther a").attr("href",link);
}
});
2010-10-22 12:03:42 +02:00
/* function boolean isHiddenFormValueSet(string option)
* Check if an hidden option is set
* @param option Option name
* @return true if option is set, false else
*/
function isHiddenFormValueSet(option){
if($('#lmhidden_'+option).length){
return true;
}else{
return false;
}
}
function ping() {
$.ajax({type:"POST",
url:scriptname,
data:{ping:1},
dataType:'json',
success:function(data){
if(!data.auth){
location.reload(true);
}
else{
setTimeout('ping();',60000);
}
}/*,
error:function(xhr, ajaxOptions, thrownError){
alert('Request failed Error code: '+xhr.status+', '+thrownError);
}*/
});
}
2010-10-22 12:03:42 +02:00