25 lines
12 KiB
JavaScript
25 lines
12 KiB
JavaScript
var sField,sSubmit,sList,pSubjectManager,pContactManager,pMiniManager,pFicheManager,pMatriceManager,fSubjectManager,fContactManager,fMiniManager,fFicheManager,fMatriceManager;
|
|
document.body.addEventListener("load",function(){function e(b){var c=b instanceof Element,a=c&&"INPUT"==b.tagName&&"submit"==b.type,d=c&&"SPAN"==b.tagName&&("p_nav-mini"==b.parentNode.id||"p_nav-fiche"==b.parentNode.id),c=c&&"SPAN"==b.tagName&&"p_nav-contact"==b.parentNode.id;if(!a&&!d&&!c&&!0!==b)return!1;console.log("> dynamic update");pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();pContactManager.fieldsToStorage();pMatriceManager.fieldsToStorage();pFicheManager.sync();pMiniManager.sync();
|
|
!0===b?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(),(a||c)&&pContactManager.storageToFields())}function f(b){var c=b instanceof Element,a=c&&"INPUT"==b.tagName&&
|
|
"submit"==b.type,d=c&&"SPAN"==b.tagName&&("f_nav-mini"==b.parentNode.id||"f_nav-fiche"==b.parentNode.id),c=c&&"SPAN"==b.tagName&&"f_nav-contact"==b.parentNode.id;if(!a&&!d&&!c&&!0!==b)return!1;console.log("> dynamic update");fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();!0===b?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(),(a||c)&&fContactManager.storageToFields())}sField=$("#search-field");sSubmit=$("#search-subject");sList=$('section[data-sublink="survey"] ul[data-list]');var g=function(b){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="",d;for(d in b.results)a+="<li data-element data-id='"+d+"'>",a+="<div data-user><span>SUJET</span></div>",a+="<div> <span><input type='text' readonly style='text-align: center' onclick='this.select()' class='flag' value='"+d+"'></span> </div>",a+="<div> <span data-prefix='Nom'>"+b.results[d].name+"</span> </div>",a+="<div> <span data-prefix='Cr\u00e9ation'>"+b.results[d].creation+
|
|
"</span> </div>",a+="<div> <span><input type='checkbox' id='s_"+d+"' "+(null!=b.results[d].phone?"checked":"")+" disabled><label for='s_"+d+"'>Cellulaire</label>",a+="</span> </div>",a+="<div> <span><input type='checkbox' id='s_"+d+"' "+(null!=b.results[d].facebook?"checked":"")+" disabled><label for='s_"+d+"'>Facebook</label>",a+="</span> </div>",a+="</li>";sList.innerHTML=a})};sSubmit.addEventListener("click",g,!1);sField.addEventListener("keypress",function(b){13===b.keyCode&&g(b)},!1);fMatriceManager=
|
|
fFicheManager=fMiniManager=fContactManager=fSubjectManager=pMatriceManager=pFicheManager=pMiniManager=pContactManager=pSubjectManager=null;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(e);pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact'));pContactManager.attach(e);pMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),$('[data-sublink="phone"] #p_nav-mini'));pMiniManager.attach(e);pFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),
|
|
$('[data-sublink="phone"] #p_nav-fiche'));pFicheManager.attach(e);pMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel'));pMatriceManager.attach(e);var b=new ShortcutManager,c=!1;b.append("s+n+a+k+e",function(){c||(c=!0,pMatriceManager.snake())});b.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();e(!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 <i>sujet</i>"),!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 <i>fiche rapide</i> <b>"+b+"</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 <i>fiche compl\u00e8te</i> <b>"+(parseInt(c)+1)+"</b> 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 <strong>"+a.subject_id+"</strong> ! 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(f);fContactManager=new inputFacebookContact($('[data-sublink="facebook"] article.contact-panel'),$('[data-sublink="facebook"] #f_nav-contact'));fContactManager.attach(f);fMiniManager=new inputFacebookMini($('[data-sublink="facebook"] article.mini-relation-panel'),$('[data-sublink="facebook"] #f_nav-mini'));
|
|
fMiniManager.attach(f);fFicheManager=new inputFacebookFiche($('[data-sublink="facebook"] article.relation-panel'),$('[data-sublink="facebook"] #f_nav-fiche'));fFicheManager.attach(f);fMatriceManager=new inputFacebookMatrice($('[data-sublink="facebook"] article.matrice-panel'));fMatriceManager.attach(f);$('[data-sublink="facebook"] #f_clear-all').addEventListener("click",function(b){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(b){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");b={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 c=$('[data-sublink="facebook"] #f_download-target');c.download="local-facebook-data.json";c.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(b));c.click()},!1);$('[data-sublink="facebook"] #f_import-all').addEventListener("click",function(b){$('[data-sublink="facebook"] #f_local-upload').click()},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("click",
|
|
function(b){b.target.value=null},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("change",function(b){b={path:"upload/local_data",file:$('[data-sublink="facebook"] #f_local-upload').files[0]};api.send(b,function(b){console.log(b);if(0!=b.ModuleError)return Notification.error("Erreur",b.ModuleError),!1;lsi.set("f_subject",0,b.local_data.subject);lsi["import"]("f_contacts",b.local_data.contacts);lsi["import"]("f_mini-fiches",b.local_data.mini);lsi["import"]("f_fiches",b.local_data.fiches);
|
|
lsi.set("f_matrice",0,b.local_data.matrice);fSubjectManager.storageToFields();fContactManager.storageToFields();fMatriceManager.storageToFields();f(!0)})},!1);$('[data-sublink="facebook"] #f_submit-all').addEventListener("click",function(b){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 <i>sujet</i>"),
|
|
!1;b=lsi["export"]("f_mini-fiches");var c=0,a;for(a in b)if(!isNaN(a)&&(c++,!b[a].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+c+"</b> est incompl\u00e8te et/ou incorrecte"),!1;b=lsi["export"]("f_fiches");for(a in b)if(!b[a].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(a)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;a={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(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;console.log(a)},!1)},!1)})})})})})},!1);
|