1let enregistrement = (function ($) { 2 3 const PAGE_IDS = { 4 5 STATUT_ENTREPTISE_PERSONNE_PHYSIQUE: 'statutEntreprisePersonnePhysique', 6 STATUT_ENTREPTISE_PERSONNE_MORALE: 'statutEntreprisePersonneMorale', 7 DENOMINATION_SOCIALE: 'denominationSociale', 8 NOM_COMMUN_NAISSANCE: 'nomCommuneNaissance', 9 CODE_NAF: 'codeNAF', 10 CODE_NAF_FULL_LABEL: 'codeNafFullLabel' 11 12 }; 13 14 let PAGE_VARIABLES_LABELS = { 15 16 INTERMEDIARY_IDENTITY_LABEL: undefined, 17 LEADER_LABEL: undefined 18 19 }; 20 21 let nafs = undefined; // Will be instance of Nafs 22 23 let self = {}; 24 25 /** 26 * Initialize the object logic of the page 27 * @param nafsJson 28 * @param labels 29 */ 30 self.init = function({nafsJson, labels}){ 31 32 _initPage({nafsJson, labels}); 33 _initNafs(nafsJson); 34 _onchangeEvents(); 35 36 }; 37 38 function _initPage({nafsJson, labels}){ 39 40 let $statutEntreprisePersonnePhysique = $('#' + PAGE_IDS.STATUT_ENTREPTISE_PERSONNE_PHYSIQUE); 41 let $statutEntreprisePersonneMoral = $('#' + PAGE_IDS.STATUT_ENTREPTISE_PERSONNE_MORALE); 42 $('#' + PAGE_IDS.DENOMINATION_SOCIALE).parent().hide(); 43 if(document.getElementById('statutEntreprisePersonneMorale').checked){ 44 $statutEntreprisePersonneMoral.trigger("click"); 45 $('#' + PAGE_IDS.DENOMINATION_SOCIALE).parent().show(); 46 } 47 if(document.getElementById('statutEntreprisePersonnePhysique').checked){ 48 $('#' + PAGE_IDS.DENOMINATION_SOCIALE).parent().hide(); 49 $statutEntreprisePersonnePhysique.trigger("click"); 50 }// by default we select Personne physique and we hide denominationSociale 51 52 53 PAGE_VARIABLES_LABELS.INTERMEDIARY_IDENTITY_LABEL = labels && labels.INTERMEDIARY_IDENTITY_LABEL; 54 PAGE_VARIABLES_LABELS.LEADER_LABEL = labels && labels.LEADER_LABEL; 55 56 } 57 58 function _initNafs(nafsJson){ 59 60 if(Nafs) { 61 nafs = new Nafs({nafs: nafsJson}); 62 } 63 else { 64 console.error("Nafs class not found"); 65 } 66 67 } 68 69 function _onchangeEvents(){ 70 71 document.getElementById(PAGE_IDS.STATUT_ENTREPTISE_PERSONNE_PHYSIQUE).addEventListener('change', _statueEntreprise); 72 document.getElementById(PAGE_IDS.STATUT_ENTREPTISE_PERSONNE_MORALE).addEventListener('change', _statueEntreprise); 73 document.getElementById(PAGE_IDS.NOM_COMMUN_NAISSANCE).addEventListener('change', _propagateCityInseeCode); 74 document.getElementById(PAGE_IDS.CODE_NAF).addEventListener('change', _checkNaf); 75 document.getElementById("paysNaissance").addEventListener('change' , _checkValue); 76 document.getElementById("nomCommuneNaissance").addEventListener('change' , _checkValue); 77 } 78 79 function _checkValue(){ 80 let pays = document.getElementById("paysNaissance") 81 if(pays.value !== "" && pays.value !== "France") {//un pays défini autre que France 82 document.getElementById("codeCommuneNaissance").value = "99"; 83 } 84 } 85 86 function _propagateCityInseeCode(event) { 87 88 let element = event.target; 89 let cityWithZipCode = $(element).val() 90 $("#list-nomCommuneNaissance").find("option").each(function() { 91 if ($(this).val() == cityWithZipCode) { 92 let inseeCode = $(this).data('codeInsee') 93 $("#codeCommuneNaissance").val(inseeCode) 94 } 95 }) 96 97 } 98 99 function _statueEntreprise(event){ 100 101 let element = event.target; 102 if(element.value === "PERSONNE_PHYSIQUE" && element.checked === true ){ 103 104 $('#' + PAGE_IDS.DENOMINATION_SOCIALE).parent().hide(); 105 _replaceTitleByLegalEntity(PAGE_VARIABLES_LABELS.INTERMEDIARY_IDENTITY_LABEL); 106 107 } 108 109 if(element.value === "PERSONNE_MORALE" && element.checked === true){ 110 111 $('#' + PAGE_IDS.DENOMINATION_SOCIALE).parent().show(); 112 _replaceTitleByLegalEntity(PAGE_VARIABLES_LABELS.LEADER_LABEL); 113 114 } 115 116 } 117 118 function _replaceTitleByLegalEntity(title){ 119 120 $("#legalEntityTitle").html(title); 121 122 } 123 124 /** 125 * Take care of the Naf libelle updating on the screen 126 * @param event 127 * @private 128 */ 129 function _checkNaf(event){ 130 131 let element = event.target; 132 _updateNafLibelle(element); 133 134 } 135 136 /** 137 * Updates the input libelle by translating the code to the libelle 138 * @param element 139 * @private 140 */ 141 function _updateNafLibelle(element){ 142 143 if(!element){ 144 console.error("element not given"); 145 return; 146 } 147 148 let foundCodeNafLabel = _findNafLibelle(element.value); 149 let codeNafLabelElement = document.getElementById(PAGE_IDS.CODE_NAF_FULL_LABEL); 150 codeNafLabelElement.innerHTML = foundCodeNafLabel; 151 152 } 153 154 /** 155 * Find the libelle of a Naf 156 * @param codeNaf 157 * @returns {string} 158 * @private 159 */ 160 function _findNafLibelle(codeNaf){ 161 162 let foundLibelle = nafs.findLibelleByCode(codeNaf); 163 let result = foundLibelle ? ": " + foundLibelle : ": ---"; 164 return result; 165 166 } 167 168 return self; 169 170})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.