var sField=$("#search-field"),sSubmit=$("#search-subject"),sList=$('section[data-sublink="survey"] ul[data-list]'),tmpSubjectSearchListener=function(a){api.send({path:"subject/search",name:sField.value},function(b){if(0!=b.ModuleError)return Notification.error("Erreur","La recherche a \u00e9chou\u00e9."),!1;console.log(b);var a="",f;for(f in b.results)a+="
  • ",a+="
    SUJET
    ",a+="
    ",a+="
    "+b.results[f].name+"
    ",a+="
    "+b.results[f].creation+"
    ",a+="
    ",a+="
    ",a+="
    ",a+="
    ", a+="
  • ";sList.innerHTML=a})};sSubmit.addEventListener("click",tmpSubjectSearchListener,!1);sField.addEventListener("keypress",function(a){13===a.keyCode&&tmpSubjectSearchListener(a)},!1);var pSubjectManager,pContactManager,pMiniManager,pFicheManager,pMatriceManager; function pDynamicUpdate(a){var b=a instanceof Element,g=b&&"INPUT"==a.tagName&&"submit"==a.type,f=b&&"SPAN"==a.tagName&&("p_nav-mini"==a.parentNode.id||"p_nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"p_nav-contact"==a.parentNode.id;if(!g&&!f&&!b&&!0!==a)return!1;console.log("> dynamic update");pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();pContactManager.fieldsToStorage();pMatriceManager.fieldsToStorage();pFicheManager.sync();pMiniManager.sync();!0===a?api.send({path:"subject/getFriends", subject_id:pSubjectManager.subject_id.value},function(a){if(0!=a.ModuleError)return!1;lsi["import"]("p_friends",a.subjects);pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();pContactManager.storageToFields()}):(pMiniManager.storageToFields(),pFicheManager.storageToFields(),pMatriceManager.storageToFields(),(g||b)&&pContactManager.storageToFields())}var fSubjectManager,fContactManager,fMiniManager,fFicheManager,fMatriceManager; function fDynamicUpdate(a){var b=a instanceof Element,g=b&&"INPUT"==a.tagName&&"submit"==a.type,f=b&&"SPAN"==a.tagName&&("f_nav-mini"==a.parentNode.id||"f_nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"f_nav-contact"==a.parentNode.id;if(!g&&!f&&!b&&!0!==a)return!1;console.log("> dynamic update");fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();!0===a?api.send({path:"subject/getFriends", subject_id:fSubjectManager.subject_id.value},function(a){if(0!=a.ModuleError)return!1;lsi["import"]("f_friends",a.subjects);fMiniManager.storageToFields();fFicheManager.storageToFields();fMatriceManager.storageToFields();fContactManager.storageToFields()}):(fMiniManager.storageToFields(),fFicheManager.storageToFields(),fMatriceManager.storageToFields(),(g||b)&&fContactManager.storageToFields())} include("/js/includes/input-phone-subject-min.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(){include("/js/includes/input-phone-matrice-min.js",function(){pSubjectManager=new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="submit"]')); pSubjectManager.attach(pDynamicUpdate);pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact'));pContactManager.attach(pDynamicUpdate);pMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),$('[data-sublink="phone"] #p_nav-mini'));pMiniManager.attach(pDynamicUpdate);pFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),$('[data-sublink="phone"] #p_nav-fiche')); pFicheManager.attach(pDynamicUpdate);pMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel'));pMatriceManager.attach(pDynamicUpdate);var a=new ShortcutManager,b=!1;a.append("s+n+a+k+e",function(){b||(b=!0,pMatriceManager.snake())});a.listen();$('[data-sublink="phone"] #p_clear-all').addEventListener("click",function(a){lsi.clear("p_subject");lsi.clear("p_contacts");lsi.clear("p_mini-fiches");lsi.clear("p_fiches");lsi.clear("p_matrice");lsi.clear("p_friends");pSubjectManager.storageToFields(); pContactManager.storageToFields();pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="phone"] #p_export-all').addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"), matrice:lsi["export"]("p_matrice")[0]};var b=$('[data-sublink="phone"] #p_download-target');b.download="local-phone-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1);$('[data-sublink="phone"] #p_import-all').addEventListener("click",function(a){$('[data-sublink="phone"] #p_local-upload').click()},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("change", function(a){a={path:"upload/local_data",file:$('[data-sublink="phone"] #p_local-upload').files[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("p_subject",0,a.local_data.subject);lsi["import"]("p_contacts",a.local_data.contacts);lsi["import"]("p_mini-fiches",a.local_data.mini);lsi["import"]("p_fiches",a.local_data.fiches);lsi.set("p_matrice",0,a.local_data.matrice);pSubjectManager.storageToFields();pContactManager.storageToFields(); pMatriceManager.storageToFields();pDynamicUpdate(!0)})},!1);$('[data-sublink="phone"] #p_submit-all').addEventListener("click",function(a){console.log("> GATHERING ALL DATA");pSubjectManager.fieldsToStorage();pContactManager.fieldsToStorage();pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();if(!pSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du sujet"),!1;a=lsi["export"]("p_mini-fiches");var b=0,c;for(c in a)if(!isNaN(c)&&(b++, !a[c].valid))return Notification.warning("Attention","La fiche rapide "+b+" est incompl\u00e8te et/ou incorrecte"),!1;a=lsi["export"]("p_fiches");for(c in a)if(!a[c].valid)return Notification.warning("Attention","La fiche compl\u00e8te "+(parseInt(c)+1)+" est incompl\u00e8te et/ou incorrecte"),!1;c={path:"input/phone",subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]}; api.send(c,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;Notification.success("OK","L'identifiant du sujet est "+a.subject_id+" ! Tout s'est bien d\u00e9roul\u00e9.",1E4);console.log(a)},!1)},!1)})})})})}); include("/js/includes/input-facebook-subject-min.js",function(){include("/js/includes/input-facebook-contact.js",function(){include("/js/includes/input-facebook-mini.js",function(){include("/js/includes/input-facebook-fiche.js",function(){include("/js/includes/input-facebook-matrice-min.js",function(){fSubjectManager=new inputFacebookSubject($('[data-sublink="facebook"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="facebook"] article.subject-panel [data-name="submit"]'));fSubjectManager.attach(fDynamicUpdate); fContactManager=new inputFacebookContact($('[data-sublink="facebook"] article.contact-panel'),$('[data-sublink="facebook"] #f_nav-contact'));fContactManager.attach(fDynamicUpdate);fMiniManager=new inputFacebookMini($('[data-sublink="facebook"] article.mini-relation-panel'),$('[data-sublink="facebook"] #f_nav-mini'));fMiniManager.attach(fDynamicUpdate);fFicheManager=new inputFacebookFiche($('[data-sublink="facebook"] article.relation-panel'),$('[data-sublink="facebook"] #f_nav-fiche'));fFicheManager.attach(fDynamicUpdate); fMatriceManager=new inputFacebookMatrice($('[data-sublink="facebook"] article.matrice-panel'));fMatriceManager.attach(fDynamicUpdate);$('[data-sublink="facebook"] #f_clear-all').addEventListener("click",function(a){lsi.clear("f_subject");lsi.clear("f_contacts");lsi.clear("f_mini-fiches");lsi.clear("f_fiches");lsi.clear("f_matrice");lsi.clear("f_friends");fSubjectManager.storageToFields();fContactManager.storageToFields();fMiniManager.storageToFields();fFicheManager.storageToFields();fMatriceManager.storageToFields(); Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="facebook"] #f_export-all').addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};var b=$('[data-sublink="facebook"] #f_download-target');b.download= "local-facebook-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1);$('[data-sublink="facebook"] #f_import-all').addEventListener("click",function(a){$('[data-sublink="facebook"] #f_local-upload').click()},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("change",function(a){a={path:"upload/local_data",file:$('[data-sublink="facebook"] #f_local-upload').files[0]}; api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("f_subject",0,a.local_data.subject);lsi["import"]("f_contacts",a.local_data.contacts);lsi["import"]("f_mini-fiches",a.local_data.mini);lsi["import"]("f_fiches",a.local_data.fiches);lsi.set("f_matrice",0,a.local_data.matrice);fSubjectManager.storageToFields();fContactManager.storageToFields();fMatriceManager.storageToFields();fDynamicUpdate(!0)})},!1);$('[data-sublink="facebook"] #f_submit-all').addEventListener("click", function(a){console.log("> GATHERING ALL DATA");fSubjectManager.fieldsToStorage();fContactManager.fieldsToStorage();fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();if(!fSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du sujet"),!1;a=lsi["export"]("f_mini-fiches");var b=0,g;for(g in a)if(!isNaN(g)&&(b++,!a[g].valid))return Notification.warning("Attention","La fiche rapide "+b+" est incompl\u00e8te et/ou incorrecte"), !1;a=lsi["export"]("f_fiches");for(g in a)if(!a[g].valid)return Notification.warning("Attention","La fiche compl\u00e8te "+(parseInt(g)+1)+" est incompl\u00e8te et/ou incorrecte"),!1;g={path:"input/facebook",subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};api.send(g,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError), !1;console.log(a)},!1)},!1)})})})})}); function testRoutinePhone(a){var b=lsi["export"]("p_contacts"),g=lsi["export"]("p_mini-fiches"),f=lsi["export"]("p_fiches"),c=0;if(null!=a&&a)for(var e in g)isNaN(e)||(a="",null!=b[e]&&(a=b[e].username),g=$('#p_nav-mini [data-n="'+e+'"]'),g.click(),$("#unknown_min_p_"+e).checked=0==a.length,0==a.length?($("#sexeI_mini_p_"+e).checked=!0,$('input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="age"]').value=c%19,$('input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="studies"]').value=0, $("#reltype9_mini_p_"+e).checked=!0):(a=["H","F"][Math.floor(c%2)],$("#sexe"+a+"_mini_p_"+e).checked=!0,$('input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="age"]').value=c%19,$('input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="studies"]').value=1+c%6,a=c%10,9==a?($("#reltype10_mini_p_"+e).checked=!0,$('input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_mini_p_"+e).checked=!0,c++));for(var d in f)isNaN(d)||(g=$('#p_nav-fiche [data-n="'+ d+'"]'),g.click(),a=["H","F","I"][Math.floor(c%3)],$("#sexe"+a+"_p_"+d).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 select[data-name="age"]').value=c%19,b="10 21 22 23 31 32 36 41 46 47 48 51 54 55 56 61 66 69 71 72 73 74 75 76 81 82".split(" "),b=b[c%b.length],$('article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 select[data-name="job"]').value=b,b=(c%12).toString(),1==b.length&&(b="0"+b),$('article.fiche-relation > input[data-name="uid"][value="'+ d+'"] ~ h5 select[data-name="studies"]').value=b,a=c%9,8==a?($("#reltype10_p_"+d).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_p_"+d).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 input[data-name="city"]').value=(10+c).toString(),$('article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 input[data-name="cp"]').value=(1E4+c).toString(),$('article.fiche-relation > input[data-name="uid"][value="'+ d+'"] ~ h5 input[data-name="quartier"]').value=c,$("#loc"+["A","B","C","D"][Math.floor(c%4)]+"_p_"+d).checked=!0,b=$$('article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 input[data-name="duration"]'),b[0].value=c.toString(),b[1].value=1+c.toString(),b=c%14,$("article.fiche-relation #contexte"+b+"_p_"+d).checked=!0,f=$$('article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 input[data-name="contextSpecial"]'),11==b&&(f[0].value="internet"),12==b&&(f[1].value="association"), 13==b&&(f[2].value="autre"),c++)} function testRoutineFacebook(a){var b=lsi["export"]("f_contacts"),g=lsi["export"]("f_mini-fiches"),f=lsi["export"]("f_fiches"),c=0;if(null!=a&&a)for(var e in g)isNaN(e)||(a="",null!=b[e]&&(a=b[e].username),g=$('#f_nav-mini [data-n="'+e+'"]'),g.click(),$("#unknown_min_f_"+e).checked=0==a.length,0==a.length?($("#sexeI_mini_f_"+e).checked=!0,$('input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="age"]').value=c%19,$('input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="studies"]').value=0, $("#reltype9_mini_f_"+e).checked=!0):(a=["H","F"][Math.floor(c%2)],$("#sexe"+a+"_mini_f_"+e).checked=!0,$('input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="age"]').value=c%19,$('input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="studies"]').value=1+c%6,a=c%10,9==a?($("#reltype10_mini_f_"+e).checked=!0,$('input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_mini_f_"+e).checked=!0,c++));for(var d in f)isNaN(d)||(g=$('#f_nav-fiche [data-n="'+ d+'"]'),g.click(),a=["H","F","I"][Math.floor(c%3)],$("#sexe"+a+"_f_"+d).checked=!0,$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 select[data-name="age"]').value=c%19,b="10 21 22 23 31 32 36 41 46 47 48 51 54 55 56 61 66 69 71 72 73 74 75 76 81 82".split(" "),b=b[c%b.length],$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 select[data-name="job"]').value=b,b=(c%12).toString(),1==b.length&& (b="0"+b),$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 select[data-name="studies"]').value=b,a=c%9,8==a?($("#reltype10_f_"+d).checked=!0,$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_f_"+d).checked=!0,$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 input[data-name="city"]').value= (10+c).toString(),$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 input[data-name="cp"]').value=(1E4+c).toString(),$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 input[data-name="quartier"]').value=c,$("#loc"+["A","B","C","D"][Math.floor(c%4)]+"_f_"+d).checked=!0,b=$$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 input[data-name="duration"]'), b[0].value=c.toString(),b[1].value=1+c.toString(),b=c%14,$('section[data-sublink="facebook"] article.fiche-relation #contexte'+b+"_f_"+d).checked=!0,f=$$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 input[data-name="contextSpecial"]'),11==b&&(f[0].value="internet"),12==b&&(f[1].value="association"),13==b&&(f[2].value="autre"),c++)};