1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-25 02:34:31 +01:00
ldapcherry/resources/static/js/lc-filler.js

43 lines
1.2 KiB
JavaScript
Raw Normal View History

2015-07-08 00:42:53 +02:00
/*
* Licensed under the MIT public license.
*
* Part of LdapCherry.
*
* Functions to autofill form fields from other fields.
*
*/
2019-07-09 15:15:59 +02:00
function normalizeName(name) {
return removeDiacritics(name).toLowerCase().replace(/[^a-z]/g, '');
}
function lcUidExt(firstname, lastname, firstnameEnd, lastnameEnd){
return normalizeName(firstname).substring(0, parseInt(firstnameEnd))+normalizeName(lastname).substring(0,parseInt(lastnameEnd));
}
2015-07-08 00:42:53 +02:00
function lcUid(firstname, lastname){
2019-07-09 15:15:59 +02:00
return lcUidExt(firstname, lastname, 0, 7);
2015-07-08 00:42:53 +02:00
}
function lcDisplayName(firstname, lastname){
2015-07-08 00:59:23 +02:00
return firstname+' '+lastname;
2015-07-08 00:42:53 +02:00
}
2019-07-09 15:15:59 +02:00
function lcMailExt(firstname, lastname, domain, firstnameEnd, lastnameEnd){
return lcUidExt(firstname, lastname, firstnameEnd, lastnameEnd)+domain;
}
2015-07-08 00:42:53 +02:00
function lcMail(firstname, lastname, domain){
return lcUid(firstname, lastname)+domain;
2015-07-08 00:42:53 +02:00
}
function lcUidNumber(firstname, lastname, minuid, maxuid){
var iminuid = parseInt(minuid);
var imaxuid = parseInt(maxuid);
2016-06-18 18:48:50 +02:00
return (parseInt('0x'+sha1(firstname+lastname)) % (imaxuid - iminuid)) + iminuid;
2015-07-08 00:42:53 +02:00
}
function lcHomeDir(firstname, lastname, basedir){
return basedir+lcUid(firstname, lastname);
2015-07-08 00:42:53 +02:00
}