1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-28 04:04:30 +01:00
ldapcherry/resources/static/js/lc-filler.js
2016-06-19 01:48:50 +09:00

33 lines
925 B
JavaScript

/*
* Licensed under the MIT public license.
*
* Part of LdapCherry.
*
* Functions to autofill form fields from other fields.
*
*/
function lcUid(firstname, lastname){
var ascii_firstname = removeDiacritics(firstname).toLowerCase().replace(/[^a-z]/g, '');
var ascii_lastname = removeDiacritics(lastname).toLowerCase().replace(/[^a-z]/g, '');
return ascii_firstname.charAt(0)+ascii_lastname.substring(0,7);
}
function lcDisplayName(firstname, lastname){
return firstname+' '+lastname;
}
function lcMail(firstname, lastname, domain){
return lcUid(firstname, lastname)+domain;
}
function lcUidNumber(firstname, lastname, minuid, maxuid){
var iminuid = parseInt(minuid);
var imaxuid = parseInt(maxuid);
return (parseInt('0x'+sha1(firstname+lastname)) % (imaxuid - iminuid)) + iminuid;
}
function lcHomeDir(firstname, lastname, basedir){
return basedir+lcUid(firstname, lastname);
}