Gestion des recommandations de nom/prénom/pseudo

This commit is contained in:
xdrm-brackets 2016-04-28 16:32:09 +02:00
parent 3e8890d234
commit 9654855506
16 changed files with 153 additions and 37 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -477,7 +477,7 @@
/* (14) Switch entre Nom et Prénom */ /* (14) Switch entre Nom et Prénom */
& span.switch{ & span.switch-both{
display: inline-block; display: inline-block;
position: relative; position: relative;
width: 1em; width: 1em;
@ -485,7 +485,25 @@
margin-right: 15px; margin-right: 15px;
background: url('/f/svg/switch/st/container/4e4e50') center center no-repeat; background: url('/f/svg/switch-both/st/container/4e4e50') center center no-repeat;
background-size: 1em auto;
font-size: .8em;
cursor: pointer;
}
/* (15) Switch Prénom+Nom = Pseudo */
& span.switch-left{
display: inline-block;
position: relative;
width: 1em;
height: 1em;
margin-right: 15px;
background: url('/f/svg/switch-left/st/container/4e4e50') center center no-repeat;
background-size: 1em auto; background-size: 1em auto;
font-size: .8em; font-size: .8em;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -6,8 +6,9 @@ contactBuilder.setLayout(
"<h4 data-icon='p' class='new-contact color2'> \n"+ "<h4 data-icon='p' class='new-contact color2'> \n"+
"\t<input type='text' data-name='number' placeholder='Numéro de téléphone' value='@number' > \n"+ "\t<input type='text' data-name='number' placeholder='Numéro de téléphone' value='@number' > \n"+
"\t<input type='text' data-name='username' placeholder='Pseudo' value='@username' > \n"+ "\t<input type='text' data-name='username' placeholder='Pseudo' value='@username' > \n"+
"\t<span class='switch-left'></span> \n"+
"\t<input type='text' data-name='firstname' placeholder='Prénom' value='@firstname' > \n"+ "\t<input type='text' data-name='firstname' placeholder='Prénom' value='@firstname' > \n"+
"\t<span class='switch'></span> \n"+ "\t<span class='switch-both'></span> \n"+
"\t<input type='text' data-name='lastname' placeholder='Nom' value='@lastname' > \n"+ "\t<input type='text' data-name='lastname' placeholder='Nom' value='@lastname' > \n"+
"\t<input type='submit' class='primary sub-number' value='Enregistrer'>\n"+ "\t<input type='submit' class='primary sub-number' value='Enregistrer'>\n"+
"</h4>\n\n"); "</h4>\n\n");

View File

@ -138,7 +138,7 @@
=========================================================*/ =========================================================*/
return array( return array(
'ModuleError' => ManagerError::Success, 'ModuleError' => ManagerError::Success,
'directory' => $sorted_directory, 'directory' => $sorted_directory,
'logs' => $phone_logs 'logs' => $phone_logs
); );
} }

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="32"
version="1.1"
viewBox="0 0 32 32"
width="32"
xml:space="preserve"
id="svg4190"
inkscape:version="0.91 r13725"
sodipodi:docname="switch-left.svg"><metadata
id="metadata4204"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs4202" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1056"
id="namedview4200"
showgrid="false"
inkscape:snap-page="true"
inkscape:zoom="14.053747"
inkscape:cx="11.638408"
inkscape:cy="5.4307279"
inkscape:window-x="0"
inkscape:window-y="24"
inkscape:window-maximized="1"
inkscape:current-layer="svg4190" /><g
id="Layer_1"
transform="translate(0,8)" /><g
id="transfer"
transform="translate(0,-2)"><g
id="g4194"><polygon
points="7.992,16 32,16 32,20 7.992,20 7.992,24 0,18 7.992,12 "
style="fill:#4e4e50"
id="stylisable" /></g></g></svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -1,6 +1,7 @@
var clearAllButton=$("#clear-all"),importCallLog=$('input#call_log-import[type="file"]'),subjectManager,contactManager,miniManager,ficheManager; var clearAllButton=$("#clear-all"),importCallLog=$('input#call_log-import[type="file"]'),subjectManager,contactManager,miniManager,ficheManager;
function dynamicUpdate(a){console.log(a);var b="SPAN"==a.tagName&&"switch"==a.className,c="INPUT"==a.tagName&&"submit"==a.type,d="SPAN"==a.tagName&&("nav-mini"==a.parentNode.id||"nav-fiche"==a.parentNode.id);if(!b&&!c&&~d)return!1;b?(console.log("> switch firstname <-> lastname"),b=a.parentNode,a=b.children[2],b=b.children[4],c=a.value,a.value=b.value,b.value=c):(console.log("> dynamic update"),miniManager.fieldsToStorage(),ficheManager.fieldsToStorage(),contactManager.fieldsToStorage(),miniManager.sync(), function dynamicUpdate(a){var b="SPAN"==a.tagName&&"switch-left"==a.className,c="SPAN"==a.tagName&&"switch-both"==a.className,e="INPUT"==a.tagName&&"submit"==a.type,d="SPAN"==a.tagName&&("nav-mini"==a.parentNode.id||"nav-fiche"==a.parentNode.id);if(!(c||b||e||d)&&!0!==a)return!1;c?(console.log("> switch firstname <-> lastname"),b=a.parentNode,a=b.children[3],b=b.children[5],c=a.value,a.value=b.value,b.value=c):b?(console.log("> switch firstname+lastname -> username"),b=a.parentNode,c=b.children[1],
ficheManager.sync(),miniManager.storageToFields(),ficheManager.storageToFields(),contactManager.storageToFields())}function checkRadioValue(a){for(var b=0,c=0;c<a.length;c++)!0===a[c].status&&b++;return 1!=b?!1:!0} a=b.children[3],b=b.children[5],c.value=a.value+" "+b.value,a.value="",b.value=""):(console.log("> dynamic update"),miniManager.fieldsToStorage(),ficheManager.fieldsToStorage(),contactManager.fieldsToStorage(),miniManager.sync(),ficheManager.sync(),miniManager.storageToFields(),ficheManager.storageToFields(),contactManager.storageToFields())}function checkRadioValue(a){for(var b=0,c=0;c<a.length;c++)!0===a[c].status&&b++;return 1!=b?!1:!0}
include("/js/includes/input-phone-subject.js",function(){include("/js/includes/input-phone-contact.js",function(){include("/js/includes/input-phone-mini.js",function(){include("/js/includes/input-phone-fiche.js",function(){subjectManager=new inputPhoneSubject($('article.subject-panel [data-name="number"]'),$('article.subject-panel [data-name="username"]'),$('article.subject-panel [data-name="firstname"]'),$('article.subject-panel [data-name="lastname"]'),$('article.subject-panel [data-name="submit"]')); include("/js/includes/input-phone-subject.js",function(){include("/js/includes/input-phone-contact.js",function(){include("/js/includes/input-phone-mini.js",function(){include("/js/includes/input-phone-fiche.js",function(){subjectManager=new inputPhoneSubject($('article.subject-panel [data-name="number"]'),$('article.subject-panel [data-name="username"]'),$('article.subject-panel [data-name="firstname"]'),$('article.subject-panel [data-name="lastname"]'),$('article.subject-panel [data-name="submit"]'));
subjectManager.attach();contactManager=new inputPhoneContact($("article.contact-panel"),$("h4.add-contact"));contactManager.attach(dynamicUpdate);miniManager=new inputPhoneMini($("article.mini-relation-panel"),$("#nav-mini"));miniManager.attach(dynamicUpdate);ficheManager=new inputPhoneFiche($("article.relation-panel"),$("#nav-fiche"));ficheManager.attach(dynamicUpdate);importCallLog.addEventListener("change",function(a){api.send({path:"upload/call_log",file:importCallLog.files[0]},function(a){console.log(a); subjectManager.attach();contactManager=new inputPhoneContact($("article.contact-panel"),$("h4.add-contact"));contactManager.attach(dynamicUpdate);miniManager=new inputPhoneMini($("article.mini-relation-panel"),$("#nav-mini"));miniManager.attach(dynamicUpdate);ficheManager=new inputPhoneFiche($("article.relation-panel"),$("#nav-fiche"));ficheManager.attach(dynamicUpdate);importCallLog.addEventListener("change",function(a){api.send({path:"upload/call_log",file:importCallLog.files[0]},function(a){console.log(a);
0==a.ModuleError&&(importCallLog.addClass("active"),a={path:"call_log/unserialize",phone_number:$("#subject_phone_number").value},api.send(a,function(a){console.log(a);if(0==a.ModuleError){for(var b=0;b<a.directory.length&&20>b;b++)lsi.set("contacts","form"+b,{uid:b,number:a.directory[b].number,username:a.directory[b].name,firstname:"",lastname:""});dynamicUpdate()}}))})},!1);clearAllButton.addEventListener("click",function(a){localStorage.clear();reload()},!1)})})})}); 0==a.ModuleError&&(importCallLog.addClass("active"),a={path:"call_log/unserialize",phone_number:$("#subject_phone_number").value},api.send(a,function(a){console.log(a);if(0==a.ModuleError){for(var b=0;b<a.directory.length&&20>b;b++){var d=a.directory[b].name.split(" ");lsi.set("contacts","form"+b,{uid:b,number:a.directory[b].number,username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):""})}dynamicUpdate()}}))})},!1);clearAllButton.addEventListener("click",
function(a){localStorage.clear();reload()},!1)})})})});

View File

@ -23,34 +23,52 @@ var ficheManager;
function dynamicUpdate(target){ function dynamicUpdate(target){
/* (0) Vérification de la cohérence de la @target /* (0) Vérification de la cohérence de la @target
---------------------------------------------------------*/ ---------------------------------------------------------*/
console.log(target); var isSwitchLeft = target.tagName == 'SPAN' && target.className == 'switch-left';
var isSwitch = target.tagName == 'SPAN' && target.className == 'switch'; var isSwitchBoth = target.tagName == 'SPAN' && target.className == 'switch-both';
var isSaveButton = target.tagName == 'INPUT' && target.type == 'submit'; var isSaveButton = target.tagName == 'INPUT' && target.type == 'submit';
var isNavButton = target.tagName == 'SPAN' && (target.parentNode.id == 'nav-mini' || target.parentNode.id == 'nav-fiche'); var isNavButton = target.tagName == 'SPAN' && (target.parentNode.id == 'nav-mini' || target.parentNode.id == 'nav-fiche');
// Si erreur, on retourne une erreur // Si erreur, on retourne une erreur
if( !isSwitch && !isSaveButton && ~isNavButton ) if( !isSwitchBoth && !isSwitchLeft && !isSaveButton && !isNavButton && target !== true )
return false; return false;
/* (1) Gestion de l'échange de nom/prénom /* (1) Gestion de l'échange de nom/prénom
---------------------------------------------------------*/ ---------------------------------------------------------*/
if( isSwitch ){ if( isSwitchBoth ){
console.log('> switch firstname <-> lastname'); console.log('> switch firstname <-> lastname');
/* (1) On récupère le formulaire parent */ /* (1) On récupère le formulaire parent */
var currentForm = target.parentNode; var currentForm = target.parentNode;
/* (2) On récupère Nom et Prénom */ /* (2) On récupère Nom et Prénom */
var firstname = currentForm.children[2]; var firstname = currentForm.children[3];
var lastname = currentForm.children[4]; var lastname = currentForm.children[5];
/* (3) On échange leurs valeurs */ /* (3) On échange leurs valeurs */
var tmp = firstname.value; var tmp = firstname.value;
firstname.value = lastname.value; firstname.value = lastname.value;
lastname.value = tmp; lastname.value = tmp;
}else if( isSwitchLeft ){
/* (2) Gestion de l'échange Prénom+Nom = Pseudo
---------------------------------------------------------*/
console.log('> switch firstname+lastname -> username');
/* (2) Gestion de la mise à jour dynamique /* (1) On récupère le formulaire parent */
var currentForm = target.parentNode;
/* (2) On récupère Pseudo, Nom et Prénom */
var username = currentForm.children[1];
var firstname = currentForm.children[3];
var lastname = currentForm.children[5];
/* (3) On attribue à Pseudo, la valeur de Prénom+Nom */
username.value = firstname.value +' '+ lastname.value;
firstname.value = '';
lastname.value = '';
/* (3) Gestion de la mise à jour dynamique
---------------------------------------------------------*/ ---------------------------------------------------------*/
}else{ }else{
console.log('> dynamic update'); console.log('> dynamic update');
@ -190,12 +208,15 @@ include('/js/includes/input-phone-fiche.js', function(){
/* (5) Pour chaque contact de l'annuaire, on ajoute un contact */ /* (5) Pour chaque contact de l'annuaire, on ajoute un contact */
for( var i = 0 ; i < dataResponse.directory.length && i < 20 ; i++ ){ for( var i = 0 ; i < dataResponse.directory.length && i < 20 ; i++ ){
// On découpe le nom par espaces
var splitted = dataResponse.directory[i].name.split(' ');
lsi.set('contacts', 'form'+i, { lsi.set('contacts', 'form'+i, {
uid: i, uid: i,
number: dataResponse.directory[i].number, number: dataResponse.directory[i].number,
username: dataResponse.directory[i].name, username: splitted.length == 1 ? splitted[0] : '', // Si un seul mot -> pseudo
firstname: '', firstname: splitted.length > 1 ? splitted[0] : '', // Si plusieurs mots -> le 1er est le prénom
lastname: '' lastname: splitted.length > 1 ? splitted.splice(1).join(' ') : '' // et les autres sont le nom
}); });
} }