2010-01-21 10:51:13 +01:00
|
|
|
/**
|
2010-10-22 12:03:42 +02:00
|
|
|
* LemonLDAP::NG Portal jQuery scripts
|
2010-01-21 10:51:13 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Used variables
|
|
|
|
* - displaytab
|
2010-10-22 12:03:42 +02:00
|
|
|
* - choicetab
|
2010-01-21 10:51:13 +01:00
|
|
|
* - autocomplete
|
|
|
|
* - login
|
|
|
|
* - newwindow
|
2010-10-22 12:03:42 +02:00
|
|
|
* - antiframe
|
2010-01-21 10:51:13 +01:00
|
|
|
*/
|
|
|
|
|
2010-01-22 17:04:15 +01:00
|
|
|
/* 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};
|
|
|
|
|
2010-01-22 17:04:15 +01:00
|
|
|
/* jQuery */
|
2010-01-21 10:51:13 +01:00
|
|
|
$(document).ready(function(){
|
2010-10-22 12:03:42 +02:00
|
|
|
|
|
|
|
/* AntiFrame script */
|
|
|
|
if(antiframe && top!=self){
|
|
|
|
top.location.href = location.href;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Display message */
|
2010-01-21 10:51:13 +01:00
|
|
|
$("div.message").fadeIn('slow');
|
2010-10-22 12:03:42 +02:00
|
|
|
|
|
|
|
/* Set timezone */
|
2010-01-21 10:51:13 +01:00
|
|
|
$("input[name=timezone]").val( -(new Date().getTimezoneOffset()/60) );
|
2010-10-22 12:03:42 +02:00
|
|
|
|
|
|
|
/* Menu tabs */
|
2010-01-21 10:51:13 +01:00
|
|
|
$("#menu").tabs({ fx: { opacity: 'toggle' } });
|
|
|
|
$("#menu").tabs("select",displaytab);
|
2010-09-03 15:21:03 +02:00
|
|
|
|
2010-10-22 12:03:42 +02:00
|
|
|
/* Authentication choice tabs */
|
2010-09-03 15:21:03 +02:00
|
|
|
$("#authMenu").tabs({
|
2010-09-15 10:31:44 +02:00
|
|
|
fx: {opacity: 'toggle'},
|
|
|
|
cookie: {name: 'lemonldapauthchoice'},
|
2010-09-03 15:21:03 +02:00
|
|
|
});
|
2010-09-06 11:35:05 +02:00
|
|
|
$("#authMenu").tabs("select",choicetab);
|
2010-09-03 15:21:03 +02:00
|
|
|
|
2010-10-22 12:03:42 +02:00
|
|
|
/* Focus on first visible input */
|
2010-01-21 10:51:13 +01:00
|
|
|
$("input[type!=hidden]:first").focus();
|
2010-10-22 12:03:42 +02:00
|
|
|
if(login){ $("input[type=password]:first").focus(); }
|
2010-09-20 12:39:23 +02:00
|
|
|
|
2010-10-22 12:03:42 +02:00
|
|
|
/* Password autocompletion */
|
|
|
|
$("input[type='password']").attr("autocomplete",autocomplete);
|
2010-09-20 12:39:23 +02:00
|
|
|
|
2010-10-22 12:03:42 +02:00
|
|
|
/* Open links in new windows */
|
2010-01-21 10:51:13 +01:00
|
|
|
if(newwindow){ $('#appslist a[href^="http://"]').attr("target", "_blank"); }
|
2010-08-20 17:07:55 +02:00
|
|
|
|
2010-10-22 12:03:42 +02:00
|
|
|
/* Complete removeOther link */
|
2010-08-20 17:07:55 +02:00
|
|
|
if ($("p.removeOther").length) {
|
|
|
|
var action = $("form.login").attr("action");
|
|
|
|
var method = $("form.login").attr("method");
|
|
|
|
|
2010-08-20 17:36:06 +02:00
|
|
|
var back_url = "";
|
|
|
|
if (action.indexOf("?") != -1) {
|
|
|
|
back_url = action.substring(0,action.indexOf("?")) + "?";
|
|
|
|
} else {
|
|
|
|
back_url = action + "?";
|
|
|
|
}
|
2010-08-20 17:07:55 +02:00
|
|
|
|
|
|
|
$("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-01-21 10:51:13 +01:00
|
|
|
});
|
2010-04-26 15:10:04 +02:00
|
|
|
|
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
|
|
|
|
*/
|
2010-04-26 15:10:04 +02:00
|
|
|
function isHiddenFormValueSet(option){
|
|
|
|
if($('#lmhidden_'+option).length){
|
|
|
|
return true;
|
|
|
|
}else{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2010-10-25 08:25:20 +02:00
|
|
|
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
|
|
|
|