make tidy-js (#683)

This commit is contained in:
Clément Oudot 2014-02-05 16:30:30 +00:00
parent 6a72659c95
commit d18840122f
9 changed files with 1451 additions and 1317 deletions

View File

@ -90,8 +90,16 @@ var helpCh={
var simpleTreeCollection; var simpleTreeCollection;
/* Convert boolean strings into javascript booleans */ /* Convert boolean strings into javascript booleans */
if (treeautoclose.match('true')){ treeautoclose = true; } else { treeautoclose = false; } if (treeautoclose.match('true')) {
if (treejquerycss.match('true')){ treejquerycss = true; } else { treejquerycss = false; } treeautoclose = true;
} else {
treeautoclose = false;
}
if (treejquerycss.match('true')) {
treejquerycss = true;
} else {
treejquerycss = false;
}
$(document).ready(function() { $(document).ready(function() {
@ -101,24 +109,88 @@ $(document).ready(function(){
jQuery.event.add(window, "resize", resizeMenu); jQuery.event.add(window, "resize", resizeMenu);
/* Buttons */ /* Buttons */
$('#header a').button({icons:{primary:"ui-icon-home"}}); $('#header a').button({
$('#header span#css-switch-link').button({icons:{primary:"ui-icon-image"}}); icons: {
$('#css-switch button[alt=tree]').button({icons:{primary:"ui-icon-grip-dotted-vertical"}}); primary: "ui-icon-home"
$('#css-switch button[alt=accordion]').button({icons:{primary:"ui-icon-grip-dotted-horizontal"}}); }
$('#css-switch button[alt=ui-lightness]').button({icons:{primary:"ui-icon-lightbulb"}}); });
$('#css-switch button[alt=ui-darkness]').button({icons:{primary:"ui-icon-star"}}); $('#header span#css-switch-link').button({
icons: {
primary: "ui-icon-image"
}
});
$('#css-switch button[alt=tree]').button({
icons: {
primary: "ui-icon-grip-dotted-vertical"
}
});
$('#css-switch button[alt=accordion]').button({
icons: {
primary: "ui-icon-grip-dotted-horizontal"
}
});
$('#css-switch button[alt=ui-lightness]').button({
icons: {
primary: "ui-icon-lightbulb"
}
});
$('#css-switch button[alt=ui-darkness]').button({
icons: {
primary: "ui-icon-star"
}
});
$('#buttons button').button(); $('#buttons button').button();
$('#content button').button(); $('#content button').button();
$('button#bsave').button({icons:{primary:"ui-icon-disk"}}); $('button#bsave').button({
$('button[id*=new]').button({icons:{primary:"ui-icon-circle-plus"}}); icons: {
$('button[id*=del]').button({icons:{primary:"ui-icon-circle-minus"}}); primary: "ui-icon-disk"
$('#query-switch a[alt=user]').button({icons:{primary:"ui-icon-person"}}); }
$('#query-switch a[alt=ip]').button({icons:{primary:"ui-icon-gear"}}); });
$('#query-switch a[alt=2ip]').button({icons:{primary:"ui-icon-alert"}}); $('button[id*=new]').button({
$('#query-switch a[alt=list]').button({icons:{primary:"ui-icon-mail-closed"}}); icons: {
$('#query-switch a[alt=listDone]').button({icons:{primary:"ui-icon-mail-open"}}); primary: "ui-icon-circle-plus"
$('#query-switch a[alt=newNotif]').button({icons:{primary:"ui-icon-circle-plus"}}); }
$('#sendNewNotif').button({icons:{primary:"ui-icon-circle-plus"}}); });
$('button[id*=del]').button({
icons: {
primary: "ui-icon-circle-minus"
}
});
$('#query-switch a[alt=user]').button({
icons: {
primary: "ui-icon-person"
}
});
$('#query-switch a[alt=ip]').button({
icons: {
primary: "ui-icon-gear"
}
});
$('#query-switch a[alt=2ip]').button({
icons: {
primary: "ui-icon-alert"
}
});
$('#query-switch a[alt=list]').button({
icons: {
primary: "ui-icon-mail-closed"
}
});
$('#query-switch a[alt=listDone]').button({
icons: {
primary: "ui-icon-mail-open"
}
});
$('#query-switch a[alt=newNotif]').button({
icons: {
primary: "ui-icon-circle-plus"
}
});
$('#sendNewNotif').button({
icons: {
primary: "ui-icon-circle-plus"
}
});
/* Display/hide divs */ /* Display/hide divs */
$("#buttons h1").click(function() { $("#buttons h1").click(function() {
@ -187,8 +259,12 @@ $(document).ready(function(){
$('#css-switch button').each(function() { $('#css-switch button').each(function() {
$(this).removeClass('ui-state-focus'); $(this).removeClass('ui-state-focus');
}); });
if($.cookie("managermenu")){css_menu=$.cookie("managermenu");} if ($.cookie("managermenu")) {
if($.cookie("managertheme")){css_theme=$.cookie("managertheme");} css_menu = $.cookie("managermenu");
}
if ($.cookie("managertheme")) {
css_theme = $.cookie("managertheme");
}
$('#css-switch button[alt=' + css_menu + ']').addClass('ui-state-focus').focus(); $('#css-switch button[alt=' + css_menu + ']').addClass('ui-state-focus').focus();
$('#css-switch button[alt=' + css_theme + ']').addClass('ui-state-focus'); $('#css-switch button[alt=' + css_theme + ']').addClass('ui-state-focus');
return false; return false;
@ -201,14 +277,20 @@ $(document).ready(function(){
} }
$("#css-switch #organization button").click(function() { $("#css-switch #organization button").click(function() {
var style = $(this).attr("alt"); var style = $(this).attr("alt");
$.cookie("managermenu",style, {expires: 365, path: '/'}); $.cookie("managermenu", style, {
expires: 365,
path: '/'
});
simpleTreeSetMenuStyle(style); simpleTreeSetMenuStyle(style);
$('#css-switch').dialog("close"); $('#css-switch').dialog("close");
return false; return false;
}); });
$("#css-switch #theme button").click(function() { $("#css-switch #theme button").click(function() {
var theme = $(this).attr("alt"); var theme = $(this).attr("alt");
$.cookie("managertheme",theme, {expires: 365, path: '/'}); $.cookie("managertheme", theme, {
expires: 365,
path: '/'
});
$("link#csstheme").attr("href", themepath + theme + '/jquery-ui-' + jqueryuiversion + '.custom.min.css'); $("link#csstheme").attr("href", themepath + theme + '/jquery-ui-' + jqueryuiversion + '.custom.min.css');
$('#css-switch').dialog("close"); $('#css-switch').dialog("close");
return false; return false;
@ -246,8 +328,7 @@ function loadSimpleTree(){
afterSetTrigger: function(node) { afterSetTrigger: function(node) {
simpleTreeTriggerJqueryClasses(); simpleTreeTriggerJqueryClasses();
}, },
afterMove:function(destination, source, pos){ afterMove: function(destination, source, pos) {},
},
afterAjax: function() { afterAjax: function() {
simpleTreeDefaultJqueryClasses(); simpleTreeDefaultJqueryClasses();
simpleTreeToggleJqueryClasses(); simpleTreeToggleJqueryClasses();
@ -255,8 +336,9 @@ function loadSimpleTree(){
animate: true, animate: true,
docToFolderConvert: true docToFolderConvert: true
}); });
if(treejquerycss){simpleTreeDefaultJqueryClasses();} if (treejquerycss) {
simpleTreeDefaultJqueryClasses();
}
} }
function simpleTreeSetMenuStyle(style) { function simpleTreeSetMenuStyle(style) {
@ -308,18 +390,10 @@ function simpleTreeTriggerJqueryClasses(){
$(".simpleTree .folder-close > img.trigger").addClass("ui-icon"); $(".simpleTree .folder-close > img.trigger").addClass("ui-icon");
$(".simpleTree .folder-close-last > img.trigger").addClass("ui-icon"); $(".simpleTree .folder-close-last > img.trigger").addClass("ui-icon");
$(".simpleTree .folder-open > img.trigger") $(".simpleTree .folder-open > img.trigger").removeClass("ui-icon-triangle-1-e").addClass("ui-icon-triangle-1-s");
.removeClass("ui-icon-triangle-1-e") $(".simpleTree .folder-open-last > img.trigger").removeClass("ui-icon-triangle-1-e").addClass("ui-icon-triangle-1-s");
.addClass("ui-icon-triangle-1-s"); $(".simpleTree .folder-close > img.trigger").removeClass("ui-icon-triangle-1-s").addClass("ui-icon-triangle-1-e");
$(".simpleTree .folder-open-last > img.trigger") $(".simpleTree .folder-close-last > img.trigger").removeClass("ui-icon-triangle-1-s").addClass("ui-icon-triangle-1-e");
.removeClass("ui-icon-triangle-1-e")
.addClass("ui-icon-triangle-1-s");
$(".simpleTree .folder-close > img.trigger")
.removeClass("ui-icon-triangle-1-s")
.addClass("ui-icon-triangle-1-e");
$(".simpleTree .folder-close-last > img.trigger")
.removeClass("ui-icon-triangle-1-s")
.addClass("ui-icon-triangle-1-e");
} else { } else {
$(".simpleTree img.trigger").removeClass("ui-icon ui-icon-triangle-1-e ui-icon-triangle-1-s"); $(".simpleTree img.trigger").removeClass("ui-icon ui-icon-triangle-1-e ui-icon-triangle-1-s");
} }
@ -347,7 +421,9 @@ function lmparent(id){
return $('#' + safeSelector(id)).parent().parent().attr('id'); return $('#' + safeSelector(id)).parent().parent().attr('id');
} }
function setlmtext(id, v, prefixvalue) { function setlmtext(id, v, prefixvalue) {
if(!prefixvalue){prefixvalue="";} if (!prefixvalue) {
prefixvalue = "";
}
if (v.length == 0) { if (v.length == 0) {
alert("Null value"); alert("Null value");
} }
@ -359,7 +435,9 @@ function setlmtext(id,v,prefixvalue){
function setlminputtext(id, input, prefixvalue) { function setlminputtext(id, input, prefixvalue) {
var inputname = $(input).attr('id'); var inputname = $(input).attr('id');
var inputvalue = $(input).val(); var inputvalue = $(input).val();
if(!prefixvalue){prefixvalue="";} if (!prefixvalue) {
prefixvalue = "";
}
if (inputvalue.length == 0) { if (inputvalue.length == 0) {
alert('No ' + inputname); alert('No ' + inputname);
return false; return false;
@ -408,11 +486,9 @@ function setlmfile(id,input){
alert('No ' + inputname); alert('No ' + inputname);
return false; return false;
} }
$("#"+inputname+"-loadimg") $("#" + inputname + "-loadimg").ajaxStart(function() {
.ajaxStart(function(){
$(this).show(); $(this).show();
}) }).ajaxComplete(function() {
.ajaxComplete(function(){
$(this).hide(); $(this).hide();
}); });
$.ajaxFileUpload({ $.ajaxFileUpload({
@ -514,8 +590,13 @@ function display(div,title) {
var height_menu = $('#menu').height(); var height_menu = $('#menu').height();
var height_buttons_edition = $('#buttons').height() + $('#edition').height(); var height_buttons_edition = $('#buttons').height() + $('#edition').height();
var help_height = height_menu - height_buttons_edition - 50; var help_height = height_menu - height_buttons_edition - 50;
if(help_height<1){$('#help h1 img').toggle();$('#help_content').toggle();} if (help_height < 1) {
else{$('#help_content').height(help_height);} $('#help h1 img').toggle();
$('#help_content').toggle();
}
else {
$('#help_content').height(help_height);
}
} }
function none(id) { function none(id) {
currentId = id; currentId = id;
@ -579,7 +660,9 @@ function authParams(id) {
$('#authText').change(function() { $('#authText').change(function() {
var isMulti = false; var isMulti = false;
$('#content_authParams option:selected').each(function() { $('#content_authParams option:selected').each(function() {
if($(this).val()=='Multi'){isMulti=true;} if ($(this).val() == 'Multi') {
isMulti = true;
}
}); });
if (isMulti) { if (isMulti) {
$('#authOptions').show(); $('#authOptions').show();
@ -596,30 +679,7 @@ function formateSelectAuth(id,value){
if (value && value.toLowerCase() == "ldap") { if (value && value.toLowerCase() == "ldap") {
value = "LDAP"; value = "LDAP";
} }
formateSelect(id,[ formateSelect(id, ['Apache=Apache', 'AD=Active Directory', 'BrowserID=BrowserID (Mozilla Persona)', 'Choice=Authentication choice', 'CAS=Central Authentication Service (CAS)', 'DBI=Database (DBI)', 'Demo=Demonstration', 'Facebook=Facebook', 'Google=Google', 'LDAP=LDAP', 'Multi=Multiple', 'Null=None', 'OpenID=OpenID', 'Proxy=Proxy', 'Radius=Radius', 'Remote=Remote', 'SAML=SAML v2', 'Slave=Slave', 'SSL=SSL', 'Twitter=Twitter', 'WebID=WebID', 'Yubikey=Yubikey'], value);
'Apache=Apache',
'AD=Active Directory',
'BrowserID=BrowserID (Mozilla Persona)',
'Choice=Authentication choice',
'CAS=Central Authentication Service (CAS)',
'DBI=Database (DBI)',
'Demo=Demonstration',
'Facebook=Facebook',
'Google=Google',
'LDAP=LDAP',
'Multi=Multiple',
'Null=None',
'OpenID=OpenID',
'Proxy=Proxy',
'Radius=Radius',
'Remote=Remote',
'SAML=SAML v2',
'Slave=Slave',
'SSL=SSL',
'Twitter=Twitter',
'WebID=WebID',
'Yubikey=Yubikey'
],value);
} }
function userdbParams(id) { function userdbParams(id) {
currentId = id; currentId = id;
@ -640,7 +700,9 @@ function userdbParams(id) {
$('#authText').change(function() { $('#authText').change(function() {
var isMulti = false; var isMulti = false;
$('#content_authParams option:selected').each(function() { $('#content_authParams option:selected').each(function() {
if($(this).val()=='Multi'){isMulti=true;} if ($(this).val() == 'Multi') {
isMulti = true;
}
}); });
if (isMulti) { if (isMulti) {
$('#authOptions').show(); $('#authOptions').show();
@ -657,22 +719,7 @@ function formateSelectUser(id,value){
if (value && value.toLowerCase() == "ldap") { if (value && value.toLowerCase() == "ldap") {
value = "LDAP"; value = "LDAP";
} }
formateSelect(id,[ formateSelect(id, ['AD=Active Directory', 'DBI=Database (DBI)', 'Demo=Demonstration', 'Facebook=Facebook', 'Google=Google', 'LDAP=LDAP', 'Multi=Multiple', 'Null=None', 'OpenID=OpenID', 'Proxy=Proxy', 'Remote=Remote', 'SAML=SAML v2', 'Slave=Slave', 'WebID=WebID'], value);
'AD=Active Directory',
'DBI=Database (DBI)',
'Demo=Demonstration',
'Facebook=Facebook',
'Google=Google',
'LDAP=LDAP',
'Multi=Multiple',
'Null=None',
'OpenID=OpenID',
'Proxy=Proxy',
'Remote=Remote',
'SAML=SAML v2',
'Slave=Slave',
'WebID=WebID'
],value);
} }
function passworddbParams(id) { function passworddbParams(id) {
currentId = id; currentId = id;
@ -685,13 +732,7 @@ function formateSelectPassword(id,value){
if (value && value.toLowerCase() == "ldap") { if (value && value.toLowerCase() == "ldap") {
value = "LDAP"; value = "LDAP";
} }
formateSelect(id,[ formateSelect(id, ['AD=Active Directory', 'DBI=Database (DBI)', 'Demo=Demonstration', 'LDAP=LDAP', 'Null=None'], value);
'AD=Active Directory',
'DBI=Database (DBI)',
'Demo=Demonstration',
'LDAP=LDAP',
'Null=None'
],value);
} }
function skinSelect(id) { function skinSelect(id) {
currentId = id; currentId = id;
@ -717,36 +758,18 @@ function changeSkinImage(skin) {
} }
function nameIdFormatParams(id) { function nameIdFormatParams(id) {
currentId = id; currentId = id;
formateSelect('select',[ formateSelect('select', ['=', 'unspecified=Unspecified', 'email=Email', 'x509=X509 certificate', 'windows=Windows', 'kerberos=Kerberos', 'entity=Entity', 'persistent=Persistent', 'transient=Transient', 'encrypted=Encrypted'], lmdata(id));
'=',
'unspecified=Unspecified',
'email=Email',
'x509=X509 certificate',
'windows=Windows',
'kerberos=Kerberos',
'entity=Entity',
'persistent=Persistent',
'transient=Transient',
'encrypted=Encrypted'
],lmdata(id));
display('select', lmtext(id)); display('select', lmtext(id));
} }
function bindingParams(id) { function bindingParams(id) {
currentId = id; currentId = id;
formateSelect('select',[ formateSelect('select', ['=', 'http-post=POST', 'http-redirect=REDIRECT', 'http-soap=SOAP', 'artifact-get=Artifact GET', 'artifact-post=Artifact POST'], lmdata(id));
'=',
'http-post=POST',
'http-redirect=REDIRECT',
'http-soap=SOAP',
'artifact-get=Artifact GET',
'artifact-post=Artifact POST'
],lmdata(id));
display('select', lmtext(id)); display('select', lmtext(id));
} }
function authnContextParams(id) { function authnContextParams(id) {
currentId = id; currentId = id;
formateSelect('select',[ formateSelect( 'select',
'=', [ '=',
'kerberos=Kerberos', 'kerberos=Kerberos',
'password-protected-transport=Password protected transport', 'password-protected-transport=Password protected transport',
'password=Password', 'password=Password',
@ -756,41 +779,22 @@ function authnContextParams(id) {
} }
function encryptionModeParams(id) { function encryptionModeParams(id) {
currentId = id; currentId = id;
formateSelect('select',[ formateSelect('select', ['none=None', 'nameid=Name ID', 'assertion=Assertion'], lmdata(id));
'none=None',
'nameid=Name ID',
'assertion=Assertion'
],lmdata(id));
display('select', lmtext(id)); display('select', lmtext(id));
} }
function timeoutActivityParams(id) { function timeoutActivityParams(id) {
currentId = id; currentId = id;
formateSelect('select',[ formateSelect('select', ['0=None', '900=15 min', '1800=30 min', '2700=45 min', '3600=60 min'], lmdata(id));
'0=None',
'900=15 min',
'1800=30 min',
'2700=45 min',
'3600=60 min'
],lmdata(id));
display('select', lmtext(id)); display('select', lmtext(id));
} }
function zimbraByParams(id) { function zimbraByParams(id) {
currentId = id; currentId = id;
formateSelect('select',[ formateSelect('select', ['=', 'name=User name', 'id=User id', 'foreignPrincipal=Foreign principal'], lmdata(id));
'=',
'name=User name',
'id=User id',
'foreignPrincipal=Foreign principal'
],lmdata(id));
display('select', lmtext(id)); display('select', lmtext(id));
} }
function casAccessControlPolicyParams(id) { function casAccessControlPolicyParams(id) {
currentId = id; currentId = id;
formateSelect('select',[ formateSelect('select', ['none=None', 'error=Display error on portal', 'faketicket=Send a fake service ticket'], lmdata(id));
'none=None',
'error=Display error on portal',
'faketicket=Send a fake service ticket'
],lmdata(id));
display('select', lmtext(id)); display('select', lmtext(id));
} }
function btext(id) { function btext(id) {
@ -803,14 +807,26 @@ function btext(id) {
} }
function bool(id) { function bool(id) {
currentId = id; currentId = id;
if(lmdata(id)==1){$('#On').prop('checked',true)}else{$('#Off').prop('checked',true)} if (lmdata(id) == 1) {
$('#On').prop('checked', true)
} else {
$('#Off').prop('checked', true)
}
display('bool', lmtext(id)); display('bool', lmtext(id));
} }
function trool(id) { function trool(id) {
currentId = id; currentId = id;
if(lmdata(id)==1){$('#TrOn').prop('checked',true)} if (lmdata(id) == 1) {
else{if(lmdata(id)==0){$('#TrOff').prop('checked',true)} $('#TrOn').prop('checked', true)
else{$('#TrDefault').prop('checked',true)}} }
else {
if (lmdata(id) == 0) {
$('#TrOff').prop('checked', true)
}
else {
$('#TrDefault').prop('checked', true)
}
}
display('trool', lmtext(id)); display('trool', lmtext(id));
} }
function int(id) { function int(id) {
@ -835,13 +851,23 @@ function filearea(id) {
$('#generatefile').hide(); $('#generatefile').hide();
$('#filearea').val(lmdata(id)); $('#filearea').val(lmdata(id));
/* Only samlIDPMetaDataXML and samlSPMetaDataXML element could be loaded from URL */ /* Only samlIDPMetaDataXML and samlSPMetaDataXML element could be loaded from URL */
if(lmtext(id)=='samlIDPMetaDataXML'){$('#urlinput').show();} if (lmtext(id) == 'samlIDPMetaDataXML') {
if(lmtext(id)=='samlSPMetaDataXML') {$('#urlinput').show();} $('#urlinput').show();
}
if (lmtext(id) == 'samlSPMetaDataXML') {
$('#urlinput').show();
}
/* Only samlServicePrivateKey* elements could generate keys */ /* Only samlServicePrivateKey* elements could generate keys */
if(lmtext(id)=='samlServicePrivateKeySig'){$('#generatefile').show();} if (lmtext(id) == 'samlServicePrivateKeySig') {
if(lmtext(id)=='samlServicePrivateKeyEnc'){$('#generatefile').show();} $('#generatefile').show();
}
if (lmtext(id) == 'samlServicePrivateKeyEnc') {
$('#generatefile').show();
}
/* If data, then allow to download */ /* If data, then allow to download */
if(lmdata(id).length){$('#downloadfile').show();} if (lmdata(id).length) {
$('#downloadfile').show();
}
/* Set switchReadonly text */ /* Set switchReadonly text */
$('#switchreadonly span').text(text4edit); $('#switchreadonly span').text(text4edit);
display('filearea', lmtext(id)); display('filearea', lmtext(id));
@ -861,12 +887,7 @@ function samlAssertion(id) {
$('#samlAssertionDefaultOff').prop('checked', true); $('#samlAssertionDefaultOff').prop('checked', true);
} }
$('#samlAssertionIndex').val(t[1]); $('#samlAssertionIndex').val(t[1]);
formateSelect('samlAssertionBinding',[ formateSelect('samlAssertionBinding', ['urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact=Artifact', 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST=HTTP POST', 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect=HTTP Redirect', 'urn:oasis:names:tc:SAML:2.0:bindings:SOAP=SOAP'], t[2]);
'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact=Artifact',
'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST=HTTP POST',
'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect=HTTP Redirect',
'urn:oasis:names:tc:SAML:2.0:bindings:SOAP=SOAP'
],t[2]);
$('#samlAssertionLocation').val(t[3]); $('#samlAssertionLocation').val(t[3]);
display('samlAssertion', lmtext(id)); display('samlAssertion', lmtext(id));
} }
@ -887,12 +908,7 @@ function samlAttribute(id) {
} }
$('#samlAttributeKey').val(lmtext(id)); $('#samlAttributeKey').val(lmtext(id));
$('#samlAttributeName').val(t[1]); $('#samlAttributeName').val(t[1]);
formateSelect('samlAttributeFormat',[ formateSelect('samlAttributeFormat', ['=', 'urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified=Unspecified', 'urn:oasis:names:tc:SAML:2.0:attrname-format:uri=URI', 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic=Basic'], t[2]);
'=',
'urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified=Unspecified',
'urn:oasis:names:tc:SAML:2.0:attrname-format:uri=URI',
'urn:oasis:names:tc:SAML:2.0:attrname-format:basic=Basic'
],t[2]);
$('#samlAttributeFriendlyName').val(t[3]); $('#samlAttributeFriendlyName').val(t[3]);
display('samlAttribute', lmtext(id)); display('samlAttribute', lmtext(id));
$('#newsamlattributeb,#delsamlattributeb').show(); $('#newsamlattributeb,#delsamlattributeb').show();
@ -927,12 +943,7 @@ function samlSpMetaData(id){
function samlService(id) { function samlService(id) {
currentId = id; currentId = id;
var t = lmdata(id).split(';'); var t = lmdata(id).split(';');
formateSelect('samlServiceBinding',[ formateSelect('samlServiceBinding', ['urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect=HTTP Redirect', 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST=HTTP POST', 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact=HTTP Artifact', 'urn:oasis:names:tc:SAML:2.0:bindings:SOAP=SOAP'], t[0]);
'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect=HTTP Redirect',
'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST=HTTP POST',
'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact=HTTP Artifact',
'urn:oasis:names:tc:SAML:2.0:bindings:SOAP=SOAP'
],t[0]);
$('#samlServiceLocation').val(t[1]); $('#samlServiceLocation').val(t[1]);
$('#samlServiceResponseLocation').val(t[2]); $('#samlServiceResponseLocation').val(t[2]);
display('samlService', lmtext(id)); display('samlService', lmtext(id));
@ -950,12 +961,7 @@ function openididplist(id) {
} }
function securedCookieValues(id) { function securedCookieValues(id) {
currentId = id; currentId = id;
formateSelect('select',[ formateSelect('select', ['0=' + text4securedCookie0, '1=' + text4securedCookie1, '2=' + text4securedCookie2, '3=' + text4securedCookie3], lmdata(id));
'0='+text4securedCookie0,
'1='+text4securedCookie1,
'2='+text4securedCookie2,
'3='+text4securedCookie3
],lmdata(id));
display('select', lmtext(id)); display('select', lmtext(id));
} }
function vhost(id) { function vhost(id) {
@ -972,7 +978,9 @@ function cfgDatas(id){
} }
function delvh(id) { function delvh(id) {
var vhname = lmtext(id); var vhname = lmtext(id);
if(confirm('Delete '+vhname+' ?')){delKey(id);} if (confirm('Delete ' + vhname + ' ?')) {
delKey(id);
}
} }
function rules(id) { function rules(id) {
currentId = id; currentId = id;
@ -1030,10 +1038,20 @@ function reloadAuthParams() {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: scriptname, url: scriptname,
data:{node:'generalParameters/authParams',conf:'authentication userDB passwordDB issuerDB',cfgNum:lmdata('li_cm9vdA2'),authentication:lmdata('li_L2F1dGhlbnRpY2F0aW9u0'),userDB:lmdata('li_L3VzZXJEQg2'),passwordDB:lmdata('li_L3Bhc3N3b3JkREI1'),issuerDB:lmdata('li_L2lzc3VlckRC0')}, data: {
node: 'generalParameters/authParams',
conf: 'authentication userDB passwordDB issuerDB',
cfgNum: lmdata('li_cm9vdA2'),
authentication: lmdata('li_L2F1dGhlbnRpY2F0aW9u0'),
userDB: lmdata('li_L3VzZXJEQg2'),
passwordDB: lmdata('li_L3Bhc3N3b3JkREI1'),
issuerDB: lmdata('li_L2lzc3VlckRC0')
},
dataType: 'html', dataType: 'html',
success: function(data) { success: function(data) {
if(data==null){networkPb()} if (data == null) {
networkPb()
}
else { else {
var node = $('#li_Z2VuZXJhbFBhcmFtZXRlcnMvYXV0aFBhcmFtcw2 >ul'); var node = $('#li_Z2VuZXJhbFBhcmFtZXRlcnMvYXV0aFBhcmFtcw2 >ul');
node.html(data); node.html(data);
@ -1049,7 +1067,9 @@ function reloadAuthParams() {
} }
var count = 0; var count = 0;
function newId(c) { function newId(c) {
if(!c){return false;} if (!c) {
return false;
}
count++; count++;
c = c.replace(/^NewID_(.*)_\d+$/, '$1'); c = c.replace(/^NewID_(.*)_\d+$/, '$1');
return 'NewID_' + c + '_' + count; return 'NewID_' + c + '_' + count;
@ -1103,14 +1123,18 @@ function newGrantSessionRule(){
return false; return false;
} }
function delKey(id) { function delKey(id) {
if(!id){id=currentId;} if (!id) {
id = currentId;
}
$('#' + safeSelector(id)).prev().remove(); $('#' + safeSelector(id)).prev().remove();
$('#' + safeSelector(id)).remove(); $('#' + safeSelector(id)).remove();
} }
function newVh(name) { function newVh(name) {
// Prompt for virtual host name // Prompt for virtual host name
var name = prompt(text4newVhost, 'test25.example.com'); var name = prompt(text4newVhost, 'test25.example.com');
if(!name){return false;} if (!name) {
return false;
}
var vhId = 'li_' + myB64('/locationRules/' + name); var vhId = 'li_' + myB64('/locationRules/' + name);
simpleTreeCollection[0].newAjaxNodeIn($('#li_L3ZpcnR1YWxIb3N0cw2'), vhId, name, scriptname + '?type=new&node=virtualHosts/' + name, function(d, s) { simpleTreeCollection[0].newAjaxNodeIn($('#li_L3ZpcnR1YWxIb3N0cw2'), vhId, name, scriptname + '?type=new&node=virtualHosts/' + name, function(d, s) {
$('>span', s).attr('name', name).attr('help', 'default').attr('id', 'text_' + vhId).attr('onclick', 'vhost(\'' + vhId + '\')'); $('>span', s).attr('name', name).attr('help', 'default').attr('id', 'text_' + vhId).attr('onclick', 'vhost(\'' + vhId + '\')');
@ -1152,7 +1176,9 @@ function newSamlAttributeR(){
} }
function newIdpSamlMetaData() { function newIdpSamlMetaData() {
var name = prompt(text4newSamlMetaData, 'idp-example'); var name = prompt(text4newSamlMetaData, 'idp-example');
if(!name){return false;} if (!name) {
return false;
}
var idpId = 'li_' + myB64('/samlIDPMetaDataExportedAttributes/' + name); var idpId = 'li_' + myB64('/samlIDPMetaDataExportedAttributes/' + name);
simpleTreeCollection[0].newAjaxNodeIn($('#li_L3NhbWxJRFBNZXRhRGF0YU5vZGU1'), idpId, name, scriptname + '?type=new&node=/samlIDPMetaDataNode/' + name, function(d, s) { simpleTreeCollection[0].newAjaxNodeIn($('#li_L3NhbWxJRFBNZXRhRGF0YU5vZGU1'), idpId, name, scriptname + '?type=new&node=/samlIDPMetaDataNode/' + name, function(d, s) {
$('>span', s).attr('name', name).attr('help', 'default').attr('id', 'text_' + idpId).attr('onclick', 'samlIdpMetaData(\'' + idpId + '\')'); $('>span', s).attr('name', name).attr('help', 'default').attr('id', 'text_' + idpId).attr('onclick', 'samlIdpMetaData(\'' + idpId + '\')');
@ -1161,7 +1187,9 @@ function newIdpSamlMetaData(){
} }
function newSpSamlMetaData() { function newSpSamlMetaData() {
var name = prompt(text4newSamlMetaData, 'sp-example'); var name = prompt(text4newSamlMetaData, 'sp-example');
if(!name){return false;} if (!name) {
return false;
}
var spId = 'li_' + myB64('/samlSPMetaDataExportedAttributes/' + name); var spId = 'li_' + myB64('/samlSPMetaDataExportedAttributes/' + name);
simpleTreeCollection[0].newAjaxNodeIn($('#li_L3NhbWxTUE1ldGFEYXRhTm9kZQ2'), spId, name, scriptname + '?type=new&node=/samlSPMetaDataNode/' + name, function(d, s) { simpleTreeCollection[0].newAjaxNodeIn($('#li_L3NhbWxTUE1ldGFEYXRhTm9kZQ2'), spId, name, scriptname + '?type=new&node=/samlSPMetaDataNode/' + name, function(d, s) {
$('>span', s).attr('name', name).attr('help', 'default').attr('id', 'text_' + spId).attr('onclick', 'samlSpMetaData(\'' + spId + '\')'); $('>span', s).attr('name', name).attr('help', 'default').attr('id', 'text_' + spId).attr('onclick', 'samlSpMetaData(\'' + spId + '\')');
@ -1174,10 +1202,15 @@ function uploadConf(f){
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: scriptname, url: scriptname,
data:{data: $('#li_cm9vdA2').html(),force: f}, data: {
data: $('#li_cm9vdA2').html(),
force: f
},
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
if(data==null){networkPb()} if (data == null) {
networkPb()
}
else { else {
var c = '<h3>' + data.content.result.msg + '</h3>'; var c = '<h3>' + data.content.result.msg + '</h3>';
if (data.content.result.cfgNum <= 0) { if (data.content.result.cfgNum <= 0) {
@ -1201,10 +1234,14 @@ function uploadConf(f){
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: scriptname, url: scriptname,
data:{menu:cfgNum}, data: {
menu: cfgNum
},
dataType: 'html', dataType: 'html',
success: function(data) { success: function(data) {
if(data==null){networkPb()} if (data == null) {
networkPb()
}
else { else {
$("div#menu").html(data); $("div#menu").html(data);
loadSimpleTree(); loadSimpleTree();
@ -1213,7 +1250,6 @@ function uploadConf(f){
} }
}); });
} }
if (typeof(data.content.warnings) != 'undefined') { if (typeof(data.content.warnings) != 'undefined') {
c += '<h4>Warnings</h4>'; c += '<h4>Warnings</h4>';
@ -1245,10 +1281,15 @@ function getCfgAttributes() {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: scriptname, url: scriptname,
data:{cfgNum:lmdata('li_cm9vdA2'),cfgAttr:1}, data: {
cfgNum: lmdata('li_cm9vdA2'),
cfgAttr: 1
},
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
if(data==null){networkPb()} if (data == null) {
networkPb()
}
else { else {
setCfgAttributes(data.content); setCfgAttributes(data.content);
cfgAttrDone++; cfgAttrDone++;
@ -1256,7 +1297,11 @@ function getCfgAttributes() {
}, },
error: function(xhr, ajaxOptions, thrownError) { error: function(xhr, ajaxOptions, thrownError) {
var msg = 'Error code: ' + xhr.status + ', ' + thrownError; var msg = 'Error code: ' + xhr.status + ', ' + thrownError;
setCfgAttributes({cfgAuthor:msg,cfgAuthorIP:msg,cfgDate:msg}); setCfgAttributes({
cfgAuthor: msg,
cfgAuthorIP: msg,
cfgDate: msg
});
} }
}); });
} }
@ -1312,37 +1357,45 @@ function downloadFile(id){
var content = lmdata(id).replace(/"/g, '&#34;'); var content = lmdata(id).replace(/"/g, '&#34;');
var inputs = ''; var inputs = '';
var filename = prompt(text4newFilename, 'lemonldap-ng.txt'); var filename = prompt(text4newFilename, 'lemonldap-ng.txt');
if(!filename){return false;} if (!filename) {
return false;
}
inputs += '<input type="hidden" name="filename" value="' + filename + '" />'; inputs += '<input type="hidden" name="filename" value="' + filename + '" />';
inputs += '<textarea style="display:none;" name="file">' + content + '</textarea>'; inputs += '<textarea style="display:none;" name="file">' + content + '</textarea>';
jQuery('<form action="'+ scriptname +'" method="post" enctype="multipart/form-data">'+inputs+'</form>') jQuery('<form action="' + scriptname + '" method="post" enctype="multipart/form-data">' + inputs + '</form>').appendTo('body').submit().remove();
.appendTo('body').submit().remove();
} }
/* Function to generate a file */ /* Function to generate a file */
function generateFile(id) { function generateFile(id) {
/* If samlServicePrivateKey* elements, then generate keys */ /* If samlServicePrivateKey* elements, then generate keys */
if (lmtext(id) == 'samlServicePrivateKeySig' || lmtext(id) == 'samlServicePrivateKeyEnc') { if (lmtext(id) == 'samlServicePrivateKeySig' || lmtext(id) == 'samlServicePrivateKeyEnc') {
var password = prompt(text4newGeneratedFile, ''); var password = prompt(text4newGeneratedFile, '');
$('#button-loadimg') $('#button-loadimg').ajaxStart(function() {
.ajaxStart(function(){
$(this).show(); $(this).show();
}) }).ajaxComplete(function() {
.ajaxComplete(function(){
$(this).hide(); $(this).hide();
}); });
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: scriptname, url: scriptname,
data:{request: 'generateKeys',password: password}, data: {
request: 'generateKeys',
password: password
},
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
if(data==null){networkPb()} if (data == null) {
networkPb()
}
else { else {
var _public; var _public;
var _id; var _id;
setlmdata(id, data.content.private); setlmdata(id, data.content.private);
if(lmtext(id)=='samlServicePrivateKeySig'){_public='samlServicePublicKeySig';} if (lmtext(id) == 'samlServicePrivateKeySig') {
if(lmtext(id)=='samlServicePrivateKeyEnc'){_public='samlServicePublicKeyEnc';} _public = 'samlServicePublicKeySig';
}
if (lmtext(id) == 'samlServicePrivateKeyEnc') {
_public = 'samlServicePublicKeyEnc';
}
_id = $('#' + lmparent(id) + ' span[name=' + _public + ']').attr('id').replace(/text_/, ''); _id = $('#' + lmparent(id) + ' span[name=' + _public + ']').attr('id').replace(/text_/, '');
setlmdata(_id, data.content.public); setlmdata(_id, data.content.public);
_id = $('#' + lmparent(id) + ' span[name=' + lmtext(id) + 'Pwd]').attr('id').replace(/text_/, ''); _id = $('#' + lmparent(id) + ' span[name=' + lmtext(id) + 'Pwd]').attr('id').replace(/text_/, '');
@ -1364,7 +1417,9 @@ function formateSelect(id,values,selectedValue) {
var key = values[i].substring(0, values[i].indexOf('=')); var key = values[i].substring(0, values[i].indexOf('='));
var val = values[i].substring(values[i].indexOf('=') + 1); var val = values[i].substring(values[i].indexOf('=') + 1);
options += '<option value="' + key + '"'; options += '<option value="' + key + '"';
if(selectedValue==key){options+=' selected';} if (selectedValue == key) {
options += ' selected';
}
options += '>' + val + '</option>'; options += '>' + val + '</option>';
} }
$('#' + safeSelector(id)).empty().append(options); $('#' + safeSelector(id)).empty().append(options);
@ -1447,7 +1502,9 @@ function applicationListCategoryRoot(id){
function newCategoryR() { function newCategoryR() {
var name = prompt(text4newCategory, 'mycategory'); var name = prompt(text4newCategory, 'mycategory');
if(!name){return false;} if (!name) {
return false;
}
var newIdValue = newId(currentId); var newIdValue = newId(currentId);
simpleTreeCollection[0].addNode(newIdValue, name, function(d, s) { simpleTreeCollection[0].addNode(newIdValue, name, function(d, s) {
$('>span', s).attr('onClick', 'applicationListCategory("' + newIdValue + '")').attr('name', name).attr('value', 'My Category').attr('id', 'text_' + newIdValue); $('>span', s).attr('onClick', 'applicationListCategory("' + newIdValue + '")').attr('name', name).attr('value', 'My Category').attr('id', 'text_' + newIdValue);
@ -1470,7 +1527,9 @@ function applicationListCategory(id){
function newApplicationR() { function newApplicationR() {
var name = prompt(text4newApplication, 'myapplication'); var name = prompt(text4newApplication, 'myapplication');
if(!name){return false;} if (!name) {
return false;
}
var newIdValue = newId(currentId); var newIdValue = newId(currentId);
simpleTreeCollection[0].addNode(newIdValue, name, function(d, s) { simpleTreeCollection[0].addNode(newIdValue, name, function(d, s) {
$('>span', s).attr('onClick', 'applicationListApplication("' + newIdValue + '")').attr('name', name).attr('value', 'My application|http://www.example.com|This is a nice application|logo.png|auto').attr('id', 'text_' + newIdValue); $('>span', s).attr('onClick', 'applicationListApplication("' + newIdValue + '")').attr('name', name).attr('value', 'My application|http://www.example.com|This is a nice application|logo.png|auto').attr('id', 'text_' + newIdValue);
@ -1502,11 +1561,7 @@ function applicationListApplication(id){
$('#applicationListApplicationURL').val(t[1]); $('#applicationListApplicationURL').val(t[1]);
$('#applicationListApplicationDescription').val(t[2]); $('#applicationListApplicationDescription').val(t[2]);
changeAppsLogo(t[3]); changeAppsLogo(t[3]);
formateSelect('applicationListApplicationDisplay',[ formateSelect('applicationListApplicationDisplay', ['auto=Automatic', 'on=On', 'off=Off'], t[4]);
'auto=Automatic',
'on=On',
'off=Off'
],t[4]);
display('applicationListApplication', lmtext(id)); display('applicationListApplication', lmtext(id));
$('#delapplication').show(); $('#delapplication').show();
} }
@ -1604,9 +1659,13 @@ var lasthelp='';
function loadHelp(ch) { function loadHelp(ch) {
var url; var url;
// Keep actual page if no help chapter // Keep actual page if no help chapter
if(!ch){return;} if (!ch) {
return;
}
// Display default help if help chapter not defined // Display default help if help chapter not defined
if(typeof(helpCh[ch])!='string'){ch='default';} if (typeof(helpCh[ch]) != 'string') {
ch = 'default';
}
// Display new help only if not the last help // Display new help only if not the last help
if (ch != lasthelp) { if (ch != lasthelp) {
url = '/doc' + helpCh[ch]; url = '/doc' + helpCh[ch];

View File

@ -7,7 +7,9 @@ function displayNotification(id) {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: scriptname, url: scriptname,
data:{'notification':id}, data: {
'notification': id
},
dataType: 'html', dataType: 'html',
success: function(data) { success: function(data) {
$('#data').html(data); $('#data').html(data);
@ -27,7 +29,9 @@ function displayNotificationDone(id) {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: scriptname, url: scriptname,
data:{'notificationDone':id}, data: {
'notificationDone': id
},
dataType: 'html', dataType: 'html',
success: function(data) { success: function(data) {
$('#data').html(data); $('#data').html(data);
@ -47,7 +51,9 @@ function del(id) {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: scriptname, url: scriptname,
data:{'delete':id}, data: {
'delete': id
},
dataType: 'html', dataType: 'html',
success: function(data) { success: function(data) {
$('#data').html(data); $('#data').html(data);
@ -68,7 +74,9 @@ function purge(id) {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: scriptname, url: scriptname,
data:{'purge':id}, data: {
'purge': id
},
dataType: 'html', dataType: 'html',
success: function(data) { success: function(data) {
$('#data').html(data); $('#data').html(data);
@ -84,7 +92,9 @@ function purge(id) {
function newNotif() { function newNotif() {
var data = $("#newNotif").html(); var data = $("#newNotif").html();
$('#data').html(data); $('#data').html(data);
$("#data input#date").datepicker({'dateFormat':'yy-mm-dd'}); $("#data input#date").datepicker({
'dateFormat': 'yy-mm-dd'
});
return; return;
} }
@ -107,16 +117,36 @@ function sendNewNotif() {
$("textarea#xml").css('border-width', '0'); $("textarea#xml").css('border-width', '0');
// Check data // Check data
if(!uid){$("input#uid").css('border-color','red').css('border-width','2px').focus();return false;} if (!uid) {
if(!date){$("input#date").css('border-color','red').css('border-width','2px').focus();return false;} $("input#uid").css('border-color', 'red').css('border-width', '2px').focus();
if(!ref){$("input#ref").css('border-color','red').css('border-width','2px').focus();return false;} return false;
if(!xml){$("textarea#xml").css('border-color','red').css('border-width','2px').focus();return false;} }
if (!date) {
$("input#date").css('border-color', 'red').css('border-width', '2px').focus();
return false;
}
if (!ref) {
$("input#ref").css('border-color', 'red').css('border-width', '2px').focus();
return false;
}
if (!xml) {
$("textarea#xml").css('border-color', 'red').css('border-width', '2px').focus();
return false;
}
// Send AJAX request // Send AJAX request
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: scriptname, url: scriptname,
data:{'newNotif':{'uid':uid,'date':date,'ref':ref,'condition':condition,'xml':xml}}, data: {
'newNotif': {
'uid': uid,
'date': date,
'ref': ref,
'condition': condition,
'xml': xml
}
},
dataType: 'html', dataType: 'html',
success: function(data) { success: function(data) {
$('#data').html(data); $('#data').html(data);

View File

@ -2,7 +2,9 @@ function displaySession(id) {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: scriptname, url: scriptname,
data:{'session':id}, data: {
'session': id
},
dataType: 'html', dataType: 'html',
success: function(data) { success: function(data) {
$('#data').html(data); $('#data').html(data);
@ -16,7 +18,9 @@ function del(id) {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: scriptname, url: scriptname,
data:{'delete':id}, data: {
'delete': id
},
dataType: 'html', dataType: 'html',
success: function(data) { success: function(data) {
$('#data').html(data); $('#data').html(data);

View File

@ -41,7 +41,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
$.fn.simpleTree = function(opt) { $.fn.simpleTree = function(opt) {
return this.each(function() { return this.each(function() {
var TREE = this; var TREE = this;
@ -72,43 +71,48 @@ $.fn.simpleTree = function(opt){
afterSetTrigger: false afterSetTrigger: false
}; };
TREE.option = $.extend(TREE.option, opt); TREE.option = $.extend(TREE.option, opt);
$.extend(this, {getSelected: function(){ $.extend(this, {
getSelected: function() {
return $('span.active', this).parent(); return $('span.active', this).parent();
}}); }
TREE.closeNearby = function(obj) });
{ TREE.closeNearby = function(obj) {
$(obj).siblings().filter('.folder-open, .folder-open-last').each(function() { $(obj).siblings().filter('.folder-open, .folder-open-last').each(function() {
var childUl = $('>ul', this); var childUl = $('>ul', this);
var className = this.className; var className = this.className;
this.className = className.replace('open', 'close'); this.className = className.replace('open', 'close');
if(TREE.option.animate) if (TREE.option.animate) {
{ childUl.animate({
childUl.animate({height:"toggle"},TREE.option.speed); height: "toggle"
},
TREE.option.speed);
} else { } else {
childUl.hide(); childUl.hide();
} }
if(typeof TREE.option.afterCloseNearby == 'function') if (typeof TREE.option.afterCloseNearby == 'function') {
{
TREE.option.afterCloseNearby($(this).parent()); TREE.option.afterCloseNearby($(this).parent());
} }
}); });
}; };
TREE.nodeToggle = function(obj) TREE.nodeToggle = function(obj) {
{
var childUl = $('>ul', obj); var childUl = $('>ul', obj);
if (obj.className.match('open')) { if (obj.className.match('open')) {
obj.className = obj.className.replace('open', 'close'); obj.className = obj.className.replace('open', 'close');
if(TREE.option.animate) if (TREE.option.animate) {
{ childUl.animate({
childUl.animate({height:"toggle"},TREE.option.speed); height: "toggle"
},
TREE.option.speed);
} else { } else {
childUl.hide(); childUl.hide();
} }
} else { } else {
obj.className = obj.className.replace('close', 'open'); obj.className = obj.className.replace('close', 'open');
if(TREE.option.animate) if (TREE.option.animate) {
{ childUl.animate({
childUl.animate({height:"toggle"},TREE.option.speed, function(){ height: "toggle"
},
TREE.option.speed, function() {
if (TREE.option.autoclose) TREE.closeNearby(obj); if (TREE.option.autoclose) TREE.closeNearby(obj);
if (childUl.is('.ajax')) TREE.setAjaxNodes(childUl, obj.id); if (childUl.is('.ajax')) TREE.setAjaxNodes(childUl, obj.id);
}); });
@ -119,21 +123,27 @@ $.fn.simpleTree = function(opt){
} }
} }
}; };
TREE.setAjaxNodes = function(node, parentId, callback) TREE.setAjaxNodes = function(node, parentId, callback) {
{
if ($.inArray(parentId, ajaxCache) == -1) { if ($.inArray(parentId, ajaxCache) == -1) {
ajaxCache[ajaxCache.length] = parentId; ajaxCache[ajaxCache.length] = parentId;
var url = $.trim($('>li', node).text()); var url = $.trim($('>li', node).text());
if(url && url.indexOf('url:')) if (url && url.indexOf('url:')) {
{
url = $.trim(url.replace(/.*\{url:(.*)\}/i, '$1')); url = $.trim(url.replace(/.*\{url:(.*)\}/i, '$1'));
var js = ''; var js = '';
var call = ''; var call = '';
if (url.indexOf(',js:')) { if (url.indexOf(',js:')) {
call = url.match(/.*,call:(.*)/i); call = url.match(/.*,call:(.*)/i);
if(call==null){call='';}else{call=call[1].replace(/,call.*$/,'');} if (call == null) {
call = '';
} else {
call = call[1].replace(/,call.*$/, '');
}
js = url.match(/.*,js:(.*)/i); js = url.match(/.*,js:(.*)/i);
if(js==null){js='';}else{js=js[1].replace(/,call.*$/,'');} if (js == null) {
js = '';
} else {
js = js[1].replace(/,call.*$/, '');
}
url = $.trim(url.replace(/,(?:js|call):.*/i, '')); url = $.trim(url.replace(/,(?:js|call):.*/i, ''));
} }
$.ajax({ $.ajax({
@ -145,22 +155,30 @@ $.fn.simpleTree = function(opt){
node.removeAttr('class'); node.removeAttr('class');
if (response.length > 0) { if (response.length > 0) {
node.html(response); node.html(response);
$.extend(node,{url:url}); $.extend(node, {
url: url
});
TREE.setTreeNodes(node, true); TREE.setTreeNodes(node, true);
} else { } else {
$("li.line", node).remove(); $("li.line", node).remove();
$("li.doc-last", node).remove(); $("li.doc-last", node).remove();
} }
if(typeof TREE.option.afterAjax == 'function') if (typeof TREE.option.afterAjax == 'function') {
{
TREE.option.afterAjax(node); TREE.option.afterAjax(node);
} }
if(typeof callback == 'function') if (typeof callback == 'function') {
{
callback(node); callback(node);
} }
if(js.length){if(!js.match(/\(/))js+='()';$('>span',node.parent()).click(function(){eval(js)});} if (js.length) {
if(call.length){if(!call.match(/\(/))call+='()';eval(call);} if (!js.match(/\(/)) js += '()';
$('>span', node.parent()).click(function() {
eval(js)
});
}
if (call.length) {
if (!call.match(/\(/)) call += '()';
eval(call);
}
}, },
error: function(xhr, ajaxOptions, thrownError) { error: function(xhr, ajaxOptions, thrownError) {
TREE.closeNearby(node); TREE.closeNearby(node);
@ -173,33 +191,27 @@ $.fn.simpleTree = function(opt){
}; };
TREE.setTreeNodes = function(obj, useParent) { TREE.setTreeNodes = function(obj, useParent) {
obj = useParent ? obj.parent() : obj; obj = useParent ? obj.parent() : obj;
$('li>span', obj).addClass('text') $('li>span', obj).addClass('text').bind('selectstart', function() {
.bind('selectstart', function() {
return false; return false;
}).click(function() { }).click(function() {
// Remove all active classes and add the text class // Remove all active classes and add the text class
$('.active', TREE).toggleClass('active').addClass('text'); $('.active', TREE).toggleClass('active').addClass('text');
if(this.className.match('text')) if (this.className.match('text')) {
{
this.className = this.className.replace('text', 'active'); this.className = this.className.replace('text', 'active');
} }
if(TREE.option.useClickToToggle) if (TREE.option.useClickToToggle) {
{
TREE.nodeToggle($(this).parent().get(0)); TREE.nodeToggle($(this).parent().get(0));
} }
if(typeof TREE.option.afterClick == 'function') if (typeof TREE.option.afterClick == 'function') {
{
TREE.option.afterClick($(this).parent()); TREE.option.afterClick($(this).parent());
} }
return false; return false;
}).dblclick(function() { }).dblclick(function() {
mousePressed = false; mousePressed = false;
if(!TREE.option.useClickToToggle) if (!TREE.option.useClickToToggle) {
{
TREE.nodeToggle($(this).parent().get(0)); TREE.nodeToggle($(this).parent().get(0));
} }
if(typeof TREE.option.afterDblClick == 'function') if (typeof TREE.option.afterDblClick == 'function') {
{
TREE.option.afterDblClick($(this).parent()); TREE.option.afterDblClick($(this).parent());
} }
return false; return false;
@ -207,12 +219,10 @@ $.fn.simpleTree = function(opt){
// available // available
}).bind("contextmenu", function() { }).bind("contextmenu", function() {
$('.active', TREE).toggleClass('active').addClass('text'); $('.active', TREE).toggleClass('active').addClass('text');
if(this.className.match('text')) if (this.className.match('text')) {
{
this.className = this.className.replace('text', 'active'); this.className = this.className.replace('text', 'active');
} }
if(typeof TREE.option.afterContextMenu == 'function') if (typeof TREE.option.afterContextMenu == 'function') {
{
TREE.option.afterContextMenu($(this).parent()); TREE.option.afterContextMenu($(this).parent());
} }
return false; return false;
@ -220,19 +230,32 @@ $.fn.simpleTree = function(opt){
mousePressed = true; mousePressed = true;
cloneNode = $(this).parent().clone(); cloneNode = $(this).parent().clone();
var LI = $(this).parent(); var LI = $(this).parent();
if(TREE.option.drag) if (TREE.option.drag) {
{
$('>ul', cloneNode).hide(); $('>ul', cloneNode).hide();
$('body').append('<div id="drag_container"><ul></ul></div>'); $('body').append('<div id="drag_container"><ul></ul></div>');
$('#drag_container').hide().css({opacity:'0.8'}); $('#drag_container').hide().css({
opacity: '0.8'
});
$('#drag_container >ul').append(cloneNode); $('#drag_container >ul').append(cloneNode);
$("<img>").attr({id : "tree_plus",src : imagepath+"tree/plus.gif"}).css({width: "7px",display: "block",position: "absolute",left : "5px",top: "5px", display:'none'}).appendTo("body"); $("<img>").attr({
$(document).bind("mousemove", {LI:LI}, TREE.dragStart).bind("mouseup",TREE.dragEnd); id: "tree_plus",
src: imagepath + "tree/plus.gif"
}).css({
width: "7px",
display: "block",
position: "absolute",
left: "5px",
top: "5px",
display: 'none'
}).appendTo("body");
$(document).bind("mousemove", {
LI: LI
},
TREE.dragStart).bind("mouseup", TREE.dragEnd);
} }
return false; return false;
}).mouseup(function() { }).mouseup(function() {
if(mousePressed && mouseMoved && dragNode_source) if (mousePressed && mouseMoved && dragNode_source) {
{
TREE.moveNodeToFolder($(this).parent()); TREE.moveNodeToFolder($(this).parent());
} }
TREE.eventDestroy(); TREE.eventDestroy();
@ -262,8 +285,7 @@ $.fn.simpleTree = function(opt){
var setClassName = 'doc'; var setClassName = 'doc';
this.className = setClassName + ($(this).is(':last-child') ? '-last' : ''); this.className = setClassName + ($(this).is(':last-child') ? '-last' : '');
} }
}).before('<li class="line">&nbsp;</li>') }).before('<li class="line">&nbsp;</li>').filter(':last-child').after('<li class="line-last"></li>');
.filter(':last-child').after('<li class="line-last"></li>');
TREE.setEventLine($('.line, .line-last', obj)); TREE.setEventLine($('.line, .line-last', obj));
}; };
TREE.setTrigger = function(node) { TREE.setTrigger = function(node) {
@ -273,15 +295,13 @@ $.fn.simpleTree = function(opt){
TREE.nodeToggle(node); TREE.nodeToggle(node);
}); });
trigger.css('float', 'left'); trigger.css('float', 'left');
if(typeof TREE.option.afterSetTrigger == 'function') if (typeof TREE.option.afterSetTrigger == 'function') {
{
TREE.option.afterSetTrigger(node); TREE.option.afterSetTrigger(node);
} }
}; };
TREE.dragStart = function(event) { TREE.dragStart = function(event) {
var LI = $(event.data.LI); var LI = $(event.data.LI);
if(mousePressed) if (mousePressed) {
{
mouseMoved = true; mouseMoved = true;
if (dragDropTimer) clearTimeout(dragDropTimer); if (dragDropTimer) clearTimeout(dragDropTimer);
if ($('#drag_container:not(:visible)')) { if ($('#drag_container:not(:visible)')) {
@ -289,36 +309,52 @@ $.fn.simpleTree = function(opt){
LI.prev('.line').hide(); LI.prev('.line').hide();
dragNode_source = LI; dragNode_source = LI;
} }
$('#drag_container').css({position:'absolute', "left" : (event.pageX + 5), "top": (event.pageY + 15) }); $('#drag_container').css({
position: 'absolute',
"left": (event.pageX + 5),
"top": (event.pageY + 15)
});
if (LI.is(':visible')) LI.hide(); if (LI.is(':visible')) LI.hide();
var temp_move = false; var temp_move = false;
if(event.target.tagName.toLowerCase()=='span' && $.inArray(event.target.className, Array('text','active','trigger'))!= -1) if (event.target.tagName.toLowerCase() == 'span' && $.inArray(event.target.className, Array('text', 'active', 'trigger')) != -1) {
{
var parent = event.target.parentNode; var parent = event.target.parentNode;
var offs = $(parent).offset({scroll:false}); var offs = $(parent).offset({
var screenScroll = {x : (offs.left - 3),y : event.pageY - offs.top}; scroll: false
});
var screenScroll = {
x: (offs.left - 3),
y: event.pageY - offs.top
};
var isrc = $("#tree_plus").attr('src'); var isrc = $("#tree_plus").attr('src');
var ajaxChildSize = $('>ul.ajax', parent).size(); var ajaxChildSize = $('>ul.ajax', parent).size();
var ajaxChild = $('>ul.ajax', parent); var ajaxChild = $('>ul.ajax', parent);
screenScroll.x += 19; screenScroll.x += 19;
screenScroll.y = event.pageY - screenScroll.y + 5; screenScroll.y = event.pageY - screenScroll.y + 5;
if(parent.className.indexOf('folder-close')>=0 && ajaxChildSize==0) if (parent.className.indexOf('folder-close') >= 0 && ajaxChildSize == 0) {
{
if (isrc.indexOf('minus') != -1) $("#tree_plus").attr('src', imagepath + 'tree/plus.gif'); if (isrc.indexOf('minus') != -1) $("#tree_plus").attr('src', imagepath + 'tree/plus.gif');
$("#tree_plus").css({"left": screenScroll.x, "top": screenScroll.y}).show(); $("#tree_plus").css({
"left": screenScroll.x,
"top": screenScroll.y
}).show();
dragDropTimer = setTimeout(function() { dragDropTimer = setTimeout(function() {
parent.className = parent.className.replace('close', 'open'); parent.className = parent.className.replace('close', 'open');
$('>ul', parent).show(); $('>ul', parent).show();
}, 700); },
700);
} else if (parent.className.indexOf('folder') >= 0 && ajaxChildSize == 0) { } else if (parent.className.indexOf('folder') >= 0 && ajaxChildSize == 0) {
if (isrc.indexOf('minus') != -1) $("#tree_plus").attr('src', imagepath + 'tree/plus.gif'); if (isrc.indexOf('minus') != -1) $("#tree_plus").attr('src', imagepath + 'tree/plus.gif');
$("#tree_plus").css({"left": screenScroll.x, "top": screenScroll.y}).show(); $("#tree_plus").css({
}else if(parent.className.indexOf('folder-close')>=0 && ajaxChildSize>0) "left": screenScroll.x,
{ "top": screenScroll.y
}).show();
} else if (parent.className.indexOf('folder-close') >= 0 && ajaxChildSize > 0) {
mouseMoved = false; mouseMoved = false;
$("#tree_plus").attr('src', imagepath + 'tree/minus.gif'); $("#tree_plus").attr('src', imagepath + 'tree/minus.gif');
$("#tree_plus").css({"left": screenScroll.x, "top": screenScroll.y}).show(); $("#tree_plus").css({
"left": screenScroll.x,
"top": screenScroll.y
}).show();
$('>ul', parent).show(); $('>ul', parent).show();
/* /*
@ -328,13 +364,18 @@ $.fn.simpleTree = function(opt){
parent.className = parent.className.replace('close', 'open'); parent.className = parent.className.replace('close', 'open');
mouseMoved = true; mouseMoved = true;
$("#tree_plus").attr('src', imagepath + 'tree/plus.gif'); $("#tree_plus").attr('src', imagepath + 'tree/plus.gif');
$("#tree_plus").css({"left": screenScroll.x, "top": screenScroll.y}).show(); $("#tree_plus").css({
"left": screenScroll.x,
"top": screenScroll.y
}).show();
}); });
} else { } else {
if(TREE.option.docToFolderConvert) if (TREE.option.docToFolderConvert) {
{ $("#tree_plus").css({
$("#tree_plus").css({"left": screenScroll.x, "top": screenScroll.y}).show(); "left": screenScroll.x,
"top": screenScroll.y
}).show();
} else { } else {
$("#tree_plus").hide(); $("#tree_plus").hide();
} }
@ -352,57 +393,46 @@ $.fn.simpleTree = function(opt){
}; };
TREE.setEventLine = function(obj) { TREE.setEventLine = function(obj) {
obj.mouseover(function() { obj.mouseover(function() {
if(this.className.indexOf('over')<0 && mousePressed && mouseMoved) if (this.className.indexOf('over') < 0 && mousePressed && mouseMoved) {
{
this.className = this.className.replace('line', 'line-over'); this.className = this.className.replace('line', 'line-over');
} }
}).mouseout(function() { }).mouseout(function() {
if(this.className.indexOf('over')>=0) if (this.className.indexOf('over') >= 0) {
{
this.className = this.className.replace('-over', ''); this.className = this.className.replace('-over', '');
} }
}).mouseup(function() { }).mouseup(function() {
if(mousePressed && dragNode_source && mouseMoved) if (mousePressed && dragNode_source && mouseMoved) {
{
dragNode_destination = $(this).parents('li:first'); dragNode_destination = $(this).parents('li:first');
TREE.moveNodeToLine(this); TREE.moveNodeToLine(this);
TREE.eventDestroy(); TREE.eventDestroy();
} }
}); });
}; };
TREE.checkNodeIsLast = function(node) TREE.checkNodeIsLast = function(node) {
{ if (node.className.indexOf('last') >= 0) {
if(node.className.indexOf('last')>=0)
{
var prev_source = dragNode_source.prev().prev(); var prev_source = dragNode_source.prev().prev();
if(prev_source.size()>0) if (prev_source.size() > 0) {
{
prev_source[0].className += '-last'; prev_source[0].className += '-last';
} }
node.className = node.className.replace('-last', ''); node.className = node.className.replace('-last', '');
} }
}; };
TREE.checkLineIsLast = function(line) TREE.checkLineIsLast = function(line) {
{ if (line.className.indexOf('last') >= 0) {
if(line.className.indexOf('last')>=0)
{
var prev = $(line).prev(); var prev = $(line).prev();
if(prev.size()>0) if (prev.size() > 0) {
{
prev[0].className = prev[0].className.replace('-last', ''); prev[0].className = prev[0].className.replace('-last', '');
} }
dragNode_source[0].className += '-last'; dragNode_source[0].className += '-last';
} }
}; };
TREE.eventDestroy = function() TREE.eventDestroy = function() {
{
// added by Erik Dohmen (2BinBusiness.nl), the unbind mousemove TREE.dragStart action // added by Erik Dohmen (2BinBusiness.nl), the unbind mousemove TREE.dragStart action
// like this other mousemove actions binded through other actions ain't removed (use it myself // like this other mousemove actions binded through other actions ain't removed (use it myself
// to determine location for context menu) // to determine location for context menu)
$(document).unbind('mousemove', TREE.dragStart).unbind('mouseup').unbind('mousedown'); $(document).unbind('mousemove', TREE.dragStart).unbind('mouseup').unbind('mousedown');
$('#drag_container, #tree_plus').remove(); $('#drag_container, #tree_plus').remove();
if(dragNode_source) if (dragNode_source) {
{
$(dragNode_source).show().prev('.line').show(); $(dragNode_source).show().prev('.line').show();
} }
dragNode_destination = dragNode_source = mousePressed = mouseMoved = false; dragNode_destination = dragNode_source = mousePressed = mouseMoved = false;
@ -419,20 +449,19 @@ $.fn.simpleTree = function(opt){
$('img', node).remove(); $('img', node).remove();
node[0].className = node[0].className.replace(/folder-(open|close)/gi, 'doc'); node[0].className = node[0].className.replace(/folder-(open|close)/gi, 'doc');
}; };
TREE.moveNodeToFolder = function(node) TREE.moveNodeToFolder = function(node) {
{
// Open node if it's closed // Open node if it's closed
if(node[0].className.match('close')){TREE.nodeToggle(node[0]);} if (node[0].className.match('close')) {
if(!TREE.option.docToFolderConvert && node[0].className.indexOf('doc')!=-1) TREE.nodeToggle(node[0]);
{ }
if (!TREE.option.docToFolderConvert && node[0].className.indexOf('doc') != -1) {
return true; return true;
} else if (TREE.option.docToFolderConvert && node[0].className.indexOf('doc') != -1) { } else if (TREE.option.docToFolderConvert && node[0].className.indexOf('doc') != -1) {
TREE.convertToFolder(node); TREE.convertToFolder(node);
} }
TREE.checkNodeIsLast(dragNode_source[0]); TREE.checkNodeIsLast(dragNode_source[0]);
var lastLine = $('>ul >.line-last', node); var lastLine = $('>ul >.line-last', node);
if(lastLine.size()>0) if (lastLine.size() > 0) {
{
TREE.moveNodeToLine(lastLine[0]); TREE.moveNodeToLine(lastLine[0]);
} }
}; };
@ -445,85 +474,70 @@ $.fn.simpleTree = function(opt){
$(dragNode_source).before(line); $(dragNode_source).before(line);
node.className = node.className.replace('-over', ''); node.className = node.className.replace('-over', '');
var nodeSize = $('>ul >li', parent).not('.line, .line-last').filter(':visible').size(); var nodeSize = $('>ul >li', parent).not('.line, .line-last').filter(':visible').size();
if(TREE.option.docToFolderConvert && nodeSize==0) if (TREE.option.docToFolderConvert && nodeSize == 0) {
{
TREE.convertToDoc(parent); TREE.convertToDoc(parent);
}else if(nodeSize==0) } else if (nodeSize == 0) {
{
parent[0].className = parent[0].className.replace('open', 'close'); parent[0].className = parent[0].className.replace('open', 'close');
$('>ul', parent).hide(); $('>ul', parent).hide();
} }
// added by Erik Dohmen (2BinBusiness.nl) select node // added by Erik Dohmen (2BinBusiness.nl) select node
if($('span:first',dragNode_source).attr('class')=='text') if ($('span:first', dragNode_source).attr('class') == 'text') {
{
$('.active', TREE).toggleClass('active').addClass('text'); $('.active', TREE).toggleClass('active').addClass('text');
$('span:first', dragNode_source).toggleClass('text').addClass('active'); $('span:first', dragNode_source).toggleClass('text').addClass('active');
} }
if(typeof(TREE.option.afterMove) == 'function') if (typeof(TREE.option.afterMove) == 'function') {
{
var pos = $(dragNode_source).prevAll(':not(.line)').size(); var pos = $(dragNode_source).prevAll(':not(.line)').size();
TREE.option.afterMove($(node).parents('li:first'), $(dragNode_source), pos); TREE.option.afterMove($(node).parents('li:first'), $(dragNode_source), pos);
} }
}; };
TREE.addNode = function(id, text, callback) TREE.addNode = function(id, text, callback) {
{
TREE.newNodeIn(TREE.getSelected(), id, text, callback); TREE.newNodeIn(TREE.getSelected(), id, text, callback);
}; };
TREE.newNodeIn = function(node, id, text, callback) TREE.newNodeIn = function(node, id, text, callback) {
{
var temp_node = $('<li><ul><li id="' + id + '"><span>' + text + '</span></li></ul></li>'); var temp_node = $('<li><ul><li id="' + id + '"><span>' + text + '</span></li></ul></li>');
TREE.setTreeNodes(temp_node, false); TREE.setTreeNodes(temp_node, false);
destination = node; destination = node;
dragNode_source = $('.doc-last', temp_node); dragNode_source = $('.doc-last', temp_node);
TREE.moveNodeToFolder(destination); TREE.moveNodeToFolder(destination);
temp_node.remove(); temp_node.remove();
if(typeof TREE.option.afterNewNode == 'function') if (typeof TREE.option.afterNewNode == 'function') {
{
TREE.option.afterNewNode(node); TREE.option.afterNewNode(node);
} }
if(typeof(callback) == 'function') if (typeof(callback) == 'function') {
{
callback(dragNode_destination, dragNode_source); callback(dragNode_destination, dragNode_source);
} }
}; };
TREE.newNodeAfter = function(id, text, callback) TREE.newNodeAfter = function(id, text, callback) {
{
TREE.newNodeIn(TREE.getSelected().parent().parent(), id, text, callback); TREE.newNodeIn(TREE.getSelected().parent().parent(), id, text, callback);
}; };
TREE.newAjaxNodeIn = function(node,id,text,url,callback) TREE.newAjaxNodeIn = function(node, id, text, url, callback) {
{
var temp_node = $('<li><ul><li id="' + id + '"><span>' + text + '</span><ul class="ajax"><li id="new">.{url:' + url + '}</li></ul></li></ul></li>'); var temp_node = $('<li><ul><li id="' + id + '"><span>' + text + '</span><ul class="ajax"><li id="new">.{url:' + url + '}</li></ul></li></ul></li>');
TREE.setTreeNodes(temp_node, false); TREE.setTreeNodes(temp_node, false);
destination = node; destination = node;
dragNode_source = $('.folder-close-last', temp_node); dragNode_source = $('.folder-close-last', temp_node);
TREE.moveNodeToFolder(destination); TREE.moveNodeToFolder(destination);
temp_node.remove(); temp_node.remove();
if(typeof TREE.option.afterNewNode == 'function') if (typeof TREE.option.afterNewNode == 'function') {
{
TREE.option.afterNewNode(node); TREE.option.afterNewNode(node);
} }
if(typeof(callback) == 'function') if (typeof(callback) == 'function') {
{
callback(dragNode_destination, dragNode_source); callback(dragNode_destination, dragNode_source);
} }
}; };
TREE.delNode = function(callback) TREE.delNode = function(callback) {
{
dragNode_source = TREE.getSelected(); dragNode_source = TREE.getSelected();
TREE.checkNodeIsLast(dragNode_source[0]); TREE.checkNodeIsLast(dragNode_source[0]);
dragNode_source.prev().remove(); dragNode_source.prev().remove();
dragNode_source.remove(); dragNode_source.remove();
if(typeof(callback) == 'function') if (typeof(callback) == 'function') {
{
callback(dragNode_destination); callback(dragNode_destination);
} }
}; };
TREE.init = function(obj) TREE.init = function(obj) {
{
TREE.setTreeNodes(obj, false); TREE.setTreeNodes(obj, false);
}; };
TREE.init(ROOT); TREE.init(ROOT);

View File

@ -1,4 +1,3 @@
$(document).ready(function() { $(document).ready(function() {
// Adapt some class to fit Bootstrap theme // Adapt some class to fit Bootstrap theme
@ -9,4 +8,3 @@ $(document).ready(function(){
$("table.info").addClass("table"); $("table.info").addClass("table");
}); });

View File

@ -12,14 +12,26 @@
*/ */
/* Set autocomplete real value */ /* Set autocomplete real value */
if(autocomplete.match('1')){autocomplete='on';} if (autocomplete.match('1')) {
if(autocomplete.match('0')){autocomplete='off';} autocomplete = 'on';
}
if (autocomplete.match('0')) {
autocomplete = 'off';
}
/* Set newwindow value (default is false) */ /* Set newwindow value (default is false) */
if(newwindow.match('1')){newwindow=true;}else{newwindow=false;} if (newwindow.match('1')) {
newwindow = true;
} else {
newwindow = false;
}
/* Set antiframe value (default is true) */ /* Set antiframe value (default is true) */
if(antiframe.match('0')){antiframe=false;}else{antiframe=true;} if (antiframe.match('0')) {
antiframe = false;
} else {
antiframe = true;
}
/* jQuery */ /* jQuery */
$(document).ready(function() { $(document).ready(function() {
@ -36,7 +48,9 @@ $(document).ready(function(){
opacity: 0.5, opacity: 0.5,
revert: true, revert: true,
items: "> div.category", items: "> div.category",
update: function(){ getOrder(); } update: function() {
getOrder();
}
}); });
restoreOrder(); restoreOrder();
@ -48,13 +62,19 @@ $(document).ready(function(){
$("input[name=timezone]").val(-(new Date().getTimezoneOffset() / 60)); $("input[name=timezone]").val(-(new Date().getTimezoneOffset() / 60));
/* Menu tabs */ /* Menu tabs */
var menuTabs = $("#menu").tabs({active:0}); var menuTabs = $("#menu").tabs({
active: 0
});
var menuIndex = $('#menu a[href="#' + displaytab + '"]').parent().index(); var menuIndex = $('#menu a[href="#' + displaytab + '"]').parent().index();
if (menuIndex<0){menuIndex=0;} if (menuIndex < 0) {
menuIndex = 0;
}
menuTabs.tabs("option", "active", menuIndex); menuTabs.tabs("option", "active", menuIndex);
/* Authentication choice tabs */ /* Authentication choice tabs */
var authMenuTabs = $("#authMenu").tabs({active:0}); var authMenuTabs = $("#authMenu").tabs({
active: 0
});
// TODO: cookie // TODO: cookie
//$("#authMenu").tabs({cookie: {name: 'lemonldapauthchoice'}}); //$("#authMenu").tabs({cookie: {name: 'lemonldapauthchoice'}});
if (choicetab) { if (choicetab) {
@ -64,13 +84,17 @@ $(document).ready(function(){
/* Focus on first visible input */ /* Focus on first visible input */
$("input[type!=hidden]:first").focus(); $("input[type!=hidden]:first").focus();
if(login){ $("input[type=password]:first").focus(); } if (login) {
$("input[type=password]:first").focus();
}
/* Password autocompletion */ /* Password autocompletion */
$("input[type='password']").attr("autocomplete", autocomplete); $("input[type='password']").attr("autocomplete", autocomplete);
/* Open links in new windows */ /* Open links in new windows */
if(newwindow){ $('#appslist a').attr("target", "_blank"); } if (newwindow) {
$('#appslist a').attr("target", "_blank");
}
/* Complete removeOther link */ /* Complete removeOther link */
if ($("p.removeOther").length) { if ($("p.removeOther").length) {
@ -106,7 +130,9 @@ function getOrder() {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: scriptname, url: scriptname,
data:{storeAppsListOrder:$(setSelector).sortable("toArray").join()}, data: {
storeAppsListOrder: $(setSelector).sortable("toArray").join()
},
dataType: 'json' dataType: 'json'
}); });
} }
@ -173,9 +199,12 @@ function isHiddenFormValueSet(option){
} }
} }
function ping() { function ping() {
$.ajax({type:"POST", $.ajax({
type: "POST",
url: scriptname, url: scriptname,
data:{ping:1}, data: {
ping: 1
},
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
if (!data.auth) { if (!data.auth) {
@ -184,10 +213,10 @@ function ping() {
else { else {
setTimeout('ping();', 60000); setTimeout('ping();', 60000);
} }
}/*, }
/*,
error:function(xhr, ajaxOptions, thrownError){ error:function(xhr, ajaxOptions, thrownError){
alert('Request failed Error code: '+xhr.status+', '+thrownError); alert('Request failed Error code: '+xhr.status+', '+thrownError);
}*/ }*/
}); });
} }